Merge pull request #14114 from Snuffleupagus/issue-14110
[api-minor] Include the /Lang-property in the `documentInfo`, and use it in the viewer (issue 14110)
This commit is contained in:
commit
b66239d6dc
@ -89,6 +89,15 @@ class Catalog {
|
||||
);
|
||||
}
|
||||
|
||||
get lang() {
|
||||
const lang = this._catDict.get("Lang");
|
||||
return shadow(
|
||||
this,
|
||||
"lang",
|
||||
typeof lang === "string" ? stringToPDFString(lang) : null
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {boolean} `true` for pure XFA documents,
|
||||
* `false` for XFA Foreground documents.
|
||||
|
@ -1160,6 +1160,7 @@ class PDFDocument {
|
||||
|
||||
const docInfo = {
|
||||
PDFFormatVersion: version,
|
||||
Language: this.catalog.lang,
|
||||
IsLinearized: !!this.linearization,
|
||||
IsAcroFormPresent: this.formInfo.hasAcroForm,
|
||||
IsXFAPresent: this.formInfo.hasXfa,
|
||||
|
@ -1165,6 +1165,7 @@ describe("api", function () {
|
||||
expect(info.Custom).toEqual(undefined);
|
||||
// The following are PDF.js specific, non-standard, properties.
|
||||
expect(info.PDFFormatVersion).toEqual("1.7");
|
||||
expect(info.Language).toEqual("en");
|
||||
expect(info.IsLinearized).toEqual(false);
|
||||
expect(info.IsAcroFormPresent).toEqual(false);
|
||||
expect(info.IsXFAPresent).toEqual(false);
|
||||
@ -1199,6 +1200,7 @@ describe("api", function () {
|
||||
);
|
||||
// The following are PDF.js specific, non-standard, properties.
|
||||
expect(info.PDFFormatVersion).toEqual("1.4");
|
||||
expect(info.Language).toEqual(null);
|
||||
expect(info.IsLinearized).toEqual(false);
|
||||
expect(info.IsAcroFormPresent).toEqual(false);
|
||||
expect(info.IsXFAPresent).toEqual(false);
|
||||
@ -1220,6 +1222,7 @@ describe("api", function () {
|
||||
|
||||
// The following are PDF.js specific, non-standard, properties.
|
||||
expect(info.PDFFormatVersion).toEqual(null);
|
||||
expect(info.Language).toEqual(null);
|
||||
expect(info.IsLinearized).toEqual(false);
|
||||
expect(info.IsAcroFormPresent).toEqual(false);
|
||||
expect(info.IsXFAPresent).toEqual(false);
|
||||
|
@ -812,6 +812,7 @@ const PDFViewerApplication = {
|
||||
const { container } = this.appConfig.errorWrapper;
|
||||
container.hidden = true;
|
||||
}
|
||||
this.appConfig.viewerContainer.removeAttribute("lang");
|
||||
|
||||
if (!this.pdfLoadingTask) {
|
||||
return;
|
||||
@ -1536,6 +1537,9 @@ const PDFViewerApplication = {
|
||||
`(PDF.js: ${version || "-"})`
|
||||
);
|
||||
|
||||
if (info.Language) {
|
||||
this.appConfig.viewerContainer.lang = info.Language;
|
||||
}
|
||||
let pdfTitle = info?.Title;
|
||||
|
||||
const metadataTitle = metadata?.get("dc:title");
|
||||
|
Loading…
x
Reference in New Issue
Block a user