Blank PDF

Hi, I’m trying to create PDF documents using Aspose.Pdf (C#/.NET), Version=19.5.0.0.
There’s an intermittent problem where sometimes the PDF generated is blank.

I’ve tried viewing the PDF in Notepad++ and can’t seem to find a pattern.

Here is what the blank pdf looks like in Adobe Acrobat Reader DC for both examples below:
image.png (19.0 KB)

Example 1:
In this example, the blank pdf is 420KB, 2 pages long, and the non-blank pdf is 424KB and 2 pages long.
Here is a file comparison:
The blank PDF is on the left and the equivalent non-blank pdf is on the right.
image.png (8.6 KB)
image.png (11.3 KB)
image.png (7.8 KB)
image.png (126.4 KB)
image.png (135.7 KB)
image.png (66.8 KB)
image.png (21.1 KB)
image.png (20.9 KB)

To fix the blank pdf, all I had to do was add “trailer” on the line above the line that has “trailer” already there:
image.png (3.1 KB)

Example 2:
In this example, the blank pdf is 424KB, 2 pages long, and the non-blank pdf is 400KB and 2 pages long.
Here is a file comparison:
The blank PDF is on the left and the equivalent non-blank pdf is on the right.
image.png (24.5 KB)
image.png (54.2 KB)
image.png (25.9 KB)
image.png (21.9 KB)
image.png (107.8 KB)
image.png (19.7 KB)
image.png (58.0 KB)
image.png (26.4 KB)
image.png (5.3 KB)
In this example, I removed lines 3322 to 3563 and it fixed the blank pdf.

Why does a blank PDF get generated intermittently?

If there is no fix for this, is there a way to determine whether or not the pdf is blank from analysing the binary programmatically?

@David.Klempfner

Thank you for contacting support.

Would you please share sample PDF documents along with SSCCE code so that we may try to reproduce and investigate it in our environment. Before sharing requested data, please ensure using Aspose.PDF for .NET 19.7.

Moreover, you may iterate through each page of PDF document and check if its a blank page with below code:

Document pdfDocument = new Document(inputFileName);
bool isBlank = pdfDocument.Pages[1].IsBlank(0.01d);