Poor image quality when converting word docs with evo pdf

454 views Asked by At

I use the WordToPdfConverter from evo to convert a Word document to a PDF. The Word document, which is in RTF format, contains images such as a QR code.

Unfortunately, the image quality in the resulting PDF is very poor (hence the QR code won't be readable). Even if I disable image compression or set it to the lowest level (=> best quality), the resulting image has a very poor quality.

Is there any other way to control the image quality? Or is there a way to tell evo's WordToPdfConverter not to use JPG as the resulting image format but to stuck with the source format (e.g. PNG)?

var pdfConverter = new WordToPdfConverter();

// Set Pdf image options
pdfConverter.PdfDocumentOptions.JpegCompressionEnabled = false;
pdfConverter.PdfDocumentOptions.JpegCompressionLevel = 0;

var filename = @"C:\temp\evo\TestWordDoc.rtf";
pdfConverter.ConvertWordFileToFile(filename, Path.Combine(Path.GetDirectoryName(filename), $"{Path.GetFileNameWithoutExtension(filename)}_{DateTime.Now:yyyyMMddHHmmss}.pdf"));
2

There are 2 answers

1
hcham1 On

Since RTF is a text format, you should convert it to PDF without having to do any image compression as that will take longer to process and will result in a larger output file + you might have issues with the image quality from embedded images.

I created a sample RTF file (test.rtf) that contains a QR code as you described:

screenshot of rtf

I then took the RTF and ran it through the Document Converter from the Leadtools.Document.sdk Nuget. Just as a disclaimer: I am associated with this library.

This document converter preserves the text and parses the images as-is from the source document, then outputs it to PDF.

You can download the output PDF from here: test.pdf

screenshot of pdf

Here is some sample code:

using (var documentConverter = new DocumentConverter())
{
   var filename = @"C:\temp\evo\TestWordDoc.rtf";
   var document = DocumentFactory.LoadFromStream(filename, new LoadDocumentOptions());
   var jobData = DocumentConverterJobs.CreateJobData(filename, Path.Combine(Path.GetDirectoryName(filename), $"{Path.GetFileNameWithoutExtension(filename)}_{DateTime.Now:yyyyMMddHHmmss}.pdf"), DocumentFormat.Pdf);
   var job = documentConverter.Jobs.CreateJob(jobData);
   documentConverter.Jobs.RunJob(job);
}
0
K J On

I am failing to see why people have issues with QR codes such as this one which is just a template (I could not download any of the older samples above for comparison.) enter image description here  

  enter image description here

It is a PNG demo template file designed to be scanned from up to 4 feet away (e.g. a poster) but it could be for production, much smaller i.e. lower scale for page scanning.

I drop the RTF on the WordPad print to pdf shortcut and get the pdf shown in the viewer almost instantly.

enter image description here

There is some natural degradation using RTF PNG and an aliased viewer, but the key is maintaining natural scales. Every thing you need is native as supplied with windows. MSPaint, WordPad, CMD printing I could have sent preview to the PDFium viewer in Edge.

enter image description here