I am evaluating Aspose.Pdf for .NET for a fax application where PDFs are converted into monochrome images. For conversion of DOCX files, we use Aspose.Words for .NET, and it does it a great job, particularly because it allows text anti-aliasing to be disabled when rendering pages. With Aspose.Words, I call Aspose.Words.Document.RenderToSize to render each page, and RenderToSize responds to how I set Graphics.TextRenderingHint to disable anti-aliasing. Each page (one at a time) is rendered as 24bpp, then I use my code to dither down to 1bpp, which is ideal because I have complete control over the dithering algorithm. I’m hoping to find a way to do the same thing with Aspose.Pdf.
So far, I’ve found that using a TiffDevice gives me the most options for rendering PDF pages, and there’s an option TiffDevice.RenderingOptions.SystemFontsNativeRendering that I can set to True that seems to disable anti-aliasing on some fonts (the output quality is what I’m looking for). But I’ve found many PDF files where this setting has no effect on fonts, and they are still rendered with anti-aliasing.
Is there a way to disable anti-aliasing on all text when PDF pages are sent to a TiffDevice (or any image format)?
Thanks…
@nickpeck,
We are working over your query and will get back to you soon.
@nickpeck,
We are sorry for the delay, kindly send us a sample of PDF document having the both types of fonts for which Aspose.Pdf for .NET API disable and enable anti-aliasing. You may also list down all problematic fonts. We will investigate and share our findings with you.
Aspose Tests.zip (1.9 MB)
The uploaded file (Aspose Tests.zip) contains two PDF files, where each PDF was converted into two TIFF files that were created with the code below. One of the TIFFs was created with SystemFontsNativeRendering set to true, the other example SystemFontsNativeRendering is false. The files are clearly named to show how they were created. For our purposes, the best looking TIFF file was made from Example1.pdf where SystemFontsNativeRendering was set to true. If you examine that TIFF file and zoom in a little, you’ll see no anti-aliasing on most of the text. Those jagged looking fonts are exactly what we need, where’s there’s no anti-aliasing, and thus no gray/smoothed edges.
The other PDF, Example2.pdf when converted to TIFF looks about the same, regardless of how SystemFontsNativeRendering is set. Obviously, this setting does not apply to the majority of fonts in that PDF. What we’re looking for is something that disables anti-aliasing on all fonts when the PDF is converted to an image. Please note that we are not creating the PDFs, they are PDFs that come from users that are created with whatever software they use.
Thanks for taking a look…
using (FileStream fs = new FileStream(Path.ChangeExtension(pdfFileName,".tif"),FileMode.Create))
{
// Create Resolution object
Resolution rtiff = new Resolution(200);
// Create TiffSettings object
TiffSettings tiffSettings = new TiffSettings();
tiffSettings.Compression = CompressionType.None;
tiffSettings.Depth = ColorDepth.Default;
tiffSettings.Shape = ShapeType.None;
tiffSettings.SkipBlankPages = false;
// Create TIFF device
TiffDevice tiffDevice = new TiffDevice(render_width,render_height,rtiff,tiffSettings);
tiffDevice.RenderingOptions.SystemFontsNativeRendering = false; // This was set to true or false as needed
tiffDevice.Process(document,1,1,fs);
}
@nickpeck,
We managed to replicate the said problem in our environment. It has been logged under the ticket ID PDFNET-43642 in our bug tracking system. We have linked your post to this ticket and will keep you informed regarding any available updates.
I’m wondering if there’s been any progress in providing a way to make Aspose.PDF disable text antialiasing when converting pages to images (PDFNET-43642)? When the target image is 1 bit-per-pixel, text antialiasing results is fuzzy, grainy and needlessly larger images. Even if Aspose.PDF converted pages to 24 bit-per-pixel images that would be great. As long as the text antialiasing is not there, the image can be converted down to 1 bit-per-pixel with a variety of tools and it will look substantially better. Yes, we live in a world with super high DPI color display devices, but for those of us dealing with mono fax images antialiasing is a quality killer. It would be great if Aspose.PDF could render text without antialiasing, just like what can be done with Aspose.Words (which is an awesome library).
@nickpeck
The earlier logged ticket has been logged as an enhancement request and we are afraid that it is not yet resolved. However, we have recorded your comments and will surely consider them during its investigation. Please give us some time. We will let you know as soon as we have additional updates in this regard.
We apologize for your inconvenience.
Hi, I thought I would check if Aspose is going to provide a way for Aspose.PDF to render PDF-to-image without added anti-aliasing (PDFNET-43642)? The added smoothing improves images for screen display, but adds unnecessary artifacts to images when converted to monochrome. That’s the space I’m in, 1bpp fax. I’m finding SDKs from other companies that let me disable smoothing/anti-aliasing for PDF-to-image rendering, and I’ll have to send my money to the company that produces the results I need. Unfortunately, Aspose.PDF isn’t looking good by comparison.
@nickpeck
We really regret to inform that the ticket has not been yet resolved. However, please note that we will definitely resolve it after completing the investigation of this feature. The feature is currently under the phase of investigation and as soon as we make some progress towards its implementation, we will update you via this forum thread. We highly appreciate your patience and comprehension in this matter.
We apologize for the inconvenience.