Skip to content

Navigation Menu

Sign in
Sign up

Duplicate and Cloneing pages from one document to another #299

Unanswered
demi-solemma asked this question in Q&A
Discussion options

Hi,
What is the best way to duplicate several copies of a page from a document to another document (new document contains two copies of the first page of the first document)?
I'm using v6.1.1

I'm trying with
Doc.AddPage((PdfPage)oldDoc.Pages[0].Clone());
but it throws an error: "An item with the same key has already been added"
Doc.AddPage(oldDoc.Pages[0]);
gives the same error (although from the documentation page it sounds like AddPage(page) should create a copy of the page and Clone() shouldn't be necessary. )

perhaps when Doc.AddPage(page) is called the page id or something wasn't updated? how can I update the key?
or maybe I am approaching is completely wrong?

Also would like to ask if it is possible to draw something under the duplicated pages, these will be different on each copies of the page.

Thank you!

You must be logged in to vote

Replies: 1 comment

Comment options

Hi!
Copying pages to other files works generally. There may be something special about the page you try to copy.
I cannot tell, seeing just one line of code.

Pages can be modified after copying them.
Pages can be drawn on other pages along with new content.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
Cannot Reproduce https://xkcd.com/583/

AltStyle によって変換されたページ (->オリジナル) /