iTextSharp的变化结果的质量/压缩像PDF24Creator [英] iTextSharp change outcome quality / compression like PDF24Creator

查看:1017
本文介绍了iTextSharp的变化结果的质量/压缩像PDF24Creator的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在想,如果我可以压缩/更改我的outcoming pdf文件与iTextSharp的和C#的质量怎么样,我可以在Adobe Acrobat Pro或PDF24Creator做的。

I was wondering if I can compress/Change the Quality of my outcoming pdf-file with iTextSharp and C# like I can do with Adobe Acrobat Pro or PDF24Creator.

使用PDF24Creator我可以打开PDF格式,再次保存文件,并设置为低质量的PDF的质量我的文件大小从88,6MB下降到12,5MB而质量仍不够好。

Using the PDF24Creator I can open the pdf, save the file again and set the "Quality of the PDF" to "Low Quality" and my file size decreases from 88,6MB to 12,5MB while the Quality is still good enough.

我已经使用了

    writer = new PdfCopy(doc, fs);
    writer.SetPdfVersion(PdfCopy.PDF_VERSION_1_7);
    writer.CompressionLevel = PdfStream.BEST_COMPRESSION;
    writer.SetFullCompression();



这降低了大约92MB到88MB文件的大小。

which decreases the file size from about 92MB to 88MB.

另外:我可以使用命令行参数或启动参数通过我的C#代码运行PDF24计划?这样的事情:

Alternatively: Can I run the pdf24 Program through my C# code using command line arguments or starting Parameters? Something like that:

pdf24Creator.exe -save -Quality:low -inputfile -outputfile

感谢您的帮助(布鲁诺)!

Thanks for your help (Bruno)!

推荐答案

简短的回答:没有。

龙答:是的,但你必须做大量的工作自己的

Long answer: yes but you must do a lot of the work yourself.

如果你读href=\"http://stackoverflow.com/a/22028008/231316\">第三和第四个段落这里你会希望得到更好的理解什么是压缩实际上

If you read the third and fourth paragraphs here you'll hopefully get a better understanding of what "compression" actually means from a PDF perspective.

如Adobe Acrobat和PDF24造物主程序允许您在PDF中摧毁数据,以减少文件的大小。当您选择低质量设置最常见的变化,这些方案提出的是,实际提取所有的图像之一,降低它们的质量和在PDF中替换原来的文件。所以最初保存没有任何压缩的JPEG可能被撞倒到60%的质量。而仅仅是明确的,即60%是不可逆的,所以不能荏苒文件,它是从字面上摧毁数据,以节省空间。

Programs like Adobe Acrobat and PDF24 Creator allow you to reduce the size of a file by destroying the data within the PDF. When you select a low quality setting one of the most common changes these programs make is to actually extract all of the images, reduce their quality and replace the original files in the PDF. So a JPEG originally saved without any compression might be knocked down to 60% quality. And just to be clear, that 60% is non-reversible, it isn't zipping the file, it is literally destroying the data in order to save space.

另一个设置为减小图像的有效的DPI。放入2英寸宽的箱子一个500像素宽的图像有效250 DPI的。这些方案将提取图像,将图像缩小到也许96或72的DPI,这意味着500像素图像被减少到192或144像素的宽度和替换在PDF原始文件。再次,这是一个破坏性不可逆的变化。

Another setting is to reduce the effective DPI of an image. A 500 pixel wide image placed into a 2 inch wide box is effectively 250 DPI. These programs will extract the image, reduce the image to maybe 96 or 72 DPI which means the 500 pixel image be reduced to 192 or 144 pixels in width and replace the original file in the PDF. Once again, this is a destructive non-reversible change.

(和破坏性不可逆的,你仍然可能有原始文件,我只是想明确的是,这是不正确的压缩像ZIP)

(And by destructive non-reversible, you still probably have the original file, I just want to be clear that this isn't true "compression" like ZIP.)

不过,如果你真的想这样做,你可以看的这样的代码这表明你如何使用iText的进行提取和图像的重新插入。它是100%给你,但是,改变图像,因为iText的不会做出破坏性更改您的数据(这是一个很好的事情,我会说!)

However, if you really want to do it you can look at code like this which shows how you can use iText to perform the extraction and re-insertion of images. It is 100% up to you, however, to change the images because iText won't make destructive changes to your data (and that's a good thing I'd say!)

这篇关于iTextSharp的变化结果的质量/压缩像PDF24Creator的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆