convert from html to pdf and to image java - java

Well, I DID READ ALMOST ALL THE QUESTIONS HERE ABOUT THIS TOPIC!
I need an API - not at tool to convert in a very high quality from PDF to image.
So I didn't find any direct tool, and I used: HTML to PDF and PDF to image.
I tried:
PDFRenderer
FDFBOX
PDFONE
HTML2IMAGE
FLYING-SAUCE
ITEXT
JPEDAL
PDFCrown
Only the commerical ones (PDFCrown and PDFBox) came out with good results.
I thought that Java is for open source projects!
Am I missing any library that prints out in a high quality images from HTML (could be also from PDF, I can pay for half the way..)

I used the wonderful tool:
WKHTMLTOPDF.
It's very easy - just a command line.
Installation:
Download from here the version. To windows I used: wkhtmltox-0.11.0_rc1-installer.exe file.
Run the installer
Save your HTML to a file on your disk.
In java, Runtime.getRuntime().exec(wkhtmltopdf file.jpg myhomepage.jpg)
That's it! so easy to use:)

Related

HTML+ Images + CSS To PDF using Google Drive API

I know it's possible to convert an HTML file to PDF using Google Drive (HTML2PDF using Google Drive API) but I'd like to know if this HTML has images and CSS files is possible and how to do that.
You need convert HTML to a Docs file and export it as PDF. During the docs conversion most of the non-trivial styles are being trimmed. Basic coloring, sizing and positioning will all you'll get. The exported PDF is the Docs' file's PDF version. Images will be preserved though.
You can make experiments by uploading your html files to Google Drive on drive.google.com with conversion settings on and see the results.
For images you could try this: Embedding Base64 Images
Worked for me when uploading by web. Should work with my solution https://stackoverflow.com/a/21711109/592042
Css can be written right into html file.

How can we use AutoCAD to create PDF from DWG/DNG files programmatically using Java?

I am OK with any command line utility too. Basically I want to convert AutoCAD files to PDF using AutoCAD. I know there are several PDF virtual printer drivers that do this even without AutoCAD installed but I am looking at high quality PDF generation.
Thanks,
Nitesh
All you need is Adobe Acrobat. See:
http://help.adobe.com/en_US/acrobat/X/pro/using/WS58a04a822e3e50102bd615109794195ff-7f35.w.html

Generate a PDF and then download as JPEG or image file

I am using iText to generate PDF and is working fine, and I can also download it via browser as PDF. However, is it possible for java or iText to convert it to JPEG or any IMAGE file and allow users to download the image file.
response.setContentType("application/pdf; charset=utf-8");
Merely changing the contentType to image/jpg is not possible. I am continuously looking for answer but struggling to find one.
Any idea would be a lot of help
I dont know more about iText. But using PDFBox we can convert pdf document into images.
After splitting you can push images to response.
Here some reference links :
http://pdfbox.apache.org/commandlineutilities/PDFToImage.html
Converting a PDF into multiple JPGs with iText or other
http://www.javatpoint.com/example-to-display-image-using-servlet
you can use iText only for generating a pdf nothing else. see the link http://itextpdf.com/itext.php . see this to convert a pdf to image. See this link as well for clearer understanding with an example.

Java generate PDF from RTF

I want to generate PDF file from RTF file.
I have tried following.
Itext
It's already outdated and new version doesn't support rtf.
JDocConverter
It uses OpenOffice on the background. it is working fine, there is only one problem. Open office doesn't support drawing object in RTF.
Any other possible and reliable solutions?
Note: It would be fine don't use any commercial software.
Windows has native convert RTF to PDF using command line, however it will to a degree be limited, so it will use direct convert text and images, but it will depend on rtf syntax as to which drawn objects are supported. WORD ART drawing objects need MS Word to print
The output looks reasonable but here is the source in MSWord where the art was clearly not handled by the non-word printout.
Under Windows you could print to CutePDF Writer. This freeware uses Ghostscript as a back end.
You may try Aspose.Words for Java to convert RTF file to PDF format. You can load a file in RTF format into Aspose.Words for Java and then save it to PDF format. Please note that while loading specify RTF as LoadFormat value and pass PDF as SaveFormat value while saving the document. This doesn't require OpenOffice or any other software to be installed for the conversion to work.
Disclosure: I work as developer evangelist at Aspose.
Best way to do it is use MS Office. And Ms Office is able to save file in PDF format (you need install some addons I think).

Generate Save Convert to TIFF PDF

Please point us in right direction
We have a requirement to
Generate a PDF
Edit/Enter some fields on it
Save/Print the information
Should have a button on the pdf "Convert to TIFF" that should generate TIFF image of that PDF
I am sure we can do 1 and 2 very easily, we are planning to use iText API.
We dont have any clue about 4.
Experts if you have any idea please let us know.
We are using Java
There are lots of programs which do PDF to image conversion (both Open Source and Commercial). You can also use icepdf, Jpedal, Qoppa and PDFRenderer
You can create, edit and fill PDF form fields using Gnostice PDFOne. PDFOne can also print PDF documents and forms. Existing documents can also export PDF pages to image formats. For exporting to TIFF, you will also need for Advaned Imaging IO library from Oracle (Sun). Disclaimer: I work for this company.
If you want a button on the PDF to export the document to TIFF, then that is not possible, as PDF specification does not describe such a feature. As mentioned earlier, any PDF document can be converted to image formats including TIFF.
DISCLAIMER: I work for Gnostice.

Categories

Resources