Skip to content

Questions about v1.4.0 #262

Closed
Closed

Description

@JQHxx

My environment is php5.3. I have encountered many problems when converting PDFS to images.
The first problem is that the text in the transferred pictures is not clear and cannot be seen at all
The second issue is that although the total number of pages of a pdf file can be obtained, the output is always the first image

The code is as follows:
$pdf = new \Spatie\PdfToImage\Pdf($pdfPath);

// 获取总页数
$numberOfPages = $pdf->getNumberOfPages();
echo "PDF 总页数:" . $numberOfPages . "
";

// 逐页转换
for ($i = 1; $i <= $numberOfPages; $i++) {
$outputPath = $outputDir . 'page_' . $i . '.png';
// 选择当前页
$pdf->setPage($i)
->setOutputFormat('png')
->setCompressionQuality(90)
->setResolution(300)
->saveImage($outputPath);

echo "已生成:" . $outputPath . "<br>";

}

Activity

  1. locked and limited conversation to collaborators on Apr 27, 2026
  2. converted this issue into a discussion #263 on Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions