0

For my personal project, I am utilizing the SelectPdf library. My goal is to duplicate a page from an existing PDF document, add text to these replicated pages, and subsequently save them to a new PdfDoc. Despite hours of searching, I have been unable to find a solution to this problem. Currently, my workaround involves creating multiple PdfDocument objects from the original file and then extracting the first page from it, which I do not believe is the most appropriate solution.

PdfPage newPage = (new SelectPdf.PdfDocument(pdfFilePath)).Pages[0];

To accomplish this task, I require a cloning method. For instance, it would be ideal if I could utilize the following code to generate a copy of the new page: "PdfPage aCopy = newPage.Clone()". Unfortunately, such a method does not exist.

Is there a more effective approach to achieving my objective?

Louis Tran
  • 1,154
  • 1
  • 26
  • 46

1 Answers1

1

The approach you have done is the way to achieve the copy in selectpdf

If you want to get the specific page in the existing pdf and you want to create it as a new pdf, then you can use the split approach.

https://selectpdf.com/docs/PdfSplit.htm

Or you can have a look at Modifying existing pdf. If this used, you must ensure that the copy of the pdf is backed up since it overwrites the existing one.

https://selectpdf.com/docs/ModifyExistingPdf.htm

K J
  • 8,045
  • 3
  • 14
  • 36