将PDF转换为JPG,如Photoshop质量 - 商业C ++ / Delphi库

时间:2012-02-20 11:17:40

标签: c++ windows delphi pdf jpeg

为了实现基于Windows的翻页应用程序,我需要能够将大量PDF页面转换为高质量的JPG,而不仅仅是缩略图。

目标是实现最佳质量/文件大小,类似于Photoshops Save for Web。

目前我正在使用Datalogics Adob​​e PDF Library SDK,它似乎无法完成该任务。因此,我正在寻找一种替代的通用C ++或Delphi库,它提供了良好的质量/尺寸/速度。

在这里做了一些搜索之后,我注意到大多数帖子都是关于GS& Imagekick,我也测试过,但我对输出和速度不满意。

目标是导入300dpi的PDF并将其转换为JPG质量50,1500px高度和300-500kb的输出。

如果有人能为这项任务指出一个好的图书馆,我会非常感激。

5 个答案:

答案 0 :(得分:2)

Gnostice PDFtoolKit VCL可能是候选人。转换为JPEG是其中一个选项。

答案 1 :(得分:1)

我总是建议Graphics32满足您的所有图像处理需求;你有几个resamplers可供选择。但是,我认为它不能将PDF文件作为图像读取。但如果你能自己生成大图像,那么它可能是个不错的选择。

答案 2 :(得分:1)

Atalasoft DotImage(使用PDF rasterizer附加组件)将会这样做(我在那里处理PDF技术)。您将使用C#(或其他.NET)语言:

ConvertToJpegs(string outfileStem, Stream pdf)
{
    JpegEncoder encoder = new JpegEncoder();
    encoder.Quality = 50;

    int page = 1;
    PdfImageSource source = new PdfImageSource(pdf);
    source.Resolution = 300; // sets the rendering resolution to 200 dpi
    // larger numbers means better resolution in the image, but will cost in
    // terms of output file size - as resolution increases, memory used increases
    // as a function of the square of the resolution, whereas compression only
    // saves maybe a flat 30% of the total image size, depending on the Quality
    // setting on the encoder.

    while (source.HasMoreImages()) {
        AtalaImage image = source.AcquireNext();
        // this image will be in either 8 bit gray or 24 bit rgb depending
        // on the page contents.

        try {
            string path = String.Format("{0}{1}.jpg", outFileStem, page++);
            // if you need to resample the image, this is the place to do it
            image.Save(path, encoder, null);
        }
        finally {
            source.Release(image);
        }
    }
}

答案 3 :(得分:0)

答案 4 :(得分:0)

看看DynaPDF。我知道它非常昂贵,但你可以试试初学者包。

P.S.:在购买产品之前,请确保它符合您的需求。

相关问题