I am trying to create/maintain CRUD a PDF letter template using a PDFBox open source Java PDF Generation Library. The letter would have the following section has represented in my POJO class.
private byte[] fileContent;
private String heading;
private String returnAddress;
private Date issueDate;
private String recipientName;
private String recipientAddress;
private String salutation;
private String title;
private String body;
private String closingText;
private String signatureLine;
private String companyLine1;
private String companyLine2;
My application is a spring boot web service, which allows the end user to view,edit and create new pdf letter. Based on the documentation and tutorials I have seen online, I cannot create separate sections or content in the PDF org.apache.pdfbox.pdmodel.PDPage using key-value. So, I can retrieve the content in sections using the keys. Please, any ideas how to achieve this separation of the sections of the letters, using key-value pair for effective CRUD operation on the PDF Doc.
I am also considering creating a MongoDB collection called Letter, with document containing the the different sections of the letter as keys (fields) in the MongoDB document. Then, may have another field holding the full PDF document as a byte stream. I thought this may be a better design than saving the whole document and then parsing or traversing using substring or regex etc
Any design thoughts or implementation thoughts or references or PDFBox Sample code for similar feature e.g. creating and reading PDF content using key-value pair, will be appreciated. Thanks.