Address the final round of review comments for Content-Disposition filename extraction

This patch updates the `IPDFStreamReader` interface and ensures that the interface/implementation of `network.js`, `fetch_stream.js`, `node_stream.js`, and `transport_stream.js` all match properly.
The unit-tests are also adjusted, to more closely replicate the actual behaviour of the various actual `IPDFStreamReader` implementations.
Finally, this patch adjusts the use of the Content-Disposition filename when setting the title in the viewer, and adds `PDFDocumentProperties` support as well.
This commit is contained in:
Jonas Jenwald 2018-01-16 16:24:36 +01:00
parent eb1f6f4c24
commit 69a8336cf1
12 changed files with 151 additions and 121 deletions

View file

@ -71,24 +71,26 @@ class PDFDocumentProperties {
return;
}
// Get the document properties.
this.pdfDocument.getMetadata().then(({ info, metadata, }) => {
this.pdfDocument.getMetadata().then(
({ info, metadata, contentDispositionFilename, }) => {
return Promise.all([
info,
metadata,
contentDispositionFilename || getPDFFileNameFromURL(this.url),
this._parseFileSize(this.maybeFileSize),
this._parseDate(info.CreationDate),
this._parseDate(info.ModDate)
]);
}).then(([info, metadata, fileSize, creationDate, modificationDate]) => {
}).then(([info, metadata, fileName, fileSize, creationDate, modDate]) => {
freezeFieldData({
'fileName': getPDFFileNameFromURL(this.url),
'fileName': fileName,
'fileSize': fileSize,
'title': info.Title,
'author': info.Author,
'subject': info.Subject,
'keywords': info.Keywords,
'creationDate': creationDate,
'modificationDate': modificationDate,
'modificationDate': modDate,
'creator': info.Creator,
'producer': info.Producer,
'version': info.PDFFormatVersion,