-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
JS -- Implement doc object #12582
JS -- Implement doc object #12582
Conversation
calixteman
commented
Nov 5, 2020
- https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/js_api_reference.pdf#page=335
- it has all the properties/methods defined in the spec
- unimplemented methods are there but with an empty body to avoid exception when calling an undefined method
- implement zoom, zoomType, layout, pageNum, ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More generally, do we actually need to run this._initializeJavaScript(pdfDocument);
as early as is done currently?
Is it absolutely impossible for things to work correctly if we e.g. waited for onePageRendered
, as we do for a number of other API-calls, to prevent them running very early and thus possibly delay initial rendering?
For example: If you're able to delay this._initializeJavaScript(pdfDocument);
slightly you'd not need to re-fetch the "metadata" again and could instead use the already cached data.
Good point, as far as I understand the specs, there is nothing which indicates that some actions must be ran before rendering (some of them must ran on "Page open" or "Document open" events). Line 1330 in 8b652d6
|
That's most definitely the preferred solution here, assuming if works of course :-) |
web/app.js
Outdated
case "print": | ||
this.triggerPrinting(); | ||
return; | ||
case "zoom": | ||
if (typeof detail.value === "string") { | ||
this.pdfViewer.currentScaleValue = detail.value; | ||
} else { | ||
this.pdfViewer.currentScale = detail.value; | ||
} | ||
return; | ||
case "layout": | ||
this.pdfViewer.spreadMode = apiPageLayoutToSpreadMode(detail.value); | ||
return; | ||
case "page-num": | ||
this.pdfViewer.currentPageNumber = detail.value + 1; | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make sure that you sort all of these case
s alphabetically, since that will make it much easier to find things as the number of cases grow.
web/app.js
Outdated
docInfo: { | ||
...info, | ||
metadata, | ||
filesize: this.pdfDocumentProperties.maybeFileSize, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This property is first of all not guaranteed to even be set at this point in time and/or it may not actually be correct. Secondly, it's not really correct to reach into that component in this way, since that property was never intended to be "public" in the first place.
Looks like a good starting point. Now that we are interacting with the viewer I'd really like to see some tests when we have quickjs wired up. |
* https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/js_api_reference.pdf#page=335 * it has all the properties/methods defined in the spec * unimplemented methods are there but with an empty body to avoid exception when calling an undefined method * implement zoom, zoomType, layout, pageNum, ...