How to generate a dynamic table on PDF by iText - java

I want to create a table programatically as like this PDF FCController.pdf.
As you see columns are Date, Name, Category, Amount. And I want to add a datepicker to change the list.
Can I generate a PDF as I said? Is it possible by Itext?

You want to embed a .swf file inside a PDF as a RichMedia annotation as explained in chapter 16 of "iText in Action - Second Edition". The book had two examples that showed you how to do this:
FestivalCalendar1 resulting in festival_calendar1.pdf
FestivalCalendar2 resulting in festival_calendar2.pdf
Although these examples work to some extend, I would urge you not to use this technology. Steve Jobs refused to support Flash on Apple devices and that started the decline of Flash as a technology. Adobe introduced support for Flash as RichMedia in PDF in one of their extensions to ISO-32000-1, but I know from insiders at Adobe that they regretted this. In any case: this functionality is not going to make it into ISO-32000-2 (PDF 2.0), which means that:
no other PDF viewers than Adobe Reader will have any interest in supporting this functionality, and
Adobe may decide to discontinue support for this functionality.
The example you've shared is nice, and it's not impossible to create such a PDF, but you should reconsider: it's not a future-proof solution.

Related

Dynamic PDF generation from PDF template in Java without formatting issue

I have a sample PDF which is having some placeholders, from which I need to generate PDF with Dynamic values in place of 'placeholders'. I need to do this in Java technologies. What should be the approach?
(Note: sample PDF having placeholders, Table structures, paragraphs, Stylesheets).
We, as iText team, has been receiving this exact question more and more everyday since many people/organisations want to generate custom filled PDF files with data they have. Many of them design forms in PDF and then they fill in the form programmatically. However there are problems with this solution: 1. You need license for a product where you will design the form 2. You need license (if applicable) for the PDF library to fill in the form 3. You (with your team) need to spend time to write the code where you fill in the form 4. You need to repeat all those each time you want to update your form etc. 5. Your form is most likely a static form, meaning that, for example, in case of an invoice you need to foresee how many rows you need to put in your form when designing it. What happens if users have more items than you foresee? You can use XFA forms but you probably know the cost of the designer and all other problems that come along with this deprecated technology.
We, as iText, bring a solution to all those problem just like we did in other tools we have. The solution is called iText DITO in which you design your PDF template in a WYSIWYG browser based editor. No coding is needed. If you want extra styling in your PDF, you can add CSS at any time. You can specify data-binding to elements in your design. Once you are done with your design, your project is basically ready to be deployed. If you need to generate tons of high-quality PDF files based on your template, you will use iText DITO back-end SDK to push your custom data (linking to data binding you have in your template) and your PDF files are created instantly.

How to create PDFs with automatic table layout in Java

In my application the user can configure their own table layouts to display the data on the screen, by choosing which colums in which order are to be shown. Now I want to give my users the possibility to export these tables to PDF. The tables should fill the page width completely and the columns should adjust their size depending on the content in the table, like e.g. HTML tables do.
Can you recomment a library or toolchain for this?
I checked Apache FOP, but their fo:tables do not support automatic table layout. Creating a Jasper Report dynamically also doesn't seem to fit, because I have to specify the exact column width there. So, does anyone have an idea how to achive this?
Open Source solutions with commercially friendly licenses like Apache or LGPL preferred.
ANSWER: There are no current tools that allow what I hoped for, so I mark this question as resolved.
iText is probably what you are looking for http://itextpdf.com/. Version 2.1.7 is free to use under the GPL lisence, for more info see this question What is latest version of itext that is not AGPL?. It will work for you need, I would recommend using their code samples on their web page. Most are applicable to version 2.1.7 although it is currently on version 5.
I would recommend you take a look at Flying Saucer. It is an open source project that uses iText PDF as its core rendering engine but it allows you to define very dynamic xhtml files as your rendering medium.
Benefits of using FS+iText using iText by itself
Allows for a much faster dev cycle for changes or new products
Very easy to add in consistent and complex styles using a language built exactly for it (HTML + CSS)
You can use the same HTML code to render your PDF as you use to view it online (if using web application)
Can render graphics using java.awt.Graphics class onto the PDF, meaning you can integrate any graphics library with FS to paint objects like graphs onto your PDF.
Downsides:
While it does a good job at rendering modern css styles it is not perfect. For instance when I used it the project required the border-radius style to be usable. It wasnt so I had to implement it.
Rendering times and memory consumption are increased (Although I have found it to be quite fast and memory efficient)
More libraires in your project.
Heres an example from the FS website if your ineterested.
https://github.com/flyingsaucerproject/flyingsaucer/blob/master/flying-saucer-examples/src/main/java/PDFRender.java

API or itext and PDFBox

How do i use an existing PDF and fill out the information given by the user online or in a java program. I know itext and pdfbox are used but they are all showing documentation to create a new pdf and then fill out the information. My problem is that I need to take an existing PDF and fill out the information there which will be collected online by the user. So for example, creating a online Tax softwrare and filling out that information to PDF in Backend?? Please help or guide me to the right direction, thank you
Please take a look at the reporting examples. They involve an existing PDF: state.pdf that can be filled out in different ways. One could fill out the PDF and submit it, as is done in the example from my book: subscribe.pdf. Unfortunately, a number of PDF viewers (such as Chrome PDF viewer) don't support this. You can also fill out an HTML form and use the data to fill out the PDF. See for instance the iText samples I prepared for a tutorial video. You can pre-fill a form or flatten it.
The standalone examples can be found on itextpdf.com; the web app examples are available on github.
Some additional remarks:
The examples explain how to work with AcroForm technology. They don't discuss XFA.
If you intend to create a commercial product, please understand that you may need to purchase a license for your use of iText.
Tax authorities of different countries (including the IRS in the US) are a customer of iText Software, using iText in the exact way you're describing.

Interactive charts in PDF

I want to generate interactive charts in PDF just like Google charts
but this is for embedding on web page I want to embed interactive chart in PDF. any help?
You specified Java, so I would say iText has some partial support for writing adobe-javascript actions. You must be aware that latest versions of itext uses AGPL license, so you must pay a commercial license if you want to use this in a commercial closed-source application.
Another option is to use Adobe Acrobat SDK, but I am not sure if you will be able to use it from Java.
You may also find this link useful: Acrobat JavaScript Scripting Guide - Adobe
This feature of the PDF specification (I mean embedded javascript) is not commonly used, so it might be a bit difficult to find start-up information and sample code.
Here you will find a few examples of interactive PDFs that use javascript, there is even an example of a flying helicopter in 3D, (it actually moves around while viewing the file).

Generating DOC (and DOCX) templates using Python or Java with absolute positioned boxes

For a web-to-print we need to generate a .doc (Microsoft Word 2003+) compatible templates/documents where we need to position some data inside the document (basically we need to auto-generated letter heads for address, phone, contact information etc.).
Which Python or Java based solutions can be used here that providing support for absolute positioning of text boxes in .doc (perhaps even through .DOCX).
We tried: XFC (FO-based which does not support absolute positioning) and tried Aspose Words for Java (also no support for absolute positioning).
Money does not play a major role. The solution has to work and it must not be open-source.
Any more options?
Anything you can do with word, you can do with the word com object.
Install PythonWin.
Use the object browser under "Tools->COM browser" to find what you need.
You could try Docmosis since it works from a template. You would do something like absolute-position your text box in the template and use Docmosis to put populate the text box. You could probably lay out the entire page as a table grid as another approach - it will likely on the specifics of the layout of the other components as well.
OpenOffice.org's Universal Network Objects (UNO), allow you to generate .doc,.PDF, as well as OpenOffice documents. It supports several programming languages like: Java, C++, Visual Basic, etcc..
Some good things is that: its free, open source and plataform-independent
You can build documents, spreadsheets, presentations, etc.
The library allow you to create graph, charts and start from scratch or using a template and fill the gaps..
In order to use it you will need to include some libraries that comes with the OpenOffice suite.
Useful links:
Open Office home
Open Office UNO Developer's Guide

Categories

Resources