I have an application responsible for taking a DOCX and converting it to PDF. In some use cases, users are opening the PDF in Adobe Acrobat and then resaving it as a PDF. When the resaved version of the PDF is opened, only the first page will render, while other pages are blank. This typically happens on longer documents (around 8 pages seems to trigger it) as well as sometimes documents with embedded images.
I have tried using Word to save the original DOCX as a PDF, and repeating the same “Save As” behavior in Adobe Acrobat and it does not repeat the erroneous behavior. This is only occurring on documents converted via Aspose Words.
I have attached an example, a DOCX with 150 pages of Lorem Ipsum text, a PDF converted using Aspose Words, and a PDF (dupLoremIpsum.pdf) which was resaved in Adobe Acrobat and doesn’t show any content past the first page.
I am using this code snippet to perform the conversion:
public static byte[] ConvertWordToPdf(byte[] docArray)
{
try
{
MemoryStream pdfStream = new MemoryStream();
pdfStream.Write(docArray, 0, docArray.Length);
Document doc = new Document(pdfStream);
pdfStream.Position = 0;
doc.Save(pdfStream, SaveFormat.Pdf);
pdfStream.Position = 0;
return pdfStream.ToArray();
}
catch
{
return docArray;
}
}
I am running:
- Aspose Words V 16.5.0.0
- Adobe Acrobat Version 2017.009.2004