A couple of small improvements of the PDFViewerApplication.{_initializeMetadata, _initializePdfHistory} methods

- Use template strings when printing document/viewer information in `_initializeMetadata`, since the old format feels overly verbose.
   Also, get the WebGL state from the `BaseViewer` instance[1] rather than the `AppOptions`. Since the `AppOptions` value could theoretically have been changed (by the user) after the viewer components were initialized, it seems much more useful to print the *actual* value that'll be used during rendering.

 - Change `_initializePdfHistory` to actually do the "is embedded"-check first, in accordance with the comment and given that the "disableHistory" option usually shouldn't be set.

---
[1] Admittedly reaching into the `BaseViewer` instance and just grabbing the value perhaps isn't a great approach overall, but given that the WebGL-backend isn't even on by default this probably doesn't matter too much.
This commit is contained in:
Jonas Jenwald 2020-04-05 11:15:21 +02:00
parent b9add65099
commit 9ef58347ed

View File

@ -1270,19 +1270,10 @@ const PDFViewerApplication = {
// Provides some basic debug information
console.log(
"PDF " +
pdfDocument.fingerprint +
" [" +
info.PDFFormatVersion +
" " +
(info.Producer || "-").trim() +
" / " +
(info.Creator || "-").trim() +
"]" +
" (PDF.js: " +
(version || "-") +
(AppOptions.get("enableWebGL") ? " [WebGL]" : "") +
")"
`PDF ${pdfDocument.fingerprint} [${info.PDFFormatVersion} ` +
`${(info.Producer || "-").trim()} / ${(info.Creator || "-").trim()}] ` +
`(PDF.js: ${version || "-"}` +
`${this.pdfViewer.enableWebGL ? " [WebGL]" : ""})`
);
let pdfTitle;
@ -1444,7 +1435,7 @@ const PDFViewerApplication = {
* @private
*/
_initializePdfHistory({ fingerprint, viewOnLoad, initialDest = null }) {
if (AppOptions.get("disableHistory") || this.isViewerEmbedded) {
if (this.isViewerEmbedded || AppOptions.get("disableHistory")) {
// The browsing history is only enabled when the viewer is standalone,
// i.e. not when it is embedded in a web page.
return;