Blank Document after calling ResizeContents

Hello, (Edit: We are using Aspose.PDF.DLL version 10.9.0.0, the problem persists with Aspose.PDF version 11.3.0.0.)


We use Aspose to shrink documents slightly to add a custom footer to uniquely identify each page of a PDF document. For most documents we simply call ResizeContents to shrink by 6% and that does the job.


We have a customer with a scanner (Xerox copier?) that generates documents that do not seem to work with Aspose, at least not with ResizeContents. Instead of shrinking the content, the document becomes blank. I can add a footer to the document okay, but the original content appears to have vanished. I attached a file that should become blank when running the example code follows at the end of this post.

This seems to be a bug in Aspose.PDF. If not, are we using ResizeContents incorrectly.

Is there another/better way to accomplish shrinking the contents of pages to leave room for a small footer while leaving the page 8.5"x11"? Or can you suggest fast transformation that would prevent the blank page but preserve actual text/images/etc. that are there for most documents? (I can convert to Word and back to PDF and that fixes the problem, but that takes maybe 5-10 times longer and can lose information. One user has 10,000+ page documents they regularly process and they already are complaining about the speed.)

If it is a bug, can you suggest code to detect there will be a problem? If so I could launch the slow conversion code only for documents that would end up blank otherwise.


Typical documents are much larger and proprietary. Here is a simple one page document that demonstrates the problem. It is not original, I extracted the page with Aspose and it seems to still have the problem (but the info changed), the original info was this:

[“Creator”] “Network ScanGear Ver.2.01”
[“Producer”] “PDFScanLib v1.2.2 in Adobe Acrobat 7.1”
[“ModDate”] “D:20160204084527-07’00’”
[“CreationDate”] “D:20160204084459-07’00’”



We have more steps after this to add the footer, but to generate the “blank” document just do the following (this results in a 6% smaller document with most other files we have tested until this scanner):


Dim testKludgeDir As String = "c:\test"
Dim PDFDocument As Aspose.Pdf.Document = Nothing
Try
'Create PdfFileEditor Object
Dim fileEditor As New PdfFileEditor()
Try
'Open PDF Document
PDFDocument = New Aspose.Pdf.Document(Trim(filePath).ToString())

'Shrink 6%
Dim shrinkPercentage As Integer = 6
Dim shrinkParameters As New PdfFileEditor.ContentsResizeParameters(PdfFileEditor.ContentsResizeValue.Percents(shrinkPercentage),
Nothing,
PdfFileEditor.ContentsResizeValue.Percents(shrinkPercentage),
PdfFileEditor.ContentsResizeValue.Percents(shrinkPercentage),
Nothing,
PdfFileEditor.ContentsResizeValue.Percents(shrinkPercentage))

Dim pageIndexes(PDFDocument.Pages.Count - 1) As Integer
For index As Integer = 0 To PDFDocument.Pages.Count - 1
pageIndexes(index) = index + 1
Next

'Saving the file here will still have a non-blank document

'This line seems to make it blank, I’ve tried a variety of versions of this with different percentages, they all seem to end up blank.
fileEditor.ResizeContents(PDFDocument, pageIndexes, shrinkParameters)

saveShrinkPDFPath = Path.Combine(testKludgeDir, Trim(fileObject.FileID).ToString() + “_ResizeContents.pdf”)
PDFDocument.Save(saveShrinkPDFPath) 'File saved here appears to be blank.
PDFDocument.Dispose()
PDFDocument = Nothing
Catch ex As Exception
'No exception is thrown.
End Try





Hi James,


Thanks for your inquiry. I have tested your scenario with the shared PDF document and noticed the reported issue, so logged a ticket PDFNEWNET-40326 in our issue tracking system for further investigation and rectification. We will notify you as soon as it is resolved.

We are sorry for the inconvenience caused.

Best Regards,

Hello,

This ticket seems to be open some time already, as I have the same issue with blank pages after resizing, I would like to know if this has been resolved/implemented in a newer version?

Best regards,

@ikke1234,

The linked ticket ID PDFNET-40326 is not resolved yet. We will notify you once it is fixed. Besides this, we recommend you to please send all details of your scenario, including source document and code. We will investigate your scenario in our environment, and share our findings with you.