【发布时间】:2019-05-01 07:14:57
【问题描述】:
您好,我有这样的代码行
var lstimage = device.ScanTIFF(SelectedScanType.Value);
// Combine list Image to PDF
imageExtension = ".pdf";
var path = Path.Combine(textBox1.Text, textBox2.Text + imageExtension);
if (File.Exists(path))
{
File.Delete(path);
}
Document doc = new Document();
//doc.SetPageSize(PageSize.A4);
var ms = File.Create(path);
{
var pdf = PdfWriter.GetInstance(doc, ms);
doc.Open();
foreach (ImageFile item in lstimage)
{
var imagepdf = iTextSharp.text.Image.GetInstance((byte[])item.FileData.get_BinaryData());
//imagepdf.ScaleAbsolute(500f, 750f);
//PdfPTable table = new PdfPTable(1);
//table.AddCell(imagepdf);
doc.Add(imagepdf);
}
if (doc.IsOpen()) doc.Close();
}
我的结果 pdf 文件太大。
仅 3 个图像文件 (300dpi) 就为我提供了 35MB 的 pdf 文件空间。
您知道如何帮助我优化文件或将文件缩小到更小的尺寸吗?
这是我的文件信息
任何用于在不更改 DPI 的情况下减少此图像的 C# 库(因为我将此文件用于 OCR)
【问题讨论】:
-
在将它们添加到 itext 之前,您必须减小图像大小,itext 不会更改图像大小。
-
你有什么例子可以在这种情况下减少 ImageFile 并且减少后图像质量没有太大变化吗?