当被要求不要时,ABC PDF抗锯齿图像

问题描述 投票:1回答:1

将QR码作为位图添加到ABCPDF文档:

Doc pdf = new Doc();
pdf.Rendering.AntiAliasImages = false;
...
pdf.AddImageBitmap(bmp, true);

渲染为PDF文件时,图像显示为锯齿:

enter image description here

直接打印到打印机时,QR码相同:

enter image description here

我的问题是:我做错了什么?

c# abcpdf
1个回答
1
投票

您需要根据图像大小和分辨率调整Doc.Rect的大小,例如

// Set PDF image size from image size and resolution (PDF coord space is 72dpi)
doc.Rect.Height = bmp.Height * 72 / bmp.VerticalResolution;
doc.Rect.Width = bmp.Width * 72 / bmp.HorizontalResolution;
doc.AddImageBitmap(bmp, true);

(并且Rendering类属性仅在从PDF导出到图像时适用。)

© www.soinside.com 2019 - 2024. All rights reserved.