简体   繁体   English

使用 evo pdf 转换 word 文档时图像质量差

[英]Poor image quality when converting word docs with evo pdf

I use the WordToPdfConverter from evo to convert a Word document to a PDF.我使用 evo 的 WordToPdfConverter 将 Word 文档转换为 PDF。 The Word document, which is in RTF format, contains images such as a QR code. RTF 格式的 Word 文档包含 QR 码等图像。

Unfortunately, the image quality in the resulting PDF is very poor (hence the QR code won't be readable).不幸的是,生成的 PDF 中的图像质量非常差(因此无法读取 QR 码)。 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 (eg PNG)?或者有没有办法告诉 evo 的 WordToPdfConverter 不要使用 JPG 作为生成的图像格式,而是坚持使用源格式(例如 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"));

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.由于 RTF 是一种文本格式,您应该将其转换为 PDF 而无需进行任何图像压缩,因为这将花费更长的时间来处理并且会导致更大的 output 文件 + 您可能会遇到嵌入图像的图像质量问题。

I created a sample RTF file ( test.rtf ) that contains a QR code as you described:我创建了一个示例 RTF 文件 ( test.rtf ),其中包含您描述的 QR 码:

rtf 截图

I then took the RTF and ran it through the Document Converter from the Leadtools.Document.sdk Nuget .然后我使用 RTF 并通过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.此文档转换器保留文本并按原样解析源文档中的图像,然后将其输出到 PDF。

You can download the output PDF from here: test.pdf您可以从此处下载 output PDF: test.pdf

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);
}

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.)我不明白为什么人们对二维码有问题,比如这个只是一个模板(我无法下载上面的任何旧样本进行比较。) 在此处输入图像描述

在此处输入图像描述

It is a PNG demo template file designed to be scanned from up to 4 feet away (eg a poster) but it could be for production, much smaller ie lower scale for page scanning.这是一个 PNG 演示模板文件,设计用于从最远 4 英尺的距离(例如海报)进行扫描,但它可以用于生产,更小,即用于页面扫描的比例较小。

I drop the RTF on the WordPad print to pdf shortcut and get the pdf shown in the viewer almost instantly.我将写字板打印上的 RTF 拖放到 pdf 快捷方式,并几乎立即在查看器中显示 pdf。

在此处输入图像描述

There is some natural degradation using RTF PNG and an aliased viewer, but the key is maintaining natural scales.使用 RTF PNG 和别名查看器会有一些自然退化,但关键是保持自然比例。 Every thing you need is native as supplied with windows.您需要的每样东西都是随 windows 一起提供的。 MSPaint, WordPad, CMD printing I could have sent preview to the PDFium viewer in Edge. MSPaint、写字板、CMD 打印我本可以将预览发送到 Edge 中的 PDFium 查看器。

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM