Git Product home page Git Product logo

pdf-generator-service's Introduction

pdf-generator-service - DEPRECATED

There is no replacemrnt platform service provided at this time.

There are 2 common approaches to generating PDFs:

  1. Use HTML to build a view, then turn that into a PDF. This is useful if the PDF you want to generate is a copy of a web page.
  2. Generate a PDF without using HTML as an intermediary. A PDF is very different to a web page, especially if you expect a user to print the PDF. And the PDF should have its own design consideration. In some cases the end user of the PDF may be an entirely different user to the one creating the PDF. In the case of print and post forms for example, the PDF needs to mostly work for the person processing the form.

Performance issues with PNG image files

  • GhostScript is used to convert PDF to PDF/A format but but has a bug that results in slow conversion, poor rendering and large resulting files.
  • using gif format files instead of png avoids this issue

Endpoint URLs

POST /pdf-generator-service/pdf-generator/generate

Service Definitions

All requests use the HTTP POST method

PDF Generator Service

Functionality

* Generates a PDF based on the submitted html
* Generated PDF must be PDF/A 1 or PDF/A 2 compliant
* Generated PDF must match the HTML page from which it was generated

Request

* html-www-urlencoded-form with a required field 'html' that contains the html to be converted and an optional 'force-pdfa' boolean field to enforce PDF/A generation.
* post Content-Type: application/json {"html": "<html><title>Some Html</title></html>", "force-pdfa":"false"}

Response

* HTTP 200 OK with a generated and downloadable PDF
* HTTP 400 Bad Request for invalid/error scenarios

Run the application locally

To run the application execute

sbt ~run 9852

The endpoints can then be accessed with the base url http://localhost:9852/pdf-generator-service/pdf-generator/generate

Tips on installing application on Ubuntu

This command will install ghostscript:

sudo apt-get install ghostscript

This command will install wkhtmltopdf:

sudo apt-get install wkhtmltopdf

We then need to add this symbolic link so that the service finds the program:

sudo ln -s /usr/bin/wkhtmltopdf /usr/local/bin

If you need to check the logs of the generator service, you may find it useful to use this command to remove the graphite warnings:

sm --start PDF_GENERATOR_SERVICE --appendArgs '{"PDF_GENERATOR_SERVICE":["-Dmicroservice.metrics.graphite.enabled=false"]}' -f

This command will bring up the logs of the pdf-generator-service:

sm --logs PDF_GENERATOR_SERVICE

GitHub API Token

You will need to generate a Personal Access Token (PAT) called GITHUB_API_TOKEN and store is a system variable by following the instructions on the GitHub page.

License

This code is open source software licensed under the Apache 2.0 License

pdf-generator-service's People

Contributors

anand462 avatar andrewarkless avatar andrewbrown22 avatar brian-digital avatar cameronstalker1 avatar cepoole avatar colin-lamed avatar danewatts avatar daniel-manning avatar gianick avatar habeeb-olayemi avatar hmrc-web-operations avatar jacktattersall avatar kurtlogan avatar liampan avatar manpreetsingh1000 avatar matthew-mcnally avatar mbrookesy avatar miloszm avatar ookami-001 avatar pascal22p avatar peteanning avatar richardjamesbaconhmrc avatar smithrebecca avatar tateni93 avatar thedanieldoyle avatar tomasz-rosiek avatar vinnicombe avatar warrd avatar willhay108 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pdf-generator-service's Issues

Mac compatibility

Hi, on macs we have been unable to run any version since 1.20.0 - this also requires us to use an old version of ghostscript. Currently we cannot run local acceptance tests on our service on Macs as with this version the browser tab title is not set correctly. Is there some fundamental problem that cannot be fixed for mac compatibility?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.