AbcPDF renders the same page multiple times
Posted
by Steven
on Stack Overflow
See other posts from Stack Overflow
or by Steven
Published on 2010-05-06T13:34:44Z
Indexed on
2010/05/06
13:38 UTC
Read the original article
Hit count: 739
I need to retrieve several pages and output this in a PDF document.
I have the following page structure:
Page 1
Sub 1
Sub 2
Sub 3
On page one, I have a link which executes the below code. What it does, is to retrieve child pages (one level) and put them in a page collection. Then I loop trough the page collection and retrieve each sub pages URL. This works. I've tested and seen that it retrieves 3 different URL's.
The problem is that my PDF gets three pages of Page 1. It does not render Sub 1 to 3.
Why isn't docID = document.AddImageUrl(pageLink)
retrieving the pages?
Websupergoo refers to a caching problem which may occur. But their solution did not help me.
Any good suggestions anyone?
protected void linkBtnCreateMultipagePDF_Click(object sender, EventArgs e)
{
string baseURL = Request.Url.ToString();
PageDataCollection pdc = GetChildren(CurrentPageLink);
//Create PDF document
Doc document = new Doc();
document.Rect.Inset(10, 20);
int docID;
string pageLink = string.Empty;
foreach (PageData pd in pdc)
{
//This lops goes through the different pages and retrieves that pages URL
pageLink = baseURL + pd.LinkURL;
document.Page = document.AddPage();
// But for some reason, the same page is added here.
docID = document.AddImageUrl(pageLink);
//Chain pages together
while (true)
{
if (!document.Chainable(docID))
break;
document.Page = document.AddPage();
docID = document.AddImageToChain(docID);
}
}
//Flatten file
for (int i = 1; i <= document.PageCount; i++)
{
document.PageNumber = i;
document.Flatten();
}
byte[] theData = document.GetData();
Response.Clear();
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "inline; filename=MyPDF.PDF");
Response.AddHeader("content-length", theData.Length.ToString());
Response.BinaryWrite(theData);
Response.End();
}
© Stack Overflow or respective owner