GlenKPeterson / PdfLayoutManager

Adds line-breaking, page-breaking, tables, and styles to PDFBox
45 stars 20 forks source link

Allow access to PDDocument #19

Open bshouse opened 7 years ago

bshouse commented 7 years ago

In order to encrypt or attach files, I believe I need access to the PDDocument.

Would it be possible to add a

PdfLayoutMgr.getPdDocument() {
   return doc;
}
GlenKPeterson commented 7 years ago

The reason I didn't allow that was that if you change the state of the PdDocument directly, you could mess things up. What functions/fields do you need to access? Also, what version of PdfLayoutManager are you using? I've been making changes in a branch that may never see production.

bshouse commented 7 years ago

I fully understand the need to protect the document so that layout manager can do its job.

For encryption I need to call: PDDocument.protect(StandardProtectionPolicy) For File attachments: PDDocument.getDocumentCatalog().setNames(PDDocmentNameDictionary)

I am currently using the master branch that I cloned 8 days ago. I suspect 0.5.1.

Thank you for all the great work you have done here! It makes PDFs much easier to create and keep looking nice.

GlenKPeterson commented 7 years ago

This is a good idea. Sorry I haven't done it yet. The class PdfLayoutMgr is what currently wraps the PDDocument doc. If you add methods like setStandardProtectionPolicy() and setDocNameDictionary() (or other names you like better) that just call through to the underlying doc, and make minimal changes I'd be willing to merge that into the main branch so it's in future releases. It would be really nice if you made a unit test (in the root of the test package where TestManuallyPdfLayoutMgr sits now) that even prints a one page PDF using the two features you require. If the pdf has to be checked manually, just add some notes on what to look for. Once again, when you change PdfLayoutMgr, try to make absolute minimal changes, make it look like my code, etc. so I can merge it without much fuss.

In any case, if you just add those two methods and you know that they work for you, I can merge them to be in future releases.

bshouse commented 7 years ago

I will make it happen.

Thanks again.

bshouse commented 7 years ago

The pull request is ready. Please let me know if it doesn't make the grade.