Generate pdf from data in mysql - java

I'm creating an Java application for self-employed workers. In this application, the self-employed workers can keep track of hours worked on different projects. Storing hours worked on different projects is now working. I store it in a MySQL database. Next step is to use this data and create invoices. The first option I want to work on is creating an invoice in PDF format. Could you suggest an approach?
One approach is generate an XML document and use that to generate the PDF document. Possible with a template containing a pre-formatted invoice. But how?

Another approach may be to generate a PDF using pure PDFBox. You can use a background image as a template and then overlay it with details that you retrieve from your DB.

You can use Apache FOP to generate a pdf from a xml using xsl transformations

You can use iText library for creating pdf. Its open source and easy to use with Java. Also the documentation provided by iText team is very good for starting any PDF generation project.

Related

OpenPdf/PdfBox automatically generate table of contents

In my current java/springboot project, I need to create a PDF dynamicaly containing paragraphs, images and tables.
And I also need to add the table of content of this document.
I'm wondering if there is a way to automatically generate this table of contents using either openPdf or pdfBox.
I noticed that it is possible to do so using IText, but it is not free...
Thanks in advance for your help.
You can use OpenPDF for this: https://github.com/LibrePDF/OpenPDF
Also see Flying Saucer: https://github.com/flyingsaucerproject/flyingsaucer
Actually neither openPdf nor pdfBox provide a way to automatically generate table of contents :-(
iText provide us with such functionality, but it is under AGPL licence so cannot be used in my case...
For the time being, I will try acheive my needs using apache POI then convert the generated docx to pdf using opensagres/xdocreport (see: Trying to make simple PDF document with Apache poi)

Is there any way to extract charts from excel and convert them to image format using java?

I am working on an application that generates a xdoc output with a series of charts and tables, whose data comes from a given excel file. Currently I have been able to generate the necessary charts and tables managing the data with Apache Poi and generating the actual charts in a separate excel file using GCExcel, nevertheless, Apache does not include support to turn XSSFChart objecs into images in order to insert them into the document, and GCexcel's unlicensed version doesn't allow me to exoprt charts to images either. Anybody knows a way in which I can work around this issue?
Check out Spire.XLS library.
Download the free version here
Read what you can do using the library (features)
Official tutorial
Convert the excel file to image
I am not sure if this will actually work because I did not implement something like this before.

library to bring a pdf to code

I have the need to create some pdf through java code, pdf templates are fixed and are very complex too. Each pdf represents a module and I have to fill it with informations I get from other sources in my application and finally create the complete pdf.
So, is there a library which, given a pdf, scans it and creats some java code which will eventually create it back? This way once I get the pdf template in java code I just have to edit it adding my informations and create it back.
You can check these 2 link it's have all information regarding PDF CRUD operation.
How to read PDF files using Java?
http://mrbool.com/how-to-create-write-and-read-pdf-files-using-pdfone-and-java/27058
I have used with success iText http://itextpdf.com/ for various tasks involving creating, parsing and modifying pdf files. Please not that this one is not free for commercial use and the pricing isn't cheap either.
However, your question is a possible duplicate of the folowing one, so be sure to check the answers there:
https://stackoverflow.com/questions/6118635/what-is-the-best-pdf-open-source-library-for-java
itext is one of best approach for your need..
itext API'S

populate data from java to pdf

I am currently looking for a solution to populate a PDF file from the java code, Is there any APi for that, I googled it and found JustformsPDF does the trick, but it works only for some pdf and not all + its a old API without recent developments/support.
Basically I have an existing PDF (and do not want to build it) I just need to populate my java data inside that pdf.
any suggestions ?
These two should be able to do the job (these are the ones I know, there may be more):
Apache PDFBox
iText
You can use our product PDFOne (for Java). It has a document component that can also fill form fields in existing PDF documents. Viewer and printer components are also available.

Creating PDF for Java applications

How to create pdf with complex design views in Java?I have tried it using jasper reports.Is there Any Ideas for creating PDF for Income tax forms?.
A commonly used Java API to create PDF files is iText. Give it a look. API documentation can be found here, code examples can be found here, a tutorial can be found here.
A good but less widely known Java API is OOo API wherein you can create any OOo document to your taste and finally export to PDF.
Have you taken a look at the Apache PDFBox project. I believe you can create PDFs using this library, although it is more commonly used in Lucene to convert PDFs to text to allow indexing.
You could also try Docmosis or JODConverter to do the conversion as long as you can install OpenOffice somewhere. They work on many platforms and can be Java controlled and will save you the hassle of learning the OOo UNO API.
Design your complex PDF Form with the appropriate tools, something like Acrobat Professional. Then from your Java code, you generate an FDF file (Form Data Format) and let the PDF Reader do the merging or you do it from the server-side and stream back the result.
Possible solutions to process FDF are Adobe Java FDF Toolkit or Apache PDFBox.
one approach that requires very little programming is converting your Java object to XML using the Java Binding API for XML (JABX) and then use apache FOP (XSL-FO) to create the PDF from XML. The adavantage of this approach is that is almost 100% declarative, .i.e no programming involved other than executing jabx and apache fop. If you want a tool to create the XSL-FO template, look at J4L FO Designer
You can try ITextPDF.jar Add this jar to your application and please go through the examples to know more about the tags and design procedure used for creating a PDF Document. Check this link for a simple exmaple http://itextpdf.com/examples/iia.php?id=12

Categories