【问题标题】:Specify image dimensions when creating PNGs from a PDF with pdflib使用 pdflib 从 PDF 创建 PNG 时指定图像尺寸
【发布时间】:2018-03-07 19:51:39
【问题描述】:

可以设置从此脚本创建的 PNG 的尺寸吗?

例如setImageWidth = '200', setImageHeight ='500'

这可以通过 pdflib 实现还是应该在创建初始图像后使用 GD?

使用 pdflib 在 SO 或 Google 中找不到任何答案。

$pdflib = new ImalH\PDFLib\PDFLib();
$pdflib->setPdfPath($pdf_file_path);
$pdflib->setOutputPath($folder_path_for_images);
$pdfLib->setImageFormat(\ImalH\PDFLib\PDFLib::$IMAGE_FORMAT_PNG);   
$pdflib->setDPI(50);
$pdflib->setPageRange(1,$pdflib->getNumberOfPages());
$pdflib->convert(); 

【问题讨论】:

  • 您到底想实现什么,您想将 PDF 导出为图像?
  • 从 8.5x11 PDF 创建 PNG。图像已创建,但是,我希望 PNG 的尺寸约为 200 像素宽 X 500 像素高。

标签: php pdflib


【解决方案1】:

他们有一个 imagecropauto 功能,老实说看起来最接近:

resource imagecropauto ( resource $image [, int $mode = -1 [, float $threshold = .5 [, int $color = -1 ]]] )

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-23
    • 2021-08-26
    • 1970-01-01
    • 1970-01-01
    • 2012-05-15
    • 1970-01-01
    相关资源
    最近更新 更多