hi,
I want to build a container around an existing pdf page, so actually enlarge that document and put it in the middle so that I can write more things into.
What I tried so far :
Code:
// Open the file
PdfDocument inputDocument = PdfReader.Open(filename, PdfDocumentOpenMode.Import);// PdfReader.Open(filename, PdfDocumentOpenMode.Modify);
PdfDocument newContainerDocument = new PdfDocument();
// Create an empty page or load existing
for (int idx = 0; idx < inputDocument.PageCount; idx++)
{
PdfPage page = new PdfPage(); //this should be the actual container
page.Width = tempWidth;
page.Height = tempHeight;
//gfx.DrawImage(image, (page.Width / 2) - (width / 2), (page.Height / 2) - (height / 2), width, height); //put it in the middle of the container, this would only work with IMAGES ... using "XGraphics"
// Add the page and save it
newContainerDocument.AddPage(inputDocument.Pages[idx]);
}
newContainerDocument.Save(String.Format("{0} - Page {1}_expandedFile.pdf", insertName,DateTime.Now.Ticks.ToString()));
inputDocument.Close();
newContainerDocument.Close();
But I get:
Quote:
The document cannot be modified
What is wrong here ?
Thank you