Skip to content

Commit

Permalink
Update README with 3.0.0 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamburgsma committed May 11, 2020
1 parent 9d2ed0e commit 77d66d3
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# wkhtmltopdf

![Swift](http://img.shields.io/badge/swift-4.2-brightgreen.svg)
![Vapor](http://img.shields.io/badge/vapor-3.0-brightgreen.svg)
![Swift](http://img.shields.io/badge/swift-5.2-brightgreen.svg)
![Vapor](http://img.shields.io/badge/vapor-4.0-brightgreen.svg)
![Travis](https://travis-ci.org/vapor-community/wkhtmltopdf.svg?branch=master)

Vapor 3 library for converting HTML (Leaf or otherwise) into PDF files using
Vapor 4 library for converting HTML (Leaf or otherwise) into PDF files using
[wkhtmltopdf](http://wkhtmltopdf.org/).

## Getting Started

Add the following in your `Package.swift` file
```Swift
.package(url: "https://github.com/vapor-community/wkhtmltopdf.git", from: "2.0.0"),
.package(url: "https://github.com/vapor-community/wkhtmltopdf.git", from: "3.0.0"),
```

## 📘 Overview

First, install [wkhtmltopdf](http://wkhtmltopdf.org/downloads.html). This
library is tested on version 0.12.4. Specify the location of `wkhtmltopdf`
library is tested on version 0.12.5. Specify the location of `wkhtmltopdf`
in the `Document` initialiser. The default is `/usr/local/bin/wkhtmltopdf`.
Run it to ensure it and any dependencies are installed correctly.

Expand Down Expand Up @@ -49,14 +49,14 @@ func pdf(_ req: Request) -> Future<Response> {
// Add the pages to the document
document.pages = [page1] + pages
// Render to a PDF
let pdf = try document.generatePDF(on: req)
let pdf = try document.generatePDF(eventLoop: req.eventLoop)
// Now you can return the PDF as a response, if you want
return pdf.map { data -> Response in
let http = HTTPResponse(status: .ok,
headers: HTTPHeaders([("Content-Type", "application/pdf")]),
body: data)
return Response(http: http,
using: req)
return HTTPResponse(
status: .ok,
headers: HTTPHeaders([("Content-Type", "application/pdf")]),
body: .init(data: data)
)
}
}
}
Expand Down

0 comments on commit 77d66d3

Please sign in to comment.