Implementing table background (embedded in stream content vs. external XObject (Form XObject)

View: New views
2 Messages — Rating Filter:   Alert me  

Implementing table background (embedded in stream content vs. external XObject (Form XObject)

by Martin Weiss :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all iText cracks,
may I ask for your advice ? I am implementing a pdf for a statement of account and using the the PdfPTable class. The table has a fix length (50 rows per page). The number of columns is variable (5 to 7) depending on the job parameters. Each odd table body row should be gray underlayed ("table background") including gray empty rows until the end of the table respectively the end of the page is reached. I have two solution for this and appreciate your feedback. Maybe you have a better approach.

My first solution ("table background" embedded in stream content)
I apply the PdfPCell.setGrayFill() method for the "table background". For each empty rows at the end of the table I add a single cell with an appropriate colspan (e.g 5 if the table has five rows). Each PdfPCell has a fix height.
Rationale for this solution: minor overhead (pdf size, CPU cycles for pdf preparation) for the "table background" (pdf syntax for the setGrayFill method, empty rows only on the last page of the statement of account)

My second solution ("table background" in an external XObject (Form XObject))
Create the "table background" as a PdfTemplate. Create the template from a PdfPTable, for each empty row add a single PdfPCell with appropriate colspan, apply the setGrayFill() method for odd rows. Use the PdfStamper to add the template ("table background") as underContent. Rationale: seems to be an enhanced solution, however I am ensure whether this implementation is not an overkill (usage of a stamper).

Your recommendation is very welcome.

Thanks a log and kind regards
Martin

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
iText-questions mailing list
iText-questions@...
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Re: Implementing table background (embedded in stream content vs. external XObject (Form XObject)

by 1T3XT info :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

martin.weiss@... wrote:
> Hi all iText cracks,
> may I ask for your advice ? I am implementing a pdf for a statement of account and using the the PdfPTable class. The table has a fix length (50 rows per page). The number of columns is variable (5 to 7) depending on the job parameters. Each odd table body row should be gray underlayed ("table background") including gray empty rows until the end of the table respectively the end of the page is reached. I have two solution for this and appreciate your feedback. Maybe you have a better approach.
>
> My first solution ("table background" embedded in stream content)
> I apply the PdfPCell.setGrayFill() method for the "table background". For each empty rows at the end of the table I add a single cell with an appropriate colspan (e.g 5 if the table has five rows). Each PdfPCell has a fix height.
> Rationale for this solution: minor overhead (pdf size, CPU cycles for pdf preparation) for the "table background" (pdf syntax for the setGrayFill method, empty rows only on the last page of the statement of account)

I use this solution: http://1t3xt.be/?X0001a5
In other words: I don't set the gray fill (or in my case color) of the
cells, I add the background in a table event.

> My second solution ("table background" in an external XObject (Form XObject))
> Create the "table background" as a PdfTemplate. Create the template from a PdfPTable, for each empty row add a single PdfPCell with appropriate colspan, apply the setGrayFill() method for odd rows. Use the PdfStamper to add the template ("table background") as underContent. Rationale: seems to be an enhanced solution, however I am ensure whether this implementation is not an overkill (usage of a stamper).

So it's as if you're creating stationary, and you're adding that
stationery in a second pass. There's no need for that, you can add the
stationery in the first page using page events.
See http://1t3xt.be/?X000120
--
This answer is provided by 1T3XT BVBA
http://www.1t3xt.com/ - http://www.1t3xt.info

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
iText-questions mailing list
iText-questions@...
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/