I am trying your demo and seem to get the text over writing itself.
How do I add multiple pages or clear out the existing page object? This would seem straight forward but I seem to be missing something.
Thank you.
Art
--------------------------
using (StreamReader sr = new StreamReader(strIn))
{
String line;
int yPoint = 0,nCount = 0;
ceTe.DynamicPDF.Page page = new ceTe.DynamicPDF.Page();
// Read and display lines from the file until the end of
// the file is reached.
while ((line = sr.ReadLine()) != null)
{
Label label = new Label(line, 0, yPoint, 570, 400, Font.Courier, 8, TextAlign.Left);
page.Elements.Add(label);
yPoint += 12;
nCount++;
if (nCount >= 58) // put n lines per page.
{
yPoint = 0;
nCount = 0;
document.Pages.Add(page);
}
}
document.Pages.Add(page);
}
}
adding pages
Re: adding pages
Support · Mar 17, 2008Actually, your code reveals that you are not re-instantiating your Page variable through each iteration of your while loop and that is why you are seeing the Label overwriting itself on every page. I think you want to instantiate a new Page object each time through you loop so that each page is unique. Right now your final document is just a collection of carbon copied pages.
To resolve this, add a line that instantiates the page variable again once your logic determines that is necessary. Adding the following line after the page is added to the document inside your for loop may resolve the issue for you:
if (nCount >= 58) // put n lines per page.
{
yPoint = 0;
nCount = 0;
document.Pages.Add(page);
//Insert this line...
page = new ceTe.DynamicPDF.Page();
}
Let us know if you have further questions.
Thanks,
ceTe Software Support Team
Re: adding pages
Forum member · Mar 17, 2008thanks - does the document.draw() commit everything to disk or can you commit pages as you add them? Otherwise it would seem that you could have a large number of Pages allocated (based on document size) eating up memory, just getting larger and larger, till your done.
also, can pages be numbered?
thanks again,
art
Re: adding pages
Support · Mar 18, 2008Hello,
The Draw method will write the PDF to the disk at a time. It is not possible to write the pages to disk separetely. It will write whole PDF at a time after creating the PDF.
The size of the PDF will depend on the contents and data you are adding to the PDF. If you are adding same image repeatedly to the PDF then you can use the ImageData class. You can refer to the Performace Considerations
topic on our help documentation.
You can add page numbers to the PDF using the PageNumberingLabel
page element.
Thanks,
ceTe Software Support Team.