Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open Source HTML to PDF in Java (2014) [closed]

I've been searching high and low for an up to date solution to this age old problem.

Long story short I want to take css + html -> pdf and do it in java.

I don't want to use an API as the data is sensitive. Googling provides me with countless sites/services that offer to do this but I'm looking for a stand alone tool and looking for one that will work nicely from my java server. I've found this awesome looking command line tool but it's a command line tool and spawning processes off a web server starts to get sketchy IMO (but I'm always willing to hear otherwise). Additionally flying saucer seems to be a standard choice, but I've heard mixed reviews.

Here is a 5 year old question on the subject, but I figure things have changed! Especially with all the work being done in the area of front end unit testing with dom manipulation I figure there might be some less than conventional solutions and I'm willing to hear them all!

Any help would be greatly appreciated.

like image 990
matty-d Avatar asked Apr 16 '14 18:04

matty-d


1 Answers

You might try a combination CSSBox that converts HTML+CSS to SVG and then use for example Batik for creating your PDF as proposed for example here. FlyingSaucer could also do the job.

The choice depends on your further requirements. E.g. are you processing "street HTML" or well-formed documents? What about the pages in the resulting PDF? What about interactive elements in the HTML pages?

I mean the only way is to try at least some options practically and then you may ask more specific questions about some particular problems.

like image 170
radkovo Avatar answered Sep 29 '22 20:09

radkovo