简体   繁体   English

将高分辨率PDF转换为低分辨率PDF文件C#

[英]Convert High Resolution PDF to Low Resolution PDF file C#

I´m looking for a way to convert a High Resolution PDF file to a Low Resolution PDF file from an ASP.NET applicaitn (C#). 我正在寻找一种将ASP.NET应用程序(C#)中的高分辨率PDF文件转换为低分辨率PDF文件的方法。 Users will import High Resolution PDF's and the solution should then have the possibility to provide both High Resolution PDF and Low Resolution PDF. 用户将导入高分辨率PDF,然后解决方案应该可以同时提供高分辨率PDF和低分辨率PDF。 I´m looking for a API to do that. 我正在寻找一个API来做到这一点。 I have found a lot of PDF apis but none of them seems to do what I´m looking for. 我发现了很多PDF api,但是它们似乎都无法满足我的需求。

ABCpdf .NET will do this for you. ABCpdf .NET将为您完成此任务。 There are a variety of functions for resizing, resampling or recompressing the images within a PDF document. 有多种功能可用于调整PDF文档中图像的大小,重新采样或重新压缩。 However given your requirements you probably just want to use the document reduce size operation. 但是,鉴于您的要求,您可能只想使用文档缩小大小操作。

To do this you just need code of the following form: 为此,您只需要以下形式的代码:

Doc doc = new Doc();
doc.Read(Server.MapPath("../mypics/sample.pdf"));
using (ReduceSizeOperation op = new ReduceSizeOperation(doc)) {
op.UnembedSimpleFonts = false; // though of course making these true...
op.UnembedComplexFonts = false; // ... would further reduce file size.
op.MonochromeImageDpi = 72;
op.GrayImageDpi = 72;
op.ColorImageDpi = 144;
op.Compact(true);
}
doc.Save(Server.MapPath("ReduceSizeOperation.pdf"));

I work on the ABCpdf .NET software component so my replies may feature concepts based around ABCpdf. 我从事ABCpdf .NET软件组件的工作,因此我的答复可能包含围绕ABCpdf的概念。 It's just what I know. 这就是我所知道的。 :-) :-)

Probably you can just resize images in high resolution version PDF and this will give you much smaller files. 您可能只需要调整高分辨率版本PDF中的图像大小,这将为您提供更小的文件。

You can resize and/or recompress images using Docotic.Pdf library . 您可以使用Docotic.Pdf库调整大小和/或重新压缩图像。 For more details please take a look at my answer to a similar question . 有关更多详细信息,请查看我对类似问题的回答

Disclaimer: I am one of the developers of Docotic.Pdf library. 免责声明:我是Docotic.Pdf库的开发人员之一。

There are a number of possible approaches to this problem, one of which would simply be to export from InDesign twice (which would allow you to make the two required versions of PDF). 有许多可能的方法可以解决此问题,其中一种方法是从InDesign导出两次(这使您可以制作两个必需的PDF版本)。 If that is not feasible (which it might not be as exporting from InDesign can take a bit of time) there are definitely libraries on the market that can perform what you want to do. 如果那不可行(从InDesign中导出可能会花费一些时间),那么市场上肯定有可以执行您想要做的事情的库。 Here to you have a number of approaches: 这里有几种方法:

1) While this will get me shot by most Adobe employees, you could re-distill your PDF file into a smaller file. 1)虽然这会让大多数Adobe员工为我着迷,但您可以将PDF文件重新提取为较小的文件。 I would not advocate to do this, I'm mentioning it to be complete. 主张这样做,我只是说它是完整的。 Risks involved would be introducing quality loss, artefacts and so on (mostly because PostScript doesn't support a number of features PDF does support and by redistilling you'd loose those features). 所涉及的风险是引入质量损失,伪影等(主要是因为PostScript不支持PDF支持的许多功能,并且通过重新列出您会丢失这些功能)。

2) Use an application or library that was made for this task. 2)使用为此任务制作的应用程序或库。 callas pdfToolbox for example (warning, I'm affiliated with this company!) is capable of taking a PDF file and running corrections on it. 例如,callas pdfToolbox(警告,我隶属于这家公司!)可以获取PDF文件并对其进行更正。 Amongst those corrections are image downsampling, conversion to RGB, image re-compression (for example with JPEG-2000), throwing away unnecessary data in the PDF and much more. 这些校正包括图像下采样,转换为RGB,图像重新压缩(例如,使用JPEG-2000),丢弃PDF中不必要的数据等等。 Given that the application has a command-line interface, it can easily be integrated into ac# process. 由于该应用程序具有命令行界面,因此可以轻松地集成到ac#流程中。 Other applications with similar functionality would be from companies such as Enfocus, Apago and others. 具有类似功能的其他应用程序将来自Enfocus,Apago等公司。

3) Use a low-level PDF library (such as the Adobe PDF library that can be licensed from Adobe through DataLogics) and implement the necessary changes yourself. 3)使用低级PDF库(例如可以通过DataLogics从Adobe许可的Adobe PDF库)并自己实施必要的更改。 More work, but potentially more flexible. 工作更多,但可能更灵活。

Whatever approach you choose, know that you are starting from a high-quality PDF file and that your process should try to retain as much of that quality as possible (dependant on which application you have for the low resolution PDF file of course). 无论选择哪种方法,都知道您是从高质量的PDF文件开始的,并且您的过程应尝试保持尽可能多的质量(当然,这取决于低分辨率PDF文件的应用程序)。 Make sure you don't get into trouble by loosing proper overprint, transparency etc... 确保您不会因为失去适当的叠印,透明度等而陷入麻烦...

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

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