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

FindTrueHeaderPosition: Determine header offset to locate XREF entries. #11

Merged
merged 2 commits into from
Jul 25, 2023

Conversation

DW715
Copy link
Collaborator

@DW715 DW715 commented Jul 24, 2023

Third-party tools can write blocks before the header block of the PDF, this causes validation to fail as the version number cannot be read. FindTrueHeaderPosition() determines the header offset whose value is used to locate XREF entries.

…, this casuses validation to fail as the version number cannot be read. FindTrueHeaderPosition() determines the header offset whose value is used to locate XREF entries.
@Numpsy
Copy link
Member

Numpsy commented Jul 24, 2023

Can the 'stuff' that gets written before the PDF Version header contain '%' (or text which looks like the PDF marer but isn't?)

@DW715
Copy link
Collaborator Author

DW715 commented Jul 25, 2023

Can the 'stuff' that gets written before the PDF Version header contain '%' (or text which looks like the PDF marer but isn't?)

I suppose it might, if it did I don't think you could ever find the 'real' header without validating the whole XREF table for every possible match?

@Numpsy
Copy link
Member

Numpsy commented Jul 25, 2023

The PdfPig equivalent (https://github.com/UglyToad/PdfPig/blob/8a82500427ace6d4dcb1b2ea7cb3fdb5e32c765d/src/UglyToad.PdfPig/Parser/FileStructure/FileHeaderParser.cs#L94) appears to be searching for the whole %PDF- bit and then checking for that being followed by a version number - is it possible to do at least part of that or is it too big of a change here?

@DW715
Copy link
Collaborator Author

DW715 commented Jul 25, 2023

is it possible to do at least part of that or is it too big of a change here?

I'll have a look, was trying to keep all changes to a minimum.

@DW715
Copy link
Collaborator Author

DW715 commented Jul 25, 2023

@Numpsy done.

@Numpsy Numpsy merged commit 139394c into BoldonJames:master Jul 25, 2023
1 check passed
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

Successfully merging this pull request may close these issues.

3 participants