Hi,
I'm trying to add a pdffile(contains 1 page) with the other PDF(contains 1 page) using .net Aspose.PDF v4.0
//Calling Insert method
pdfEditor.insert(inFile, location, portFile, pages,startpage,endpage, outFile);
ie
//Calling Insert method
pdfEditor.Insert(inFile, 1, portFile, pages,1,1, inFile);
Note:I have give the infile and outfile are same.ie. I want to append the page in the same file and I dont want to create a new file.
Also If I have 7 pages in source file and I try to add the new file at the location getting the same exception.If I give 6 the new page inserted before the last page. But I want to add at the end(as 8th Page)
Kindly let me know how to resolve this issue.
Hi Ponraj,
Thanks for contacting support.
In order to add the pages of PDF document into itself, I would recommend you to try using Document Object Model approach. Please try using the following code snippet to add the pages of document to itself.
[C#]
//open document<o:p></o:p>
Document pdfDocument = new Document(@"input.pdf");
//get particular page
Page pdfPage = pdfDocument.Pages[1];
//create a temporary document object
Document newDocument = new Document();
// get the first page of original
document loaded
newDocument.Pages.Add(pdfPage);
// add the pages of temporary document to the pages collection of original input file
pdfDocument.Pages.Add(newDocument.Pages);
// save the original PDF file
pdfDocument.Save(@“input.pdf”);
In case you need to add the pages at the end of document, please try using Insert(…) method in which you can specify the location where page needs to be added.
pdfDocument.Pages.Insert(pdfDocument.Pages.Count, newDocument.Pages);
Hi,
Thanks for your updates. While using insert method only I got the exception..
Kindly read my mail once again and provide me the working code snippet.
Thanks!
Hi Ponraj,
Sorry for the inconvenience faced. While testing your scenario with insert method of PdfFileEditor class using latest version of Aspose.Pdf dll i.e. 7.9.0, I’m unable to notice the issue. Please download and try latest dll of Aspose.Pdf. Hopefully your issue will be resolved. If issue persist then please share your sample document here. So we will test it further and provide you more information accordingly.
Please feel free to contact us for any further assistance.
Best Regards,