|
| 1 | +# PDF generator |
| 2 | + |
| 3 | +The digilib `PDFGenerator` servlet creates custom PDF documents from images on the server |
| 4 | +for download by the user. The user can specify the sequence of images, the image resolution |
| 5 | +and information for the generated cover page of the document. The frontend will reload |
| 6 | +the status page until the document has been generated and then download the document. |
| 7 | +Generated documents will be cached on the server to speed up subsequent requests for the same document. |
| 8 | + |
| 9 | +## Installation |
| 10 | + |
| 11 | +The `PDFGenerator` servlet and its frontend are built by the `pdf` and `frontend-pdf` modules. |
| 12 | +You can add both to the [manual build process](build-maven.html) using the `-Ppdf` option but it is |
| 13 | +easier to include the generated artifacts the `pom.xml` of your own Maven project: |
| 14 | + |
| 15 | +``` |
| 16 | +<dependency> |
| 17 | + <groupId>digilib</groupId> |
| 18 | + <artifactId>digilib-frontend-pdf</artifactId> |
| 19 | + <version>2.10.0</version> |
| 20 | + <type>war</type> |
| 21 | + <scope>runtime</scope> |
| 22 | +</dependency> |
| 23 | +``` |
| 24 | + |
| 25 | +(see https://github.com/robcast/digilib-frontend-template for a basic setup) |
| 26 | + |
| 27 | +## Request |
| 28 | + |
| 29 | +The `PDFGenerator` servlet accepts the first request as a HTTP POST request with the following parameters: |
| 30 | + |
| 31 | +`fn` |
| 32 | +: image directory path name (required) |
| 33 | + |
| 34 | +`pgs` |
| 35 | +: image sequence specification (required) examples: "1-" (all pages), "1-5", "5,10,15", "1-7,9-13" |
| 36 | + |
| 37 | +`dw` |
| 38 | +: pixel image width (optional) |
| 39 | + |
| 40 | +`dh` |
| 41 | +: pixel image height (optional, default 500) |
| 42 | + |
| 43 | +`logo` |
| 44 | +: url of header logo for cover page (optional) |
| 45 | + |
| 46 | +`header-title` |
| 47 | +: header title for cover page (optional) |
| 48 | + |
| 49 | +`header-subtitle` |
| 50 | +: header subtitle for cover page (optional) |
| 51 | + |
| 52 | +`title` |
| 53 | +: document title for cover page (optional) |
| 54 | + |
| 55 | +`author` |
| 56 | +: document author for cover page (optional) |
| 57 | + |
| 58 | +`date` |
| 59 | +: document date for cover page (optional) |
| 60 | + |
| 61 | +`reference` |
| 62 | +: document full reference for cover page (optional, alternative to title, author, date) |
| 63 | + |
| 64 | +`online-url` |
| 65 | +: footer online url for cover page (optional) |
| 66 | + |
| 67 | +The very simple but functional HTML form `/pdf/form.jsp` can be used as a starting point for customization. |
| 68 | + |
| 69 | +The response to the first post request is a redirect to a HTTP GET request with an added `docid` |
| 70 | +parameter identifying the requested document. The following GET requests must provide the `docid` |
| 71 | +parameter and the response will be either a work-in-progress waiting page, an error page or the final document |
| 72 | +download. |
| 73 | + |
| 74 | +The `PDFGenerator` servlet can also be queried as a ReST-style API. Responses will be given as |
| 75 | +JSON documents with the keys `docid`, `status` and `message` if the request carries the `Accept` |
| 76 | +header value `application/json`. |
| 77 | + |
| 78 | +## iText PDF license |
| 79 | + |
| 80 | +The `PDFGenerator` servlet uses the [iText PDF library](https://itextpdf.com). |
| 81 | +You can use it either under an [AGPL license](https://itextpdf.com/en/how-buy/agpl-license) |
| 82 | +or request a commercial license from the vendor. |
0 commit comments