Hi. I am using the below code in C# with Aspose.PDF version 25.6.1 and when converting certain images color drop out or the color gets lines.
Also what is the highest resolution that can be set?
var pdfDocument = new Document(FullImageMemoryStream);
Resolution resolution = new Resolution(AppSettings.Instance.PdfResolution);
var renderer = new Aspose.Pdf.Devices.BmpDevice(800);
//renderer.RenderingOptions.
Stream bitmapStream = new MemoryStream();
renderer.Process(pdfDocument.Pages[1], bitmapStream);
bmp = new Bitmap(bitmapStream);
bitmapStream.Close();
image.jpg (76.2 KB)
image.jpg (129.7 KB)
@GKElite
Cause
The issue of lines or color dropouts when converting PDF to Bitmap may stem from the resolution settings or specific content in the PDF that does not render correctly at the specified resolution. Additionally, using an older version of Aspose.PDF (25.6.1) may contribute to these rendering issues.
Solution
To resolve this, follow these steps:
-
Update Aspose.PDF: Ensure you are using the latest version of Aspose.PDF, as newer versions often include bug fixes and improvements related to rendering.
-
Adjust Resolution: Set a higher resolution for the BmpDevice
. The maximum resolution depends on your system’s capabilities, but values like 300 DPI or higher are common for high-quality images.
-
Check Rendering Options: Explore the RenderingOptions
property of the BmpDevice
to fine-tune the rendering process.
Code
Here’s an updated code snippet that sets a higher resolution and includes rendering options:
var pdfDocument = new Document(FullImageMemoryStream);
Resolution resolution = new Resolution(300); // Set to 300 DPI for better quality
var renderer = new Aspose.Pdf.Devices.BmpDevice(resolution);
Stream bitmapStream = new MemoryStream();
renderer.Process(pdfDocument.Pages[1], bitmapStream);
bitmapStream.Position = 0; // Reset stream position before creating Bitmap
bmp = new Bitmap(bitmapStream);
bitmapStream.Close();
Next Steps
- Update to the latest version of Aspose.PDF.
- Test the conversion using the updated code snippet.
- If the issue persists, check the specific PDF content for any anomalies that might affect rendering.
Please implement these steps and let me know if you need further assistance!
I thought 25.6.1 was the latest. Nuget is showing that as the current.
image.png (13.0 KB)
@GKElite
Would you kindly share your sample PDF document for our reference as well? We will test the scenario in our environment and address it accordingly.
Here is the original pdf.
Thank you for your help so far.
0090080169_670216_Z63YT1_FULLIMAGE.pdf (333.4 KB)
@GKElite
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): PDFNET-60291
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.