Active1 year, 9 months ago
I am trying to create a PDF from HTML content.
I was looking for an HTML to PDF renderer. We were using iText. I was looking to do same with Apache PDFBox. But, it looks like it cannot be done. I can either use Apache FOP or continue using iText. Here is the iText solution if anyone is interested: Java Render XML Document as PDF. With DocRaptor, it's fast and painless to convert HTML, CSS, and JavaScript into PDF and XLS documents with Java. Below are working Java examples for creating documents. Our API reference lists all the generation options and our style and formatting guide will help make it look perfect.
- OPEN HTML TO PDF OVERVIEW. Open HTML to PDF is a pure-Java library for rendering arbitrary well-formed XML/XHTML (and even HTML5) using CSS 2.1 for layout and formatting, outputting to PDF or images.
- Description: Official Java language specification for Java SE 7 edition is available online to view as HTML and download as PDF. This is the best FREE resource in Java, as it's from source and contains most up-to-date details about Java Programming language.
- Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, PHP, Python, Bootstrap, Java and XML.
- How to convert HTML to PDF using iText duplicate Ask Question Asked 6 years, 2 months ago. This is my code to convert HTML to PDF. I am able to convert it but in PDF file it saves as whole HTML while I need to display only text. Converting a html to pdf using itext in java. Java convert dynamic generated HTML content to PDF.
Games serials and cracks. When I take this
byte[]
and save to a file, the file is blank. I am using PDStream
to embed the input stream into the documentFrom the http://pdfbox.apache.org/apidocs/
Reads all data from the input stream and embeds it into the document, this will close the
KirbyInputStream
.10.4k66 gold badges6565 silver badges8888 bronze badges
vsinghvsingh4,05311 gold badge4343 silver badges4646 bronze badges
1 Answer
I was looking for an HTML to PDF renderer. We were using iText. I was looking to do same with Apache PDFBox. But, it looks like it cannot be done.
I can either use Apache FOP or continue using iText.
Here is the iText solution if anyone is interested:Java Render XML Document as PDF
If you are looking for a solution for merging using PDF box, here it is Merge pdf files using Apapche pdf box
Community♦
vsinghvsingh4,05311 gold badge4343 silver badges4646 bronze badges
Not the answer you're looking for? Browse other questions tagged javapdfpdfbox or ask your own question.
Active1 year, 9 months ago
This question already has an answer here:
- Converting HTML files to PDF [closed] 8 answers
This is my code to convert HTML to PDF. I am able to convert it but in PDF file it saves as whole HTML while I need to display only text.
Alexis Pigeon<html><body> This is my Project </body></html>
gets saved to PDF while it should save only This is my Project
.6,5211010 gold badges3232 silver badges4242 bronze badges
Aman KumarAman Kumar15844 gold badges44 silver badges1111 bronze badges
marked as duplicate by Ravi, Richard Sitze, AurA, Dirk, Antal Spector-ZabuskyJul 24 '13 at 19:34
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
2 Answers
Html To Pdf Java Free
You can do it with the
HTMLWorker
class (deprecated) like this:or using the
bluishXMLWorker
, (download from this jar) using this code:15.2k1919 gold badges9696 silver badges155155 bronze badges
MaVRoSCyMaVRoSCy14.7k1111 gold badges6969 silver badges112112 bronze badges
This links might be helpful to convert.
If it is a college Project, you can even go for these,http://pd4ml.com/examples.htm
Example is given to convert HTML to PDF
JayeshJayesh3,56077 gold badges3838 silver badges6868 bronze badges