I am running into problems when converting layered PDFs to JPGs.
I have a sample PDF (which I believe has an invisible layer in it) which can be converted to a JPG using the jpegDevice.Process() function. However when I open the JPG, large areas of the image are missing.
I’ve used my code with other PDFs and they seem to convert correctly:
Dim sizeThumbnails As Integer = 600
Dim smallestDPI As Integer = 72
Dim pdfDocument As New Aspose.Pdf.Document(sInFile)
Using imageStream As New FileStream(sOutFile, FileMode.Create)
’ Height and width in points (1/72 inch)
Dim pageHeight As Double = pdfDocument.Pages(1).Rect.Height
Dim pageWidth As Double = pdfDocument.Pages(1).Rect.Width
’ Work out the smallest DPI
Dim screenDPI As Integer = 72
Dim horizontalDPI As Integer = Convert.ToInt32((sizeThumbnails / pageWidth) * screenDPI)
Dim verticalDPI As Integer = Convert.ToInt32((sizeThumbnails / pageHeight) * screenDPI)
If (horizontalDPI < verticalDPI) Then
smallestDPI = horizontalDPI
Else
smallestDPI = verticalDPI
End If
Dim resolution As New Devices.Resolution(smallestDPI)
Dim jpegDevice As New Devices.JpegDevice(resolution, 80)
'convert a particular page and save the image to stream
Hi Bruce,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Thank you for
sharing the template files.
I am able to
generate your mentioned issue after an initial test. For rectification, your
issue has been registered in our issue tracking system with issue id: PDFNEWNET-34145. You will be notified
via this forum thread regarding any updates against your reported issue.
Thanks for the update. I've just downloaded and installed the latest Aspose.Total and have then installed Aspose.Pdf v7.7.0.
I've re-run my test on that PDF (the Anzac Day BBQ), but I get exactly the same result as when I first reported the problem. The JPG is saved with a wide white band around the top and left sides of the image.
Thanks for sharing the feedback. I have again tested the scenario using Aspose.Pdf for .NET 7.7.0 and as per my observations, the issue is not occurring. For your reference, I have also attached the resultant image file which is generated over my end. Can you please ensure that the new product version is included in your project. We are sorry for this inconvenience.