Commit Graph

204 Commits

Author SHA1 Message Date
Yury Delendik
4165cedc9f Replace pdfjsLib with module that represents pdf.js. 2016-04-13 10:11:34 -05:00
Yury Delendik
006e8fb59d Introduces UMD headers to the web/ folder. 2016-04-13 10:09:48 -05:00
Yury Delendik
1e3e14e6b2 Exposes all functional members via lib exports and use them in viewer. 2016-04-07 13:46:07 -05:00
Tim van der Meij
6a33dfd13a Implement support for FileAttachment annotations 2016-02-23 22:49:53 +01:00
Jonas Jenwald
3079dd937f Remove a superfluous "s" in AnnotationsLayerBuilder from files in web/
This patch makes the naming consistent with the `TextLayerBuilder`, and also the new `AnnotationLayer`, and should thus help reduce possible confusion when working with the code.
Please note that the files were renamed using `git mv`, in order to preserve blame.
2015-12-18 19:55:54 +01:00
Jonas Jenwald
6dfe53b976 [api-minor] Add a parameter to PDFPageProxy_getTextContent that enables replacing of all whitespace with standard spaces in the textLayer (issue 6612)
This patch goes a bit further than issue 6612 requires, and replaces all kinds of whitespace with standard spaces.

When testing this locally, it actually seemed to slightly improve two existing test-cases (`tracemonkey-text` and `taro-text`).

Fixes 6612.
2015-11-25 17:28:40 +01:00
Yury Delendik
99f9b523c2 Merge pull request #6627 from prometheansacrifice/use-editorconfig
Uses editorconfig to maintain consistent coding styles
2015-11-16 13:51:45 -06:00
Manas
a2ba1b8189 Uses editorconfig to maintain consistent coding styles
Removes the following as they unnecessary
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
2015-11-14 07:32:18 +05:30
Tony Jin
570f144fc3 Fix minor capitalization issue in viewer 2015-11-12 13:33:34 -08:00
Jonas Jenwald
e629882f2a Correctly handle /FitH destinations with null as the parameter
According to http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G11.2095870, the vertical position shouldn't change if the parameter is `null`.

Fixes 6615.
2015-11-10 14:22:24 +01:00
Xiliang Chen
a059f9fcbb Fix exception when rotate page without a document 2015-09-14 10:42:53 +12:00
Jonas Jenwald
93d82e21d5 Move handling of the 'custom' scale value from pdf_viewer.js to viewer.js
The special handling of the 'custom' scale value is only relevant for the `scaleSelect` dropdown in the standard viewer, hence I think that it should be placed in `viewer.js` instead.
2015-07-19 20:02:47 +02:00
Tim van der Meij
b35cbaa32c Merge pull request #6157 from Snuffleupagus/components-update-on-setScale-and-pagesRotation
Make sure that the document is rendered on zooming and rotation for `PDFViewer` instances using the `defaultRenderingQueue`
2015-07-16 23:06:32 +02:00
Tim van der Meij
535b7c236e Merge pull request #6110 from Snuffleupagus/issue-6056
Refactor viewer code to fix issues with the "pageviewer" components example (issue 6056)
2015-07-12 16:02:37 +02:00
Jonas Jenwald
d0c071a40d Prevent re-rendering of pages because of rounding errors when computing the scale value
Currently if the zoom level is reset multiple times in a row, i.e. by pressing <kbd>Ctrl</kbd>+<kbd>0</kbd>, the pages can be re-rendered each time even though their size shouldn't change. Whether this happens can depend on the size of the viewer, but documents with pages in landscape mode seem to be very susceptible to this. (An example is: https://wiki.mozilla.org/images/5/55/MobileOpportunity.pdf.)
This can also effect documents with pages in portrait mode, when they are displayed in Presentation Mode.

The reason for this unnecessary re-rendering is that due to limited numerical precision, the new scale value may change in *only* the last decimal place.
2015-07-06 17:22:03 +02:00
Jonas Jenwald
4364b37e55 Simplify the SimpleLinkService and use it to pass in a linkService instance in DefaultAnnotationsLayerFactory
Considering that most methods of `SimpleLinkService` are complete stubs, or practically "useless" considering what they return, we can actually simplify it even more.

*Note:* This depends on the previous patch, that did a small amount of refactoring of `PDFViewer_scrollPageIntoView`, since `PDFViewer.linkService.page` is no longer accessed.

----------

Currently the `pageviewer` components example doesn't work correctly (an error is printed in the console), since no `linkService` is present when the `AnnotationsLayerBuilder` is created.

*Note:* Given that this uses the `SimpleLinkService`, clicking on e.g. internal links won't actually do anything. However, given that internal links (and similar features) are pretty much useless when only *one* page is loaded the `pageviewer` example, I don't think that really matters.
Also, using the complete `PDFLinkService` would require a `PDFViewer` instance. That would significantly complicate the example, thus making it both less clear and less self contained.
2015-07-06 16:34:55 +02:00
Jonas Jenwald
ac3233bfa4 Use "private" properties in PDFViewer_scrollPageIntoView
Currently in `PDFViewer_scrollPageIntoView`, we're accessing a number of properties in an indirect and overly complicated way. In particular, using `this.linkService.page` is a *very* roundabout way to access `this.currentPageNumber`.

The reason for this appears to be entirely historical, since prior to PR 5361 the code was placed in `PDFPageView` (or `PageView` as it was called at the time).
2015-07-06 16:33:01 +02:00
Yury Delendik
1b847df2f3 Using pdfjs-dist as a library for b2g viewer. 2015-06-30 16:53:32 -05:00
Jonas Jenwald
d940078d95 Make sure that the document is rendered on zooming and rotation for PDFViewer instances using the defaultRenderingQueue
In `viewer.js` we have code that ensures that the document is re-rendered on zooming and rotation. However, for `components` based viewers this might not work correctly, since there's currently no code which handles that.

Note that there is a good chance that this "just works" in many `components` viewers already, thanks to the `watchScroll` function.
The explanation is that zooming or rotation, most of the time, causes the viewer to change its (scrollable) size, thus triggering `PDFViewer_update` through `PDFViewer_scrollUpdate`.

However, in general there's no guarantee that this will actually work (since zooming and rotation doesn't necessarily change the size of the viewer for all documents), and requiring every viewer `components` implementer to provide methods for this doesn't seem like a great idea.
2015-06-30 23:09:17 +02:00
Jonas Jenwald
ffeba9c630 Move the page switching code into set currentPageNumber in PDFViewer instead of placing it in the pagechange event handler
The reason that this code can be moved is that the `if (this.loading && page === 1)` check, in the `pagechange` event handler in viewer.js, is never satisfied since `this.loading` is not defined in that scope.
This *could* be considered a regression from PR 5295, since prior to that `this.loading` was using the `PDFViewerApplication` scope (or `PDFView` as it were).
However, I don't think that we need to fix that since we've been shipping this code in no less than *three* Firefox releases (uplifted in https://bugzilla.mozilla.org/show_bug.cgi?id=1084158), without breaking the world.

An explanation of why the `pagechange` code works, despite `this.loading === undefined`, is that `set currentPageNumber` (in `PDFViewer`) returns early whenever `this.pdfDocument` isn't set. This check is, for all intents and purposes, functionally equivalent to checking `PDFViewerApplication.loading`.
Hence we can move the page switching code into `PDFViewer`, and also remove `PDFViewerApplication.loading` since it's not used any more.
(The `this.loading` property was added in PR 686, which was before the current viewer even existed.)

*Note:* The changes in this patch should also be beneficial to the viewer `components`, since requiring every implementer to provide their own `pagechange` event handler just to get `PDFViewer.currentPageNumber` to actually work seems like an unnecessary complication.
2015-06-24 14:07:07 +02:00
Yury Delendik
0ef6212b64 Refactors PDFLinkService.
# Conflicts:
#	web/viewer.js
2015-05-16 11:20:36 -05:00
Tim van der Meij
39d5031832 Merge pull request #5989 from Snuffleupagus/updateviewarea-location
Add the |location| to the |updateviewarea| UI event
2015-05-14 13:14:34 +02:00
Yury Delendik
00f3756d02 Merge pull request #5867 from Snuffleupagus/pdfViewer-pages-private
Change |pages| to be a "private" property of |PDFViewer|
2015-05-11 12:33:59 -05:00
Jonas Jenwald
ba0eb7fdc6 Add the |location| to the |updateviewarea| UI event
*This patch addresses an issue I stumbled upon while working on rewriting the history implementation.*

Currently the `updateviewarea` UI event doesn't include the `location`, and in the event handler in viewer.js we instead reach into `PDFViewer` to retrieve it. Not only does this seem conceptually wrong, it also makes the `updateviewarea` event less useful in general since it's currently only possible to access the `location` if you have a reference to the `PDFViewer`.

To me, this simply appears to be an oversight in the implementation, hence this patch which adds `location` to the `updateviewarea` event. It also changes `location` to be a "private" property of `PDFViewer`.
2015-05-08 12:15:50 +02:00
Jonas Jenwald
b1c4b85d4f Change |pages| to be a "private" property of |PDFViewer|
As suggested by yurydelendik: http://logs.glob.uno/?c=mozilla%23pdfjs&s=30+Sep+2014&e=30+Sep+2014&h=4150#c26119, this patch renames `pages` -> `_pages` to indicate that it's a "private" property.
Accessing pages from outside `PDFViewer` should instead be done by using `getPageView`.
2015-04-21 22:40:11 +02:00
Jonas Jenwald
10f134bcc2 Remove no longer needed hacks that enable spacebar scrolling in Firefox (issue 3498)
Now that [bug 915962](https://bugzilla.mozilla.org/show_bug.cgi?id=915962) has landed, we no longer need any hacks to enable <kbd>spacebar</kbd> scrolling in Firefox.

Fixes 3498.
2015-04-21 22:26:50 +02:00
Jonas Jenwald
2dc1af8028 Break dependencies between PresentationMode and other code, and add PresentationMode related utility methods to PDFViewer
This patch:
 - Adds a couple of utility methods to `PDFViewer` to enable checking `presentationModeState` without cumbersome comparisons.

 - Disentangles `PresentationMode` from `PDFHistory` and `HandTool`, by adding event listeners for `presentationmodechanged` to both of them.

 - Adds a utility function to `PDFViewerApplication` for requesting PresentationMode.

 - Prevents initialization of `PresentationMode` if the browser does not support the fullscreen API.
2015-04-21 16:02:32 +02:00
Jonas Jenwald
4a3b0d9c64 Add a |PDFViewer| option to remove the border shadow around pages (issue 5559) 2015-03-16 12:28:28 +01:00
Yury Delendik
a0a94344d7 Merge pull request #5721 from Snuffleupagus/move-findController-resolveFirstPage
Move the call to |PDFFindController.resolveFirstPage| into PDFViewer
2015-02-27 06:33:15 -06:00
Jonas Jenwald
a495ab0d13 Fix regression that prevents resetting the zoom level to "Automatic" when using the |Ctrl + 0| keys 2015-02-19 17:37:02 +01:00
Jonas Jenwald
8131440f9e Move the call to |PDFFindController.resolveFirstPage| into PDFViewer
From reading IRC scrollback, it became clear that having to manually call `PDFFindController.resolveFirstPage` in order for the find functionality to work isn't particulary good. Hence this PR, which moves that code into `PDFViewer.setDocument` to make life easier for third-party implementations.
2015-02-11 14:22:24 +01:00
Jonas Jenwald
95dd9ee185 Move the |pagerendered| event to pdf_page_view.js
Also deprecates the |pagerender| event, except for GENERIC builds.
2015-01-06 21:44:22 +01:00
Yury Delendik
2ac7ac4678 Removes lastScrollSource and isViewerInPresentationMode from TextLayerBuilderOptions 2014-12-20 11:14:13 -06:00
Yury Delendik
b930228788 Refactors Cache into PDFPageViewBuffer 2014-12-19 16:54:32 -06:00
Yury Delendik
22c62685b0 Removes Stats dependency from PDFPageView. 2014-12-19 13:07:28 -06:00
Yury Delendik
9f384bbb41 Creates AnnotationsLayerBuilder. 2014-12-19 13:07:28 -06:00
Yury Delendik
fe4ac86781 Removes PDFPageSource 2014-12-19 09:55:11 -06:00
Yury Delendik
7663942ee5 Creates IPDFTextLayerFactory interface 2014-12-17 15:21:54 -06:00
Yury Delendik
f68678086d Simple restructuring PageView into PDFPageView 2014-12-17 15:21:54 -06:00
Yury Delendik
863d583ae1 Renames page_view.js file. 2014-12-17 10:32:07 -06:00
Jonas Jenwald
670b842e09 Fix "Automatic Zoom" for landscape documents with very wide pages (issue 5398) 2014-10-12 02:25:35 +02:00
Jonas Jenwald
5f83739190 Fix |cleanup| regression in the viewer 2014-10-02 00:24:01 +02:00
Yury Delendik
5740b96020 Introduces 'pagesinit' event. 2014-09-30 12:41:53 -05:00
Yury Delendik
b16a406f3a Packages PDFViewer as a UI component. 2014-09-30 12:41:53 -05:00
Yury Delendik
374b94381d Moves scrollPageIntoView to the PDFViewer. 2014-09-30 07:13:46 -05:00
Yury Delendik
504d2c19e0 Fixes typo/regression of #5295 for presentation mode 2014-09-29 20:17:26 -05:00
Yury Delendik
a89bba35b2 Adds types definitions (jsdoc) for the PDFViewer code. 2014-09-28 10:39:56 -05:00
Yury Delendik
3773972dce Marks some private methods in PDFViewer and PDFThumbnailViewer
Conflicts:
	web/pdf_viewer.js
2014-09-28 10:39:56 -05:00
Yury Delendik
a1eca2084d Moves constants to avoid dependency on PDFView 2014-09-21 12:47:26 -05:00
Yury Delendik
f1851c6393 Removes any usage of PDFView in the PageView 2014-09-21 12:47:26 -05:00
Yury Delendik
fbd7eedce8 Removes PresentationMode dependency from PDFViewer 2014-09-21 12:47:26 -05:00
Yury Delendik
a06a974f78 Moves rendering queue logic from PDFView 2014-09-21 12:47:26 -05:00
Yury Delendik
7642c39734 Moves pdfDocument.getPage/getTextContent requests out of PDFView 2014-09-21 12:47:26 -05:00
Yury Delendik
7af8748151 Moves viewer code into PDFViewer and some code from PageView. 2014-09-21 12:47:07 -05:00