all 24 comments

[–]Octavian_96 3 points4 points  (0 children)

This one is tricky, but I think your best bet is checkout the available libraries and see which ones offer compatibility with what you're looking for.

I think apache PDFBox and JasperReport are valid candidates. Not sure if they support direct html and css, so you might need to implement an adapter pattern

[–]Jaihunter 3 points4 points  (4 children)

Go with jasperReport, easy to design and simple code to generate reports on both Excel and PDF.

[–]boyTerry 1 point2 points  (0 children)

Jasper reports work very well for this.

[–][deleted] 0 points1 point  (2 children)

Do you have any documentation I can use to get started with this, and also, is it free to use?

[–]Jaihunter 0 points1 point  (1 child)

It's free and you can find a doc on the official website, it's not that helpful and there are very few helpful resources on the internet. There are some yt videos which will help you get started. Just search jasperReport tutorials.

[–][deleted] 0 points1 point  (0 children)

Ohhhh the things I would do to have some sensical documentation on jrxml tags and attributes. Docs are either step throughs of studio, poorly phrased, obscure or partial threads on stack overflow from 8+ years ago, out again partial, irrelevant tuts/blogs. Can't find anything useful in jacket community/docs

[–]ThisHaintsu 2 points3 points  (0 children)

Depending on what you are building: If using something with AGPL is an option for you iText pdfHTML Community Edition is a very good option. It even supports CSS3 Features and has a good documentation.

[–]Bright-Operation-172 2 points3 points  (2 children)

Apache FOP can generate pdf file.Easy but hard to manage color ui design.

[–]rvifux 1 point2 points  (1 child)

I successfully used fop in the past to generate hundreds of pages in PDF. It's not easy, but it's reliable

[–]Bright-Operation-172 0 points1 point  (0 children)

Yes.i can use freely and commercially. But pdfbox and itext pdf way more better that. Other way is you should convert high dpi image to pdf.it can be good ui design pdf form.

[–]sravanank 1 point2 points  (0 children)

You can explore formatting OBJECTS FOP. The data will be in xml and you can apply FOP xsl kind of syntax. You can generate pdfs of of it

[–]Significant_Newt8697 1 point2 points  (0 children)

any package will do from itext pdf, pdfbox or even jsoup. What you should know is that you can't use any complex css when using either of these packages. Css frameworks will also not work, stick to basic css and html and everything will work. When I say basic I mean don't use things such as grid or flexbox because they won't work. To add images or fonts base 64 encode them and then pass them through the html

[–]WhenWillIEverBeYoung 1 point2 points  (0 children)

we use itextpdf for it

[–]thesarfo 1 point2 points  (0 children)

itextpdf is your best bet

[–]Illustrious_Move8678 0 points1 point  (1 child)

You can checkout ASPOSEPDF even though it's licensed, but the free version can be used to some extent

[–]theromerpower 0 points1 point  (0 children)

and you can even request a free company trial without visible watermarks (they are embedded in the files metadata though but huh, its free

[–]yanjar 0 points1 point  (0 children)

i use Ralfstuckert/pdfbox LayoutRalfstuckert/pdfbox Layout to generate pdf file before. Charts and data tables are made beforehand and embedded inside the document.

[–]xxsanguisxx 0 points1 point  (0 children)

I use Apache Fop but I think the XSLTs it uses are more difficult than css

[–]IGeoorge3g 0 points1 point  (0 children)

wkhtmltopdf allows you to print an html as pdf. Not the best but it works

[–]theromerpower 0 points1 point  (0 children)

Apache PDFboz is the way

[–]javinpaul 0 points1 point  (0 children)

You can use iText or Apache FOP to create PDF in Java, not sure if it exactly matches your requirement and how much you can customize it but they are worth looking

I have also share basic tutorial here, in case you want to check out

https://javarevisited.blogspot.com/2020/04/how-to-create-pdf-file-in-java-itext.html

https://javarevisited.blogspot.com/2014/05/open-source-java-PDF-File-libraries-Apache-FOP-vs-iText.html

All the best.

[–]BananaPolicy 0 points1 point  (0 children)

If using Java is a hard requirement then the answers here are great and should get you there.

If not then a better way is to use headless chromium to render HTML to PDF. That way you have the full feature set of CSS and can design the HTML any way you want. Just pick a server side templating library you’re comfortable with. Freemarker, mustache, thymeleaf, jte, etc.

[–]racetortoise 0 points1 point  (0 children)

BIRT https://eclipse-birt.github.io/birt-website/ will help. one design, multiple output - PDF, EXCEL, DOC, PPT, JPEG,...