Hi,
I’m trying to insert a page from one pdf at a specific position in a page from another pdf but i’m not able to find any useful classes/methods.
Maybe i’m missing something and i was wondering if you can help me with code example ,documentation or some hints for this problem, thanks.
I am using Aspose.PDF for C++ but i think C# examples would also pe helpfull.
Thank you for contacting support.
Each PDF document contains pages where you may manipulate page collection with Add
and Insert
methods. Below sample code inserts first two pages of source document as first two pages of destination document, as the index where page should be inserted is managed with Integer
value of page.Number
property. Moreover, you may also visit Aspose::Pdf::PageCollection Class for your kind reference.
Document SourceDocument = new Document(dataDir + "Source.pdf");
Document DestinationDocument = new Document(dataDir + "Destination.pdf");
int[] pages = { 1, 2 };
foreach (Page page in SourceDocument.Pages)
{
foreach (int match in pages)
{
if (page.Number == match)
{
DestinationDocument.Pages.Insert(page.Number,page);
}
}
}
DestinationDocument.Save(dataDir + "NewPages_19.11.pdf");
We hope this will be helpful. Please feel free to contact us if you need any further assistance.
@Farhan.Raza
Thanks for your reply, but i was wondering if there is any way to insert the page as a image at a specific position and with specific dimensions as content inside the other’s pdf page, but also to maintain the original resolution.
You would need to Convert PDF Pages to images and later Add Image Stamp in a PDF File at any position with specific dimensions.
Please feel free to contact us if you need any further assistance.