Hello,
I'm trying to insert a new page to an existing pdf file at the index 1, but i'm getting an white empty page with 0 width and 0 height. If i try to insert the page to any different index it works fine.
I'm using the aspose.pdf 8.5
Below is the code i'm using :
public MemoryStream InsertPages(MemoryStream inputFile, int index, MemoryStream pageStream) { MemoryStream retVal = new MemoryStream(); if (inputFile != null) { Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(inputFile); Page newPage = pdfDocument.Pages.Insert(index); PageCollection pageCollection = pdfDocument.Pages; double pdfPageWith, pdfPageHeight; double lly, llx, urx, ury; if (pageCollection.Count != 0) { pdfPageWith = newPage.Rect.Width; pdfPageHeight = newPage.Rect.Height; lly = newPage.Rect.LLY; llx = newPage.Rect.LLX; ury = newPage.Rect.URY; urx = newPage.Rect.URX; newPage.SetPageSize(pdfPageWith, pdfPageHeight); Aspose.Pdf.Facades.PdfFileMend fileMend = new Aspose.Pdf.Facades.PdfFileMend(pdfDocument); using (pageStream) { float pdfPageHeightLLY = (float)lly; float pdfPageWidthLLX = (float)llx; float pdfPageHeightURY = (float)ury; float pdfPageWidthURX = (float)urx; if (pageStream != null) { fileMend.AddImage(pageStream, index, pdfPageWidthLLX, pdfPageHeightLLY, pdfPageWidthURX, pdfPageHeightURY); } } pdfDocument.Save(retVal); fileMend.Close(); } return retVal; }
Am I missing something ?
Regards,