Welcome Guest Search | Active Topics | Sign In | Register

add page to pdfdocument Options
henkjelt
Posted: Monday, October 31, 2011 5:41:42 PM
Rank: Member
Groups: Member

Joined: 8/8/2011
Posts: 16
Hi
I am a relative newbie to EO, working in VB.Net.

I have a question.

I have created a document of one page, and would like to add a new page with the same header / footer.
How do I do this?

My code is:


'Create an empty PDF document
Dim doc As PdfDocument = New PdfDocument

'Set the document title
doc.Info.Title = id

Dim pageLayout As New AcmPageLayout(New AcmPadding(0.3F))

'Use it to create an AcmRender object
Dim render As New AcmRender(doc, pageLayout)
render.SetDefPageSize(New System.Drawing.SizeF(getconfig.Rows(0)("pagew").ToString, getconfig.Rows(0)("pageh").ToString))

'Handle the render's BeforeRenderPage event (creating the header and footer)
AddHandler render.BeforeRenderPage, New AcmPageEventHandler(AddressOf BeforeRenderPage)

... generating a table ...

render.Render(table)

.... I assume this is where something like doc.pages.add() will come, but I cannot figure out how....


doc.Save(Server.MapPath("documents/invoices/" & getcustdet.Rows(0)("iInvoicenbr") & ".pdf"))



Is anybody willing to help me out?

KR

Henk Jelt Hoving





eo_support
Posted: Monday, October 31, 2011 6:11:53 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

See here for the sample code:

http://doc.essentialobjects.com/library/4/acm/advanced%20formatting/page_header.aspx

Please let us know if you have any questions.

Thanks!
henkjelt
Posted: Tuesday, November 1, 2011 11:35:29 AM
Rank: Member
Groups: Member

Joined: 8/8/2011
Posts: 16
Hi

This is not the solution to my question. It is a short introduction to implementing a header and a footer on a page.
The question I have is how I can add a second page to a document I have created.

The main thing is that I have a table with several rows, all with a fixed height.
Above the table I have implemented a header, and below the table I have implemented a footer.

Now I want to add another page to the document, with the same header and footer, but with a table with different information.

The shortcut I have found, is to create tow documents, merging them afterwards into one, but this is not an elegant solution.
Question is: which is the appropriate solution?

KR

Henk Jelt
eo_support
Posted: Tuesday, November 1, 2011 11:48:51 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
I see. Usually you do not need to worry about adding new pages at all. New pages are automatically add when your contents is more than one page. For example, if your content needs 100 lines and one page only fits 60 lines, then the rest 40 lines will automatically flow to the second page.

If you wish to force a page break before the first page is full, you can add an AcmPageBreak object into your content tree. You can take a look of the source code for "All Demos -> PDF Creator -> Interactive Features -> Link" sample in the EOPdfDemo project to see how it works. That sample is meant to demonstrate how to create links, however it also shows you how to add page breaks because the link is on the first page and the link target is on the second page.

If you have complex tables, it will be much easier for you to use the HTML to PDF feature instead of PDF Creator feature. If you use HTML to PDF, you can use CSS style to control paging:

http://doc.essentialobjects.com/library/4/htmltopdf/paging.aspx

Creating separate documents and then merging them is also a solution. It works for both PDF Creator and HTML to PDF and it's actually quite efficient.

Hope this helps.

Thanks!
henkjelt
Posted: Tuesday, November 1, 2011 12:00:02 PM
Rank: Member
Groups: Member

Joined: 8/8/2011
Posts: 16
Thanks for the quick reply.
I will take a look at the example, because I really need to add a page before the first page is full.
I am creating invoices, with a cover page and detailed attachments.

A question relating to "For example, if your content needs 100 lines and one page only fits 60 lines, then the rest 40 lines will automatically flow to the second page.".

I have this first page, with a header and a footer, and a table in between.
I indeed run into the situation that I have more lines than available.

What happens is that the table is rendered to the page and onto the next page, but it is covering the footer of the first page and the header of the second page.

How can I tell the table to stop just above the footer, and to continue on the next page just below the header?
eo_support
Posted: Tuesday, November 1, 2011 12:10:20 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

The key for "header" and "footer" is they are usually setup to occupy a different region than the main content. For example, if your page is 11 inch high, then you can setup it up so that your "header area" is from 0.5 inch to 1 inch, your content is from 1 inch to 10 inch and your footer area is from 10.5 to 11 inch. if you use PDF Creator interface, this means:

1. You would set up your AcmPageLayout object such it only renders from 0.5 inch to 1 inch (That means a 0.5 inch top margin and a 10 inch bottom margin) while rendering header;
2. You would set up your AcmPageLayout object such it only renders from 1 inch to 10 inch (That means 1 inch top margin and 1 inch bottom margin, this is actually the default value) while rendering your main tables;
2. You would set up your AcmPageLayout object such it only renders from 10.5 inch to 11 inch (That means 10.5 inch top margin and 0 inch bottom margin) while rendering your footer;

This way the table will just run from 1 to 10 inch and will never run into the footers. Let us know if this makes sense to you.

Thanks!
henkjelt
Posted: Tuesday, November 1, 2011 12:39:48 PM
Rank: Member
Groups: Member

Joined: 8/8/2011
Posts: 16
Hi

the pagelayout option worked for the overflow.
Thanx!
henkjelt
Posted: Tuesday, November 1, 2011 12:55:23 PM
Rank: Member
Groups: Member

Joined: 8/8/2011
Posts: 16
I also managed to implement the acmpagebreak, so I have made some progress today!

thx!
eo_support
Posted: Tuesday, November 1, 2011 1:04:25 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Great. Glad that it's working for you.
henkjelt
Posted: Tuesday, November 1, 2011 4:44:08 PM
Rank: Member
Groups: Member

Joined: 8/8/2011
Posts: 16
Hi

i thought it worked, but not.

I create a table for the main page, and render the table (without pagebreak).
Then I dynamically determine how many attachments I need, and loop through them:

"
render.Render(table)

Dim getcats = d.MyConn3("SELECT ----")
If getcats.Rows.Count > 0 Then

For Each cat In getcats.Rows
Dim atttable As New AcmTable(2.5F, 2.5F, 2.5F)
atttable.CellPadding = 0.05F
atttable.Style.Left = 0.2

invdata = getinvoicedataforcat(cat("cBusinessGroup"), id) / getting the invoice data

Dim rowatt = New AcmTableRow()
'create invoicedetails subtable
Dim tablecellatt As New AcmTable(4.0F, 0.75F, 1.0F, 0.75F, 1.0F)

-----------------------------------------
filling tablecellatt with the invoice data
-----------------------------------------

cell7 = New AcmTableCell(tablecellatt)
cell7.ColSpan = 3
rowatt.Cells.Add(cell7)
rowatt.Style.Height = getconfig.Rows(0)("invh").ToString
atttable.Rows.Add(rowatt)

render.Render(atttable, New AcmPageBreak())
Next
End If
"

The effect is that the first render generates a pagebreak (the attachments start on a new page).
However, I want each cat to be rendered on a new page, so I create a pagebreak after processing each cat.
But this does not happen: it renders all cats on the same page.

What is wrong here?
Is it not ok to use the tablename 'atttable' for all cats?
Or should I use different table names?

KR

Henk Jelt
eo_support
Posted: Tuesday, November 1, 2011 5:26:38 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

That's very normal. Render always starts from the same position (the top of the first page if you call new AcmRender(doc, ....), or the specific position if you call new AcmRender(page, position, ...). The second Render call does not generate output following the first Render. If you wish to do so, create a new Render object and explicitly pass the page where you wish to start to the AcmRender object, or create all th tables (along with all the AcmPageBreaks in between then) and then call Render once to generate all the output.

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.