|
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
|
|
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.aspxPlease let us know if you have any questions. Thanks!
|
|
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
|
|
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.aspxCreating 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!
|
|
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?
|
|
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!
|
|
Rank: Member Groups: Member
Joined: 8/8/2011 Posts: 16
|
Hi
the pagelayout option worked for the overflow. Thanx!
|
|
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!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Great. Glad that it's working for you.
|
|
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
|
|
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
|
|