Active9 months ago
At the moment, I'm creating an XML file in Java and displaying it in a JSP page by transforming it with XSL/XSLT. Now I need to take that XML file and display the same information in a PDF. Is there a way I can do this by using some kind of XSL file?
- Aug 16, 2019 THE unique Spring Security education if you’re working with Java today. In this quick article, we'll focus on creating PDF document from scratch based on popular iText and PdfBox library. Both, the iText and PdfBox are java libraries used for creation/manipulation of pdf.
- Creating PDF Files in Java 1. In this quick article, we’ll focus on creating PDF document from scratch based on. Maven Dependencies. The latest version of the libraries can be found here: iText and PdfBox. Both, the iText and PdfBox are java libraries used for.
- Creating Table in PDF using Java and iText iText is a free and open source library for creating and manipulating PDF files in Java. In this tutorial we are going to learn how to create a Paragraph and a Table layout in PDF.
Sep 17, 2007 There's also a package call PDFBox. You deliver the PDF just like any other data stream, In a Servlet set the resonse type to 'application/pdf'. Following are few libraries to create PDF with Java: iText; Apache PDFBox; BFO; I have used iText for genarating PDF's with a little bit of pain in the past. Or you can try using FOP: FOP is an XSL formatter written in Java. It is used in conjunction with an XSLT transformation engine to format XML documents into PDF. Generate PDF documents directly from your Java programs. JPDFWriter is a Java class library that allows you to create PDF documents directly from your Java programs without having to install any third party drivers or software. JPDFWriter emulates the standard Java classes to print and draw graphics to reduce the learning curve when using the library and reuse existing code.
I've seen the iText Java-PDF library, but I can't find any way to use it with XML and a stylesheet.
Any assistance would be much appreciated. Thanks in advance!
Philip MortonPhilip Morton58.4k3636 gold badges8282 silver badges9494 bronze badges
11 Answers
You can use XSL Formatting objects.Here are some good articles on how to do it:
Battlefield 2 full game. TORRENT – FREE DOWNLOAD – CRACKEDGame OverviewThe sequel to the blockbuster online multiplayer war Battlefield franchise, EA and developer Digital Illusions are taking the battle to another realm with a modern-war era edition. Players from the United States, China and the Middle East Coalition (all armed with realistic armarments andTitle: Battlefield 2: Complete CollectionDeveloper: N/APublisher: N/ARelease Date: N/AGenre: Action, AdventureDOWNLOAD LINKSRelease Name: Battlefield 2 Complete CollectionCracked by: P2PRelease Size: 4.57 GBTORRENT LINKSystem RequirementNo Information FoundScreenshots.
Gray99.3k1515 gold badges240240 silver badges308308 bronze badges
Bogdan MaximBogdan Maxim3,49133 gold badges1919 silver badges3434 bronze badges
A - Explanation
You should use Apache FOP framework to generate pdf output. Simply you provide data in xml format and render the page with an xsl-fo file and specify the parameters like margin, page layout in this xsl-fo file.
I'll provide a simple demo, I use maven build tool to gather the needed jar files. Please notify that at the end of the page, there is an svg graphics embedded in pdf. I also want to demonstrate that you can embed svg graphics inside pdf.
B - Sample XML input data
C - The XSL-FO Template
D - Project Directory Structure
E - Pom file
F - Demo Code: PdfGenerationDemo.java
G - Sample Output: output.pdf
Levent DiviliogluLevent Divilioglu7,12833 gold badges3838 silver badges8989 bronze badges
hakanhakan
BIRT has a GUI for Eclipse that lets you define the PDF from XML, DB, CSV, etc etc.
bluish15.2k1919 gold badges9696 silver badges155155 bronze badges
jeff porterjeff porter3,9181111 gold badges5353 silver badges105105 bronze badges
You might want to look at the XSL-FO libraries that are out there that can do PDF creation as a transformation. I'll try to find a link.
Mitchel SellersMitchel Sellers53.3k1212 gold badges100100 silver badges161161 bronze badges
Try the xhtmlrenderer project. See the article 'Generating PDFs for Fun and Profit with Flying Saucer and iText'.
axelclkaxelclk
You can apply XSL-Fo to your XML and transform it with Java transformer:
Tim Cooper126k3232 gold badges259259 silver badges233233 bronze badges
YaroslavYaroslav
Use JasperReports. You can either pull the data from Database or XML.You can export to many formats : pdf, excel, html, etc..
raffimdraffimd
Coming in late, you can create a static PDF with Adobe's designer with editable fields, then create a matching XDP XML document.
Dean JDean J22.4k1313 gold badges5656 silver badges9090 bronze badges
There are two ways to do this.
- Firstly, you can create a normal PDF which when read back will not give you the hierarchy of the original XML file. This is explained very elaborately in
'Section 9.4.2 Parsing XML'
of the'iText in Action : Edition 2'
. - Secondly, you can create a tagged PDF which contains both the hierarchy of the XML as well as the data. This enables you to read back the PDF file and create an XML file from this(which exactly matches the original XML file). This concept is also dealt with in detail in
'15.2.3 Adding structure'
of the'iText in Action : Edition 2'
.
Based on your requirements, you can use either of the approaches mentioned above.
Shriram Kalpathy MohanShriram Kalpathy Mohan
XML, CSS, XHTML, etc. consist in an 'alive ecosystem' of open standards, while XSL-FO is an isolated standard.
.. Historically XSL-FO and XSLT was created as twins brothers, but only XSLT remains an 'alive standard', XSL-FO concentrates a lot of DNA in proprietary (Adobe) standards.. now is obsolete.
Strictly speaking, XSL-FO is part of an 'abandoned way' that will not evolve, it ignores CSS, the 'new way' to express layout in the 'alive ecosystem'.
It is not a Java problem
See this answer about the use of CSS-page with XML or XHTML.
Not the answer you're looking for? Browse other questions tagged javaxmlpdfxsltitext or ask your own question.
Active2 years ago
Possible Duplicate:
PDF Generation Library for Java
PDF Generation Library for Java
I'm working on an invoice program for a local accounting company.What is a good way to create a PDF file with Java? Any good library?I'm totally new to PDF export (On any language).
lakshman1,74166 gold badges2828 silver badges5555 bronze badges
hogni89hogni89
1,06755 gold badges1717 silver badges3838 bronze badges
marked as duplicate by trashgod, Shog9♦Sep 23 '11 at 18:01
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.
3 Answers
I prefer outputting my data into XML (using Castor, XStream or JAXB), then transforming it using a XSLT stylesheet into XSL-FO and render that with Apache FOP into PDF. Worked so far for 10-page reports and 400-page manuals. I found this more flexible and stylable than generating PDFs in code using iText.
Philipp ReichartCreate Pdf In Java
Philipp Reichart19k55 gold badges5151 silver badges6363 bronze badges
Codec pack windows xp free download. Following are few libraries to create PDF with Java:
I have used iText for genarating PDF's with a little bit of pain in the past.
Or you can try using FOP: FOP is an XSL formatter written in Java. It is used in conjunction with an XSLT transformation engine to format XML documents into PDF.
Lii7,62644 gold badges4747 silver badges6464 bronze badges
RiteshRitesh3,86888 gold badges2525 silver badges4646 bronze badges
Another alternative would be JasperReports: JasperReports Library. It uses iText itself and is more than a PDF library you asked for, but if it fits your needs I'd go for it.
Simply put, it allows you to design reports that can be filled during runtime. If you use a custom datasource, you might be able to integrate JasperReports easily into the existing system. It would save you the whole layouting troubles, e.g. when invoices span over more sites where each side should have a footer and so on.
pudaykiran5,04577 gold badges4949 silver badges7474 bronze badges
boxboxCreate Pdf Template In Java
2,03822 gold badges2020 silver badges2929 bronze badges