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

validation: info dict: missing object #307

Closed
HuabeiYou opened this issue Mar 5, 2021 · 4 comments
Closed

validation: info dict: missing object #307

HuabeiYou opened this issue Mar 5, 2021 · 4 comments

Comments

@HuabeiYou
Copy link

Hi there,

I was trying to add watermarks on pdf files using api.AddTextWatermarksFile but got the error validation error: pdfcpu: validateString: missing object for some of them. It seems like the error is coming from pdfcpu/validate/info.go line 60 to 64: if xRefTable.ValidationModa == pdf.ValidationRelaxed { ... }.

I then tried the CLI mode.
validate -m relaxed F18E1000.pdf gives error:

validating(mode=relaxed) F18E1000.pdf ...
validation error: pdfcpu: validateString: missing object

However pdfcpu validate -m strict F18E1000.pdf worked

validating(mode=strict) F18E1000.pdf ...
validation ok

I attached the sample pdf below. Also, is there a way to change the validation mode and make api.AddTextWatermarksFile work?

Thanks!
F18E1000.pdf

@HuabeiYou
Copy link
Author

Hi there,

I was trying to add watermarks on pdf files using api.AddTextWatermarksFile but got the error validation error: pdfcpu: validateString: missing object for some of them. It seems like the error is coming from pdfcpu/validate/info.go line 60 to 64: if xRefTable.ValidationModa == pdf.ValidationRelaxed { ... }.

I then tried the CLI mode.
validate -m relaxed F18E1000.pdf gives error:

validating(mode=relaxed) F18E1000.pdf ...
validation error: pdfcpu: validateString: missing object

However pdfcpu validate -m strict F18E1000.pdf worked

validating(mode=strict) F18E1000.pdf ...
validation ok

I attached the sample pdf below. Also, is there a way to change the validation mode and make api.AddTextWatermarksFile work?

Thanks!
F18E1000.pdf

Update: Found out I can change the validation mode by passing in the Configuration, but it didn't solve my problem, here is the error:

  • Add text watermark using ValidationNone:
text: corrupt -  <<
	<BaseFont, Helvetica>
	<Encoding, WinAnsiEncoding>
	<Subtype, Type1>
	<Type, Font>
>>
  • Add text watermark using ValidationStrict:
dict=type1FontDict required entry=FirstChar missing

@hhrutter
Copy link
Collaborator

hhrutter commented Mar 5, 2021

OK, I shall check it out.
Thank you for reporting this 💚

PS: relaxed validation is the default for pdfcpu validate.

@hhrutter hhrutter changed the title validation error: pdfcpu: validateString: missing object validation: validateString: missing object Mar 5, 2021
@hhrutter
Copy link
Collaborator

hhrutter commented Mar 5, 2021

Looks like this file was created/modified on an Apple device (possibly Mac Preview) and then processed with "pdf-tools".
All info dict entries using indirect references point to empty objects:

175:   offset=  841786 generation=0 pdfcpu.Dict
<<
	<AAPL:Keywords, (180 0 R)>
	<CreationDate, (178 0 R)>
	<Creator, (177 0 R)>
	<Keywords, (179 0 R)>
	<ModDate, (D:20180922122321Z)>
	<Producer, (3-Heights\(TM\) PDF Security Shell 4.8.25.2 \(http://www.pdf-tools.com\) / pdcat \(www.pdf-tools.com\))>
	<Title, (176 0 R)>
>>
  176: f   next=     177 generation=0
  177: f   next=     178 generation=0
  178: f   next=     179 generation=0
  179: f   next=     180 generation=0

We are working on a fix.

Thank you for using pdfcpu 💚

@hhrutter hhrutter changed the title validation: validateString: missing object validation: info dict: missing object Mar 5, 2021
@hhrutter
Copy link
Collaborator

hhrutter commented Mar 7, 2021

Fixed with latest commit.

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

No branches or pull requests

2 participants