pdfcpu / pdfcpu

A PDF processor written in Go.
http://pdfcpu.io/
Apache License 2.0
6.74k stars 465 forks source link

About the version of xRefTable #846

Open jimbirthday opened 5 months ago

jimbirthday commented 5 months ago

Thank you for submitting a possible bug!

Please ensure the following:

this my pdf file info

PDF version: | 1.7

this my code

    pdfFile := "1.pdf"

    // 将PDF页面渲染为图像
    err := api.ExtractImagesFile(pdfFile, "./1.png", []string{"1"}, &model.Configuration{
        WriteXRefStream: false,
    })
    if err != nil {
        fmt.Fprintf(os.Stderr, "Extraction error: %v\n", err)
        return
    }

log

Extraction error: Read: xRefTable failed: parseTrailerDict: PDF1.4 conformant reader: found incompatible version: 1.7
jimbirthday commented 5 months ago

image change WriteXRefStream to true, result same

hhrutter commented 5 months ago

Did you ensure your input file passes validation? pdfcpu val in.pdf

hhrutter commented 5 months ago

This file's trailer seems to be corrupted somehow. Working on the assumption that you can open this file with A.Preview or A.Reader.. If you can share the file I will look into this and provide a fix. Thank you!