Multipage form using itext with Acrofield and Dynamic table - pdf

I'm new at working with itext and I'm looking for help.
I'm creating a PDF document based on a PDF template which contains a form with acrofields. This form is composed by some fields on top page and a table and has only one page.
The PDF document generated will have one or more pages depending on table's size (if size content extends predefined size, table should continue in the second page). Also every page should display fields on the top with the same information.
I've tried to solve it following "AddExtraTable" example, but I didn't get to keep the fields on top in all pages, only in the first one.
I've tried also to solve it with PdfCopy. This approach displays the fields on top in all pages but table content is not properly displayed.
Can someone help me?
PS: I have to use itext 2.1.7 because of project requirements.

Related

PDFBox using to creating pdf's in HTML form

i've got another question about the PDFBox. Is it possible to creating new pdf's templates on our webpage and saving it?
Well something like - I want to create PDF document with specific fields as administrator on web page. I have fields which I want to fill by my restrictions and when I saving it i want to "LOCK" fields which i filled.
I hope it's clear.

Creating dynamic PDF internal links with BIRT

I am trying to create a PDF in BIRT and I need to have bookmarks linking from a summary page to each detail page. The links work fine in the HTML preview and a similar http link works in published PDFs. However, the internal links do not work in the PDF format.
What I have tried so far is setting the bookmark property to "detail_" + row["nodeid"] and setting the hyperlink to the same. As stated, this works for the HTML preview, but not the PDF export.
The PDF has automatically generated TOC items that I would prefer to leverage off, but I don't know how to link to those.
Is there a way that I can get the PDF output to contain the required links using either bookmark properties, or the generated TOC items?
Sample PDF output (Customer data removed, alternate locations selected)
The solution to the problem lies not in the format of the bookmark/hyperlink, but in the placement of the bookmark.
The problem was, I was placing the bookmark on the row of the table I wanted to link to. Instead, the bookmark needed to be on the label in the first column of the row.
I believe the issue is that, in the HTML version, the table row is a <tr> tag, however in the PDF, the row doesn't physically exist, so there's nothing to set the bookmark on. However the label/text item exists in both versions, so the bookmark is created correctly.

Adding a pdf footer conditionally on certain pages in a multi-page pdf document

I have one web application which generates pdfs for each request.The data would be different in these pdfs based on user information.The number of pages can vary from 6 to 9.To construct the pdfs,i have multiple PdfPTables and each table has its own cells.Once i construct all the PdfPTables,as a final step i am adding the tables to the document.
Recently i have a requirement as,when ever there is a particular text then we need to add the footer to indicate the occurrence of this text in the respective pages.This can in 3 page or this can be 6 page or in both.I was thinking to figure out a way for this.
One of the approach i have is to identify this text at the time of adding to the PdfPCell and then generate a footer.But at this stage i dont have an idea as which page this would be in the document.I am letting the table to grow to the next page if it doesn't fit to the current page.
Another approach is to parse the entire pdf before sending the response back.Take one by one page,get the text and compare against the search text and if exists add a footer.Some how i feel this is a costly operation.
Please let me know if any of you have any suggestion to this.
Any help would be highly appreciated.
Thanks,

ssrs report viewer vs exported pdf page count

The number of pages displayed when viewed in ReportViewer and in exported PDF are differing.
Eg: 50 records are shown in one single page of Report Viewer. But when Exported to PDF 45 reords come in page 1 and the remaining come in page 2.
Soution Tried:
1)Removed Top and Bottom Margins.
2)Reduced "Interactive Page Size" to match the page count.
But it is not consistent, as it is behaving differently with different number of records.
Can anyone tell me how should I proceed to achieve sync between the ReportViewer and exported PDF ?
Thanks
Short answer - you can't do what you are trying to do: the different renderers handle pagination differently, but appropriately for their output.
The HTML renderer is optimised for screen-based reading and generally allows more content per page than the print renderer does as the print renderer is constrained by the paper size that it formats to. Thus the HTML renderer allows more content on fewer pages for a better browser experience whereas the print and PDF renderers have to conform strictly to the page length.
The best illustration of this is the Excel renderer - the Excel renderer renders the entire report onto a single worksheet in most cases (for reports with grouping and page breaks set on the group footer it will render each group on its own worksheet). You wouldn't want the Excel renderer to artificially create worksheets to try to "paginate" your report or to put it all in one worksheet but insert the header into the spreadsheet rows every "page". It does the appropriate thing which is to include all the data in one big worksheet even though that may be logically thought of as one big "page".
The HTML renderer page length is determined (more accurately, influenced) by the InteractiveHeight attribute of the report (in the InteractiveSize property in the Properties pane for the report). However, the interactive height is an approximation rather than a fixed page break setting and your page breaks may still not conform to the print version even if you set InteractiveHeight to the same length as your target page length. This is because the HTML renderer will vary the page length to group the data together better so the interactive page breaks happen around about, but not always exactly, where the interactive height is set.
This is what is happening in your scenario where the report viewer shows 50 records on one page but the PDF has 45 on the first page and 5 on the second page. The report viewer is making the decision that since there are only a few records left to display it will just include them all on the one page rather than force the user to scroll even though the interactive height will be exceeded. Thus you get a better user experience but a variance in pages between renderers. The important thing about the report is the data and the experience with working with that data in that renderer, not that the pages are the same length no matter how you look at it.
See this discussion of rendering behaviour for more information on why what you are trying to achieve isn't achievable. Just educate your users that the browser pagination is optimised for their viewing pleasure.

How to fill tables in PDF forms with iTextSharp?

all
I must fill this PDF form using iTextSharp.
I have no problems with the header fields, but I don't know how to fill the table in the bottom. I can fill its first row with PdfStamper.AcroFields.SetField(), but how can I add more rows, if it is at all possible?
Your form is a form based on AcroForm technology. This means that the form is static. Every field in the form corresponds with a widget annotation for which an absolute position is defined on the page. You can not add any data on coordinates that are not predefined, hence you can not "add more rows". What you are asking for is impossible.
Take a look under the hood of your PDF:
There's an array of /Fields and each field is defined by a dictionary that combines field entries and the entries of a single widget annotation. Each widget annotation has its fixed coordinates on the page.
It seems that you were looking for a dynamic form solution. In that case, you need a form based on the XML Forms Architecture (XFA). Your form is not an XFA form.
If you are in doubt about the difference between AcroForm and XFA technology, please download this free ebook: The Best iText Questions on StackOverflow. In this book you'll find the answer to several questions such as:
What is the difference between iText, JasperReports and Adobe LC?
Generate and design PDF with iTextSharp or similar
How can I flatten a XFA PDF Form using iTextSharp?
...
These and other answers will give you an idea of some alternative options.