The code below works fine when I use a new page but when I use an imported page i get an invalid page number error on the last line of code. I am trying to use an existing page as a template then add new elements. Any help please this one is doing my nut.
PDFDocument = New Document
PDFDocument.Sections.Begin()
'Loop each page building the pdf file
For Each Page
Dim PDFPage As Page = New ImportedPage(TemplateLocation, 1)
' Create a Page and add it to the document
PDFPage.Dimensions.Width = 750
PDFPage.Dimensions.SetMargins(35, 10, 35, 0)
PDFDocument.Pages.Add(PDFPage)
'Add each element
For Each Element
PDFPage.Elements.Add(New Label(ElementName, Element.Xcord, Element.YCord, _
Element.Width, Element.Height, Font.Helvetica, Element.FontSize))
Next
'Reset page
PDFPage = Nothing
Next
PDFDocument.Draw(PDFNAME.pdf")
Invalid page number
Re: Invalid page number
Support · May 2, 2007Hello,
Can you please make sure that you are using the latest build DLL files and see if it solves the problem or not.
Do you get an error when trying to add elements to an existing PDF template? If yes, can you please send over the PDF template and the code you are using to our [^a|mailto:support@cete.com|Support Team^] and they can take a look at it?
Thanks,
ceTe Software Support Team
Re: Invalid page number
Forum member · Dec 4, 2008I am having the same issue when using the following code:
*Note: m_PDF is a MergeDocument object.
[CODE]
PdfDocument template = new PdfDocument(m_DocumentPath);
foreach (DataRow row in m_DataTable.Rows)
{
ImportedPage page = new ImportedPage(template.Pages[0]);
// Add elements to page
Label lblDate = new Label(DateTime.Now.ToString("MM/dd/yyyy"), 90, 134, 300, 20, FontFamily.Times.Regular, 12);
page.Elements.Add(lblDate);
// Add page to merge document
m_PDF.Pages.Add(page);
// Nullify page
page = null;
}
I am using the following build: 5.0.1.20 (Build 10926)
Thanks!
Matt
Re: Invalid page number
Support · Dec 4, 2008Hello Matt,
Can you please make sure that you are using the latest build DLL files and see if it solves the problem or not?
If the problem continues to occur using the latest DLL files, please send over the PDF template you are using to our [^a|mailto:support@cete.com|Support Team^] and they can take a look at it?
Thanks,
ceTe Software Support Team
Re: Invalid page number
Forum member · Dec 4, 2008I believe I just found the problem. I had a tiny checkbox (form field) in my document template. When I removed that the error went away.
Thanks!
Matt