pdfitextpdfboxopenpdf

Creating a custom diploma from a designer template, filling in data


I need to be able to create PDFs with printable diplomas for sports events (10K runs etc).

A graphic designer creates a beautiful diploma with placeholder texts (name of participant, finish time) - and I need to get from that to a finished PDF (on the fly), which the participant can download.

I have done a lot of generating PDFs from HTML and Word docs, but this is something new to me, so I am can't figure out where to start.

My best idea right now is to have the designer export as PDF without placeholder text, but with x/y coordinates and font on where to input name, time etc... But I would prefer to not have to store the x/y coordinates, font etc - and just be able to fill in a "template"...


Solution

  • There are several possibilites e.g:

    1. Let your designer create a diploma PDF
    2. Add form fields at the places you want to add name and event etc. This can be done by you or the designer or a PDF lib like openPdf / PdfBox / iText
    3. Fill in the data using openPdf / PdfBox / iText and afterwards make the field readonly
    4. You could even sign the PDF afterwards (and thus "protect" it from changes)

    OR 2a) You could also add text to an existing PDF but this is a bit trickier since you need to know the coordinates and need to care about length issues etc.