mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-21 15:48:06 +02:00
Merge pull request #6988 from timvandermeij/fileattachment-annotation
Implement support for FileAttachment annotations
This commit is contained in:
commit
41efb92d3a
19 changed files with 222 additions and 34 deletions
|
@ -72,6 +72,7 @@
|
|||
.annotationLayer .highlightAnnotation,
|
||||
.annotationLayer .underlineAnnotation,
|
||||
.annotationLayer .squigglyAnnotation,
|
||||
.annotationLayer .strikeoutAnnotation {
|
||||
.annotationLayer .strikeoutAnnotation,
|
||||
.annotationLayer .fileAttachmentAnnotation {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
* @property {HTMLDivElement} pageDiv
|
||||
* @property {PDFPage} pdfPage
|
||||
* @property {IPDFLinkService} linkService
|
||||
* @property {DownloadManager} downloadManager
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -35,6 +36,7 @@ var AnnotationLayerBuilder = (function AnnotationLayerBuilderClosure() {
|
|||
this.pageDiv = options.pageDiv;
|
||||
this.pdfPage = options.pdfPage;
|
||||
this.linkService = options.linkService;
|
||||
this.downloadManager = options.downloadManager;
|
||||
|
||||
this.div = null;
|
||||
}
|
||||
|
@ -59,7 +61,8 @@ var AnnotationLayerBuilder = (function AnnotationLayerBuilderClosure() {
|
|||
div: self.div,
|
||||
annotations: annotations,
|
||||
page: self.pdfPage,
|
||||
linkService: self.linkService
|
||||
linkService: self.linkService,
|
||||
downloadManager: self.downloadManager
|
||||
};
|
||||
|
||||
if (self.div) {
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/* globals getFileName, PDFJS */
|
||||
/* globals PDFJS */
|
||||
|
||||
'use strict';
|
||||
|
||||
|
@ -84,7 +84,7 @@ var PDFAttachmentView = (function PDFAttachmentViewClosure() {
|
|||
|
||||
for (var i = 0; i < attachmentsCount; i++) {
|
||||
var item = attachments[names[i]];
|
||||
var filename = getFileName(item.filename);
|
||||
var filename = PDFJS.getFilenameFromUrl(item.filename);
|
||||
var div = document.createElement('div');
|
||||
div.className = 'attachmentsItem';
|
||||
var button = document.createElement('button');
|
||||
|
|
|
@ -13,8 +13,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
/* globals RenderingStates, PDFJS, DEFAULT_SCALE, CSS_UNITS, getOutputScale,
|
||||
TextLayerBuilder, AnnotationLayerBuilder, Promise,
|
||||
approximateFraction, roundToDivide */
|
||||
TextLayerBuilder, Promise, approximateFraction, roundToDivide */
|
||||
|
||||
'use strict';
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
/*jshint globalstrict: false */
|
||||
/* globals PDFJS, PDFViewer, PDFPageView, TextLayerBuilder, PDFLinkService,
|
||||
DefaultTextLayerFactory, AnnotationLayerBuilder, PDFHistory,
|
||||
DefaultAnnotationLayerFactory, getFileName, ProgressBar */
|
||||
DefaultAnnotationLayerFactory, DownloadManager, ProgressBar */
|
||||
|
||||
// Initializing PDFJS global object (if still undefined)
|
||||
if (typeof PDFJS === 'undefined') {
|
||||
|
@ -29,6 +29,7 @@ if (typeof PDFJS === 'undefined') {
|
|||
//#include pdf_link_service.js
|
||||
//#include pdf_viewer.js
|
||||
//#include pdf_history.js
|
||||
//#include download_manager.js
|
||||
|
||||
PDFJS.PDFViewer = PDFViewer;
|
||||
PDFJS.PDFPageView = PDFPageView;
|
||||
|
@ -39,6 +40,6 @@ if (typeof PDFJS === 'undefined') {
|
|||
PDFJS.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory;
|
||||
PDFJS.PDFHistory = PDFHistory;
|
||||
|
||||
PDFJS.getFileName = getFileName;
|
||||
PDFJS.DownloadManager = DownloadManager;
|
||||
PDFJS.ProgressBar = ProgressBar;
|
||||
}).call((typeof window === 'undefined') ? this : window);
|
||||
|
|
|
@ -40,6 +40,8 @@ var DEFAULT_CACHE_SIZE = 10;
|
|||
* @property {HTMLDivElement} container - The container for the viewer element.
|
||||
* @property {HTMLDivElement} viewer - (optional) The viewer element.
|
||||
* @property {IPDFLinkService} linkService - The navigation/linking service.
|
||||
* @property {DownloadManager} downloadManager - (optional) The download
|
||||
* manager component.
|
||||
* @property {PDFRenderingQueue} renderingQueue - (optional) The rendering
|
||||
* queue object.
|
||||
* @property {boolean} removePageBorders - (optional) Removes the border shadow
|
||||
|
@ -92,6 +94,7 @@ var PDFViewer = (function pdfViewer() {
|
|||
this.container = options.container;
|
||||
this.viewer = options.viewer || options.container.firstElementChild;
|
||||
this.linkService = options.linkService || new SimpleLinkService();
|
||||
this.downloadManager = options.downloadManager || null;
|
||||
this.removePageBorders = options.removePageBorders || false;
|
||||
|
||||
this.defaultRenderingQueue = !options.renderingQueue;
|
||||
|
@ -757,7 +760,8 @@ var PDFViewer = (function pdfViewer() {
|
|||
return new AnnotationLayerBuilder({
|
||||
pageDiv: pageDiv,
|
||||
pdfPage: pdfPage,
|
||||
linkService: this.linkService
|
||||
linkService: this.linkService,
|
||||
downloadManager: this.downloadManager
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
@ -23,15 +23,6 @@ var MAX_AUTO_SCALE = 1.25;
|
|||
var SCROLLBAR_PADDING = 40;
|
||||
var VERTICAL_PADDING = 5;
|
||||
|
||||
function getFileName(url) {
|
||||
var anchor = url.indexOf('#');
|
||||
var query = url.indexOf('?');
|
||||
var end = Math.min(
|
||||
anchor > 0 ? anchor : url.length,
|
||||
query > 0 ? query : url.length);
|
||||
return url.substring(url.lastIndexOf('/', end) + 1, end);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns scale factor for the canvas. It makes sense for the HiDPI displays.
|
||||
* @return {Object} The object with horizontal (sx) and vertical (sy)
|
||||
|
|
|
@ -12,15 +12,15 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/* globals PDFJS, PDFBug, FirefoxCom, Stats, ProgressBar,
|
||||
DownloadManager, getFileName, getPDFFileNameFromURL,
|
||||
PDFHistory, Preferences, SidebarView, ViewHistory, Stats,
|
||||
PDFThumbnailViewer, URL, noContextMenuHandler, SecondaryToolbar,
|
||||
PasswordPrompt, PDFPresentationMode, PDFDocumentProperties, HandTool,
|
||||
Promise, PDFLinkService, PDFOutlineView, PDFAttachmentView,
|
||||
OverlayManager, PDFFindController, PDFFindBar, PDFViewer,
|
||||
PDFRenderingQueue, PresentationModeState, parseQueryString,
|
||||
RenderingStates, UNKNOWN_SCALE, DEFAULT_SCALE_VALUE,
|
||||
/* globals PDFJS, PDFBug, FirefoxCom, Stats, ProgressBar, DownloadManager,
|
||||
getPDFFileNameFromURL, PDFHistory, Preferences, SidebarView,
|
||||
ViewHistory, Stats, PDFThumbnailViewer, URL, noContextMenuHandler,
|
||||
SecondaryToolbar, PasswordPrompt, PDFPresentationMode,
|
||||
PDFDocumentProperties, HandTool, Promise, PDFLinkService,
|
||||
PDFOutlineView, PDFAttachmentView, OverlayManager,
|
||||
PDFFindController, PDFFindBar, PDFViewer, PDFRenderingQueue,
|
||||
PresentationModeState, parseQueryString, RenderingStates,
|
||||
UNKNOWN_SCALE, DEFAULT_SCALE_VALUE,
|
||||
IGNORE_CURRENT_POSITION_ON_ZOOM: true */
|
||||
|
||||
'use strict';
|
||||
|
@ -134,7 +134,8 @@ var PDFViewerApplication = {
|
|||
container: container,
|
||||
viewer: viewer,
|
||||
renderingQueue: pdfRenderingQueue,
|
||||
linkService: pdfLinkService
|
||||
linkService: pdfLinkService,
|
||||
downloadManager: new DownloadManager()
|
||||
});
|
||||
pdfRenderingQueue.setViewer(this.pdfViewer);
|
||||
pdfLinkService.setViewer(this.pdfViewer);
|
||||
|
@ -485,7 +486,7 @@ var PDFViewerApplication = {
|
|||
setTitleUsingUrl: function pdfViewSetTitleUsingUrl(url) {
|
||||
this.url = url;
|
||||
try {
|
||||
this.setTitle(decodeURIComponent(getFileName(url)) || url);
|
||||
this.setTitle(decodeURIComponent(PDFJS.getFilenameFromUrl(url)) || url);
|
||||
} catch (e) {
|
||||
// decodeURIComponent may throw URIError,
|
||||
// fall back to using the unprocessed url in that case
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue