This C# code works... sort of. I simply want to copy selected pages from one PDF to another. The page counts generated are correct, and the new pdf is created. However the content of the pages in pamphlet.pdf are all blank. What did I miss??
private void GeneratePamphlet_Click(object sender, EventArgs e)
{
String sourcePath = SourcePdf.src;
// get ref to original file
File source = new File(sourcePath);
// Create new file
File dest = new File();
// Get Collection of pages from original file
Pages pageCollection = source.Document.Pages;
foreach ( string page in ( savedPageList.Items) ) {
int pageIndex = Convert.ToInt32(page);
Page myPage = pageCollection[pageIndex];
dest.Document.Pages.Add(myPage);
}
// Write out saved pages
dest.Save("pamphlet.pdf", SerializationModeEnum.Standard);
MessageBox.Show ( string.Format("There are {0} pages in the source collection\n and {1} in the destination", pageCollection.Count, dest.Document.Pages.Count));
}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This C# code works... sort of. I simply want to copy selected pages from one PDF to another. The page counts generated are correct, and the new pdf is created. However the content of the pages in pamphlet.pdf are all blank. What did I miss??
When you copy a content from one document to another you have to clone it:
Thank you Stefano. Much appreciated.