Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

validate: invalid border array #711

Closed
ximbal opened this issue Sep 14, 2023 · 6 comments
Closed

validate: invalid border array #711

ximbal opened this issue Sep 14, 2023 · 6 comments
Assignees

Comments

@ximbal
Copy link

ximbal commented Sep 14, 2023

I am validating a group of PDF files, I am getting this error:

PDF validation failed for file documents/process/move-rename/pdf-from-zip/684c366a052e42889156a47eee17a9d6d88326e55d8bda2b4851bdad10fdb63e.pdf: validation error (obj#:11): invalid border array: [10 10 10 60]PDF validation failed for file documents/process/move-rename/pdf-from-zip/684c366a052e42889156a47eee17a9d6d88326e55d8bda2b4851bdad10fdb63e.pdf: validation error (obj#:11): invalid border array: [10 10 10 60]Error combining and stamping PDFs: error combining PDF files: invalid border array: [10 10 10 60]
exit status 1

using the following code:

func validatePDFs(pdfFilePaths []string) (string, error) {
	for _, pdfFilePath := range pdfFilePaths {
		if err := api.ValidateFile(pdfFilePath, nil); err != nil {
			fmt.Printf("PDF validation failed for file %s: %v", pdfFilePath, err)
			return pdfFilePath, err
		}
	}
	return "", nil
}

I've been trying to find documentation around it.

Is this a bug?

Thank you.
E

@hhrutter
Copy link
Collaborator

Hello!

I need to see a stacktrace in order to tell you more.
if you can share the file even better.

Thank you!

@ximbal
Copy link
Author

ximbal commented Sep 18, 2023

@hhrutter hhrutter changed the title PDF validation failed for file: validation error (obj#:11): invalid border array validate: invalid border array Sep 18, 2023
@hhrutter
Copy link
Collaborator

10:   offset=     778 generation=0 types.Dict type=Annot subType=Link
<<
	<A, (9 0 R)>
	<Border, [10 10 10 60]>
	<P, (7 0 R)>
	<Rect, [512 735 562 773]>
	<Subtype, Link>
	<Type, Annot>
>>

This border dict seems to be in violation of the PDF specification:

Screenshot 2023-09-18 at 17 06 37

@ximbal
Copy link
Author

ximbal commented Sep 18, 2023

Thank you for the insight.

It seems that this was created with Crystal Reports, I am only merging in chronological order 200 PDF files. I was aiming to do it with pure golang. I can achieve the merging by using some CLI tools such as pdftk.

I understand that the goal is to stick as much as possible to the PDF specification. But my usecase is not about creating a PDF. but to merge a list of received files of which there are some malformed (such as this one).

Perhaps it would be worth thinking how to deal with this kind of "malformations" specially for merging pdfs.

I do appreciate your help and salute your efforts with PDFCPU.

Regards,

E

@hhrutter
Copy link
Collaborator

This is fixed in the latest commit by relaxing validation for Border arrays.

@ximbal
Copy link
Author

ximbal commented Sep 19, 2023

This is fixed in the latest commit by relaxing validation for Border arrays.

You're awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants