phpdave11 / gofpdi

Go Free PDF Document Importer
MIT License
118 stars 59 forks source link

Adobe Acrobat error 110 when opening file using UseImportedTemplate #42

Open bhelzer opened 3 years ago

bhelzer commented 3 years ago

When generating a PDF file that uses imported pages I get the following error in Adobe Acrobat:

There was an error processing a page. There was a problem reading this document (110).

The file opens and displays correctly in Chrome, Brave, Safari and iOS Viewer.

If I comment out the following lines it does open in Adobe:

    page := gen.doc.ImportPage(gen.cacheFile(importData.Name), importData.Page, "/MediaBox")
    gen.doc.UseImportedTemplate(page, 0, 0, WIDTH, HEIGHT)

Also I checked, the source file does open in Acrobat as well.

bobc82 commented 2 years ago

I got same error when I use importing template. The method works fine and when i see the document generated in the browser, it will open fine. But once the the document is downloaded in a local folder and when i'll try to open it, adobe 110 error occurs. PS: Template doesn't contain errors. I'll try to show a simplified version of the method i wrote:

pdf := gopdf.GoPdf{}
pdf.Start(gopdf.Config{PageSize: gopdf.Rect{W: 841.89, H: 595.28}})
pdf.AddPageWithOption(gopdf.PageOption{PageSize: &gopdf.Rect{W: 841.89, H: 595.28}})
fileUrl, errSt := storage.Get("private", <path>, 10*60*time.Second)
if errSt != nil {
    return errSt.Error() + "Errore 114", errSt
}
errFile := DownloadFile("template.pdf", fileUrl)
if errFile != nil {
    return errFile.Error() + "Errore 121", errFile
}
tpl1 := pdf.ImportPage("template.pdf", 1, "/MediaBox")
pdf.UseImportedTemplate(tpl1, 0, 0, 841.89, 595.28)

filePdf := pdf.GetBytesPdf()
fileReader := bytes.NewReader(filePdf)

storage.Upload("private", fileReader, <path>, fileReader.Size(), "application/pdf", nil)
return "ok", nil
evilsocket commented 1 year ago

+1 ... I have the same exact issue, when using a (valid) pdf template, the generated document works pretty much everywhere but Adobe Acrobat raises a 100 error. Did anybody find a workaround or fix?

evilsocket commented 1 year ago

This is apparently fixed in master via https://github.com/phpdave11/gofpdi/compare/v1.0.13...master ... the issue seemed caused by a block like:

>>/Extend [truetrue]

instead of a correct:

>>/Extend [true true]