13
13
* limitations under the License.
14
14
*/
15
15
16
- import {
17
- createPromiseCapability ,
18
- getPdfFilenameFromUrl ,
19
- PDFDateString ,
20
- } from "pdfjs-lib" ;
16
+ import { createPromiseCapability , PDFDateString } from "pdfjs-lib" ;
21
17
import { getPageSizeInches , isPortraitOrientation } from "./ui_utils.js" ;
22
18
23
19
const DEFAULT_FIELD_CONTENT = "-" ;
@@ -58,12 +54,21 @@ class PDFDocumentProperties {
58
54
* @param {OverlayManager } overlayManager - Manager for the viewer overlays.
59
55
* @param {EventBus } eventBus - The application event bus.
60
56
* @param {IL10n } l10n - Localization service.
57
+ * @param {function } fileNameLookup - The function that is used to lookup
58
+ * the document fileName.
61
59
*/
62
- constructor ( { dialog, fields, closeButton } , overlayManager , eventBus , l10n ) {
60
+ constructor (
61
+ { dialog, fields, closeButton } ,
62
+ overlayManager ,
63
+ eventBus ,
64
+ l10n ,
65
+ fileNameLookup
66
+ ) {
63
67
this . dialog = dialog ;
64
68
this . fields = fields ;
65
69
this . overlayManager = overlayManager ;
66
70
this . l10n = l10n ;
71
+ this . _fileNameLookup = fileNameLookup ;
67
72
68
73
this . #reset( ) ;
69
74
// Bind the event listener for the Close button.
@@ -110,7 +115,7 @@ class PDFDocumentProperties {
110
115
const {
111
116
info,
112
117
/* metadata, */
113
- contentDispositionFilename,
118
+ /* contentDispositionFilename, */
114
119
contentLength,
115
120
} = await this . pdfDocument . getMetadata ( ) ;
116
121
@@ -122,7 +127,7 @@ class PDFDocumentProperties {
122
127
pageSize ,
123
128
isLinearized ,
124
129
] = await Promise . all ( [
125
- contentDispositionFilename || getPdfFilenameFromUrl ( this . url ) ,
130
+ this . _fileNameLookup ( ) ,
126
131
this . #parseFileSize( contentLength ) ,
127
132
this . #parseDate( info . CreationDate ) ,
128
133
this . #parseDate( info . ModDate ) ,
@@ -173,15 +178,13 @@ class PDFDocumentProperties {
173
178
}
174
179
175
180
/**
176
- * Set a reference to the PDF document and the URL in order
177
- * to populate the overlay fields with the document properties.
178
- * Note that the overlay will contain no information if this method
179
- * is not called.
181
+ * Set a reference to the PDF document in order to populate the dialog fields
182
+ * with the document properties. Note that the dialog will contain no
183
+ * information if this method is not called.
180
184
*
181
185
* @param {PDFDocumentProxy } pdfDocument - A reference to the PDF document.
182
- * @param {string } url - The URL of the document.
183
186
*/
184
- setDocument ( pdfDocument , url = null ) {
187
+ setDocument ( pdfDocument ) {
185
188
if ( this . pdfDocument ) {
186
189
this . #reset( ) ;
187
190
this . #updateUI( true ) ;
@@ -190,14 +193,12 @@ class PDFDocumentProperties {
190
193
return ;
191
194
}
192
195
this . pdfDocument = pdfDocument ;
193
- this . url = url ;
194
196
195
197
this . _dataAvailableCapability . resolve ( ) ;
196
198
}
197
199
198
200
#reset( ) {
199
201
this . pdfDocument = null ;
200
- this . url = null ;
201
202
202
203
this . #fieldData = null ;
203
204
this . _dataAvailableCapability = createPromiseCapability ( ) ;
0 commit comments