unidoc / unipdf

Golang PDF library for creating and processing PDF files (pure go)
https://unidoc.io
Other
2.56k stars 251 forks source link

[BUG] "unsupported encoding parameters" with some PDFs when upgrading to 3.19.0+ #446

Closed echarrod closed 3 years ago

echarrod commented 3 years ago

Description

When setting the optimizer on the PdfWriter with:

// Set optimizer.
writer.SetOptimizer(optimize.New(optimize.Options{
    CombineDuplicateDirectObjects:   true,
    CombineIdenticalIndirectObjects: true,
    CombineDuplicateStreams:         true,
    CompressStreams:                 false,
    UseObjectStreams:                true,
    ImageQuality:                    80,
    ImageUpperPPI:                   100,
}))

When a subsequent call to write with this writer is made with:

err = writer.Write(outputFile)

The error "unsupported encoding parameters" is thrown.

This was introduced in 3.19.0+, these PDFs work fine with versions before this.

Expected Behavior

Actual Behavior

Steps to reproduce the behavior: 1) Open the attached project 2) Run go test ./... 3) Inspect the produced PDF in /testdata

Attachments

Alttaf commented 3 years ago

+1

gunnsth commented 3 years ago

Fixed in newest release https://github.com/unidoc/unipdf/releases/tag/v3.27.0