Skip to content

ValidationNone no longer supported in Merge() function since v0.5.0 #708

@blakepatteson

Description

@blakepatteson

Hi - first of all thanks for all your work on this library!

I noticed that this started failing as of upgrading to the latest version :
-Using version 0.5.0 - github.com/pdfcpu/pdfcpu v0.5.0
-Using Windows 10 Pro Version 22H2 (OS Build 19045.3324)
-Using Go version go version go1.21.1 windows/amd64

Steps to Reproduce : call the function :

func MergeCreateFile(inFiles []string, outFile string, conf *model.Configuration) (err error)

...with a conf.ValidationMode of "model.ValidationNone" and see if the config is overwritten

I had this simple wrapper function that would call "api.MergeCreateFile()" with my specific config :

func combinePDFs(allDocuments []pdfDocument, outPath string) error {
	conf := model.NewDefaultConfiguration()
	conf.ValidationMode = model.ValidationNone
	allPaths := getPathsFromDocumentSlice(allDocuments)
	if err := api.MergeCreateFile(allPaths, outPath, conf); err != nil {
		return &models.CmdErrorDetails{
			IsFatal: true,
			Title:   "ERR MERGING PDFS",
			Message: "Something went wrong when cominbing the input PDF's. Details : \n",
			ValuesList: append([]string{
				err.Error(),
				fmt.Sprintf("outPath : '%v'", outPath),
				fmt.Sprintf("conf : '%+v'", conf),
			}, allPaths[0], allPaths[1], "...", allPaths[len(allPaths)-1]),
		}
	}
	return nil
}

I want to ignore the validation errors for this particular operation, but as of be32323, it appears that this functionality is no longer supported

In the previous version, it used to work fine. Now I get this error and this output :

Now creating PDF......conf : 'pdfcpu configuration:
Path:              disable
CheckFileNameExt:  true
Reader15:          true
DecodeAllStreams:  false
ValidationMode:    none
Eol:               EolLF
WriteObjectStream: true
WriteXrefStream:   true
EncryptUsingAES:   true
EncryptKeyLength:  256
Permissions:       -3901
Unit :             points
TimestampFormat:        2006-01-02 15:04
DateFormat:             2006-01-02
HeaderBufSize:          100
OptimizeDuplicateContentStreams false
CreateBookmarks false
'
!!! ERR MERGING PDFS !!!
!!! ERR MERGING PDFS !!!

Something went wrong when cominbing the input PDF's. Details :

dict=extGStateDict entry=TK: unsupported in version 1.3
This file could be PDF/A compliant but pdfcpu only supports versions <= PDF V1.7

outPath : 'C\path\test\multi_employer_test/test.pdf'
conf : 'pdfcpu configuration:
Path:              disable
CheckFileNameExt:  true
Reader15:          true
DecodeAllStreams:  false
ValidationMode:    relaxed
Eol:               EolLF
WriteObjectStream: true
WriteXrefStream:   true
EncryptUsingAES:   true
EncryptKeyLength:  256
Permissions:       -3901
Unit :             points
TimestampFormat:        2006-01-02 15:04
DateFormat:             2006-01-02
HeaderBufSize:          100
OptimizeDuplicateContentStreams false
CreateBookmarks false
'

So it looks like "Merge()" no longer supports config "ValidationMode" of "ValidationNone" - not sure if that was intentional based on be32323?

For now my work around is just reverting to "0.4.0" for my use case.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions