1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 10:08:06 +02:00

Add support for the /Catalog Base-URI when resolving URLs (issue 14802)

As far as I can tell, this is actually the very first time that we've seen a PDF document with a Base-URI specified in the /Catalog; please refer to the specification:
https://web.archive.org/web/20220309040754if_/https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf#G11.2097122

To simplify the overall implementation, this new parameter is accessed via the existing `BasePdfManager.docBaseUrl`-getter and will thus override any user-specified `docBaseUrl` API-parameter.
This commit is contained in:
Jonas Jenwald 2022-04-19 16:53:44 +02:00
parent 32ae0e4867
commit 5bc7339c1b
6 changed files with 126 additions and 5 deletions

View file

@ -13,7 +13,12 @@
* limitations under the License.
*/
import { createValidAbsoluteUrl, unreachable, warn } from "../shared/util.js";
import {
createValidAbsoluteUrl,
shadow,
unreachable,
warn,
} from "../shared/util.js";
import { ChunkedStreamManager } from "./chunked_stream.js";
import { MissingDataException } from "./core_utils.js";
import { PDFDocument } from "./document.js";
@ -46,7 +51,8 @@ class BasePdfManager {
}
get docBaseUrl() {
return this._docBaseUrl;
const catalog = this.pdfDocument.catalog;
return shadow(this, "docBaseUrl", catalog.baseUrl || this._docBaseUrl);
}
onLoadedStream() {