[api-minor] Add "contentLength" to the information returned by the getMetadata method

Given that we already include the "Content-Disposition"-header filename, when it exists, it shouldn't hurt to also include the information from the "Content-Length"-header.
For PDF documents opened via a URL, which should be a very common way for the PDF.js library to be used, this will[1] thus provide a way of getting the PDF filesize without having to wait for the `getDownloadInfo`-promise to resolve[2].

With these API improvements, we can also simplify the filesize handling in the `PDFDocumentProperties` class.

---
[1] Assuming that the server is correctly configured, of course.

[2] Since that's not *guaranteed* to happen in general, with e.g. `disableAutoFetch = true` set.
This commit is contained in:
Jonas Jenwald 2020-11-20 14:17:23 +01:00
parent c88e805870
commit 01d12b465c
4 changed files with 49 additions and 51 deletions

View file

@ -863,15 +863,10 @@ const PDFViewerApplication = {
}
parameters[key] = value;
}
// Finally, update the API parameters with the arguments (if they exist).
if (args) {
for (const key in args) {
const value = args[key];
if (key === "length") {
this.pdfDocumentProperties.setFileSize(value);
}
parameters[key] = value;
parameters[key] = args[key];
}
}