简体   繁体   English

图像的PDFsharp压缩

[英]PDFsharp Compression for Images

I'm building a tool which will join multiple PDFs into a single file. 我正在构建一个将多个PDF合并到一个文件中的工具。

Each source PDF is one single page containing an image. 每个源PDF都是一个包含图像的一页。 The images are high resolution greyscale, and generally quite large. 图像是高分辨率的灰度,通常很大。

I need to find the most optimal compression to apply to these images such that the resultant file is smaller than it is now (with around 240 source PDFs, the final file comes out at over 650 MB). 我需要找到适用于这些图像的最佳压缩方式,以使生成的文件比现在小(包含约240个源PDF,最终文件的大小超过650 MB)。

My question is, would it be possible to extract the images from the source PDFs, convert them to grey scale TIFFs and then compile a new PDF using them as sources? 我的问题是,是否可以从源PDF中提取图像,将其转换为灰度TIFF,然后使用它们作为源来编译新的PDF? It is my hope that this approach would make use of the inbuilt LZ compression, rather than the JPEG process of just copying the image into the PDF byte by byte. 我希望这种方法将利用内置的LZ压缩,而不是仅将图像逐字节复制到PDF的JPEG处理。

The images themselves are high resolution and large size, so even scaling them would make a difference (I will be testing this today - these images will be sent for printing into a portfolio book, so a higher resolution is preferable, however as the book will be A5, they don't need to be enormous). 图像本身具有高分辨率和大尺寸,因此即使缩放它们也会有所不同(我今天将对此进行测试-这些图像将被发送以打印到投资组合书中,因此更高分辨率是可取的,但是该书会成为A5,则不必太大)。

I would be grateful for any suggestions of a better implementation, although I'm stuck with using these one page PDFs as my sources - there are simply too many images to start from scratch using the original sources, so extracting them from the source PDFs is my only real option. 尽管我一直坚持将这些一页PDF用作源,但我仍将不胜感激,尽管我坚持将这些一页PDF用作源-太多的图像无法使用原始源从头开始,所以从源PDF中提取它们是我唯一的选择

PDFsharp does not reduce your images in any way (that may come in the future, but currently images are not modified). PDFsharp不会以任何方式缩小图像(可能会在将来出现,但当前图像不会被修改)。

JPEG is a very efficient compression method. JPEG是一种非常有效的压缩方法。 Image quality is reduced a bit, but file size shrinks drastically. 图像质量有所降低,但文件大小急剧缩小。 Not suitable for line art, but very good for photos. 不适合艺术线条,但非常适合照片。
PDFsharp will optionally apply LZ compression to JPEG images, but that usually gains 1 % through 5 % only. PDFsharp可以选择将LZ压缩应用于JPEG图像,但是通常只能获得1%到5%的增益。

It's up to you to scale the images down. 您可以按比例缩小图像。 If you go for JPEG you have to decide which JPEG quality you need - lower quality gives smaller images. 如果您要使用JPEG,则必须确定所需的JPEG质量-较低的质量会生成较小的图像。

You can try using TIFF or PNG images. 您可以尝试使用TIFF或PNG图像。 PDFsharp will also apply LZ compression when embedding them in PDF, but in most cases JPEG will achieve much better compression results. 当将PDFsharp嵌入到PDF中时,它们也会应用LZ压缩,但是在大多数情况下,JPEG将获得更好的压缩结果。

Without seeing a real PDF with a real image I can only provide a general answer about how PDFsharp handles images. 在看不到带有真实图像的真实PDF的情况下,我只能提供有关PDFsharp如何处理图像的一般答案。

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

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