[英]How to compress PDF file that is generated using HTML-Renderer library c#
i have the following code which is working fine.我有以下代码工作正常。 I am generating
pdf
file through html
content using library HTML-Randerer
.我正在使用库
HTML-Randerer
通过html
内容生成pdf
文件。 Problem is that generated pdf
file size become increases up to aprox 8MB some time.and i wanted to compress that file as i have to send this pdf
to some of the client .问题是生成的
pdf
文件大小有时会增加到大约 8MB。我想压缩该文件,因为我必须将此pdf
发送给某些客户端。 I have searched but did not find any solution.我已经搜索过,但没有找到任何解决方案。
Note:"Html content has no image just tag and textual data only "注意:“Html 内容没有图像,只有标签和文本数据”
Library: HTML Renderer库: HTML 渲染器
Question: How to compress the pdf file using HTML Renderer
is there any method ?问题:如何使用
HTML Renderer
压缩 pdf 文件有什么方法吗?
Code代码
public void GenerateHtmlToPdf(string htmlContent, string sFilePath)
{
PdfDocument pdf = PdfGenerator.GeneratePdf(htmlContent, PageSize.A4, 25);
pdf.Save(sFilePath);
}
Thanks!谢谢!
The PDF "foo.pdf" you provide contains 33 pages, each pages is between 150 kB to 350 kB in size.您提供的 PDF“foo.pdf”包含 33 页,每页大小在 150 kB 到 350 kB 之间。
Each page draws hundreds of lines.每页画数百行。 Maybe the library draws four lines around each cell.
也许图书馆在每个单元格周围画了四条线。 The same visual effect could be achieved with a few, long lines which would reduce the file size considerably.
使用几行长行可以实现相同的视觉效果,这将大大减少文件大小。
There are many PDF Optimizer and PDF Compacter around, but I'm afraid they won't do much good with that file.周围有很多 PDF Optimizer 和 PDF Compacter,但恐怕它们对该文件的作用不大。
It seems you can't do it with pdfsharp.看来你不能用 pdfsharp 做到这一点。 And because you don't use images, there is no help there either in that direction.
而且因为您不使用图像,所以在那个方向上也没有帮助。 You may read up on alternatives in another post Compress existing PDF using C# programming
您可以在另一篇文章使用 C# 编程压缩现有 PDF 中阅读替代方案
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.