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

[api-minor] Add an IsLinearized property to the PDFDocument.documentInfo getter, to allow accessing the linearization status through the API (via PDFDocumentProxy.getMetadata) #9920

Merged
merged 4 commits into from
Jul 29, 2018

Conversation

Snuffleupagus
Copy link
Collaborator

Please refer to the individual commit messages for additional details.

@timvandermeij
Copy link
Contributor

Should we label this as [api-minor] because it's an addition?

@timvandermeij
Copy link
Contributor

/botio-windows preview

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_preview from @timvandermeij received. Current queue size: 0

Live output at: http://54.215.176.217:8877/9272b47df4e4376/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://54.215.176.217:8877/9272b47df4e4376/output.txt

Total script time: 4.77 mins

Published

@timvandermeij
Copy link
Contributor

timvandermeij commented Jul 24, 2018

For completeness I'm also providing the Dutch translations. If you would like to include them in this patch, please feel free to do so; hopefully it helps. Here they are:

document_properties_linearized=Snelle webweergave:
document_properties_linearized_yes=Ja
document_properties_linearized_no=Nee

@Snuffleupagus
Copy link
Collaborator Author

Snuffleupagus commented Jul 25, 2018

Should we label this as [api-minor] because it's an addition?

You're obviously correct (the change may be really small, but it's still adding "new" API functionality).

For completeness I'm also providing the Dutch translations.

Nice, thank you! I'll add those as well soon (and probably some kind of localization comment too).

…ion`

Note first of all that `PDFDocument` will be initialized with either a `Stream` or a `ChunkedStream`, and that both of these have `length` getters. Secondly, the `PDFDocument` constructor will assert that the `stream` has a non-zero (and positive) length. Hence there's no point in checking `stream.length` in the `linearization` getter.
With this file now being a proper (ES6) module, it's no longer (technically) necessary for this structure to be lazily initialized. Considering its size, and simplicity, I therefore cannot see the harm in letting `DocumentInfoValidators` just be simple Object instead.

While I'm not aware of any bugs caused by the current code, it cannot hurt to add an `isDict` check in `PDFDocument.documentInfo` (since the current code assumes that `infoDict` being defined implies it also being a Dictionary).

Finally, the patch also converts a couple of `var` to `let`/`const`.
…ntInfo` getter, to allow accessing the linearization status through the API (via `PDFDocumentProxy.getMetadata`)

There was a (somewhat) recent question on IRC about accessing the linearization status of a PDF document, and this patch contains a simple way to expose that through already existing API methods.
Please note that during setup/parsing in `PDFDocument` the linearization data is already being fetched and parsed, provided of course that it exists. Hence this patch will *not* cause any additional data to be loaded.
@Snuffleupagus Snuffleupagus force-pushed the getMetadata-linearization branch 3 times, most recently from ca49e08 to 1e7b6ab Compare July 26, 2018 15:04
This uses the same terminology, i.e. "Fast Web View", as is used by Adobe software.
@Snuffleupagus Snuffleupagus changed the title Add an IsLinearized property to the PDFDocument.documentInfo getter, to allow accessing the linearization status through the API (via PDFDocumentProxy.getMetadata) [api-minor] Add an IsLinearized property to the PDFDocument.documentInfo getter, to allow accessing the linearization status through the API (via PDFDocumentProxy.getMetadata) Jul 27, 2018
@Snuffleupagus
Copy link
Collaborator Author

/botio-windows test

@mozilla mozilla deleted a comment from pdfjsbot Jul 29, 2018
@mozilla mozilla deleted a comment from pdfjsbot Jul 29, 2018
@mozilla mozilla deleted a comment from pdfjsbot Jul 29, 2018
@mozilla mozilla deleted a comment from pdfjsbot Jul 29, 2018
@mozilla mozilla deleted a comment from pdfjsbot Jul 29, 2018
@mozilla mozilla deleted a comment from pdfjsbot Jul 29, 2018
@timvandermeij
Copy link
Contributor

/botio-linux preview

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_preview from @timvandermeij received. Current queue size: 0

Live output at: http://54.67.70.0:8877/5ef338543e524c3/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/5ef338543e524c3/output.txt

Total script time: 3.02 mins

Published

@timvandermeij
Copy link
Contributor

/botio test

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_test from @timvandermeij received. Current queue size: 0

Live output at: http://54.67.70.0:8877/287b24cca26b089/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_test from @timvandermeij received. Current queue size: 0

Live output at: http://54.215.176.217:8877/0470f2b8094b351/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/287b24cca26b089/output.txt

Total script time: 19.50 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: Passed

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://54.215.176.217:8877/0470f2b8094b351/output.txt

Total script time: 27.21 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: Passed

@timvandermeij timvandermeij merged commit 3521424 into mozilla:master Jul 29, 2018
@timvandermeij
Copy link
Contributor

I really like this feature. Nice work!

@Snuffleupagus Snuffleupagus deleted the getMetadata-linearization branch July 30, 2018 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants