|
1 | 1 | # wkhtmltopdf |
2 | 2 |
|
3 | | - |
4 | | - |
| 3 | + |
| 4 | + |
5 | 5 |  |
6 | 6 |
|
7 | | -Vapor 3 library for converting HTML (Leaf or otherwise) into PDF files using |
| 7 | +Vapor 4 library for converting HTML (Leaf or otherwise) into PDF files using |
8 | 8 | [wkhtmltopdf](http://wkhtmltopdf.org/). |
9 | 9 |
|
10 | 10 | ## Getting Started |
11 | 11 |
|
12 | 12 | Add the following in your `Package.swift` file |
13 | 13 | ```Swift |
14 | | -.package(url: "https://github.com/vapor-community/wkhtmltopdf.git", from: "2.0.0"), |
| 14 | +.package(url: "https://github.com/vapor-community/wkhtmltopdf.git", from: "3.0.0"), |
15 | 15 | ``` |
16 | 16 |
|
17 | 17 | ## 📘 Overview |
18 | 18 |
|
19 | 19 | First, install [wkhtmltopdf](http://wkhtmltopdf.org/downloads.html). This |
20 | | -library is tested on version 0.12.4. Specify the location of `wkhtmltopdf` |
| 20 | +library is tested on version 0.12.5. Specify the location of `wkhtmltopdf` |
21 | 21 | in the `Document` initialiser. The default is `/usr/local/bin/wkhtmltopdf`. |
22 | 22 | Run it to ensure it and any dependencies are installed correctly. |
23 | 23 |
|
@@ -49,14 +49,14 @@ func pdf(_ req: Request) -> Future<Response> { |
49 | 49 | // Add the pages to the document |
50 | 50 | document.pages = [page1] + pages |
51 | 51 | // Render to a PDF |
52 | | - let pdf = try document.generatePDF(on: req) |
| 52 | + let pdf = try document.generatePDF(eventLoop: req.eventLoop) |
53 | 53 | // Now you can return the PDF as a response, if you want |
54 | 54 | return pdf.map { data -> Response in |
55 | | - let http = HTTPResponse(status: .ok, |
56 | | - headers: HTTPHeaders([("Content-Type", "application/pdf")]), |
57 | | - body: data) |
58 | | - return Response(http: http, |
59 | | - using: req) |
| 55 | + return HTTPResponse( |
| 56 | + status: .ok, |
| 57 | + headers: HTTPHeaders([("Content-Type", "application/pdf")]), |
| 58 | + body: .init(data: data) |
| 59 | + ) |
60 | 60 | } |
61 | 61 | } |
62 | 62 | } |
|
0 commit comments