Repository navigation
feat(pdf-studio): PDF.js based viewer and editor - #618
AlexAndBear wants to merge 18 commits into
Conversation
|
awesome!! |
|
Really awesome! |
a6d45f3 to
c523e9f
Compare
89a2a4c to
2cd53ef
Compare
|
Note: It's too easy to accidentally move or delete a page with a single click while scrolling through the pages in the sidebar. We need a better UI concept for the page actions. -> 3 Dot Menu ✅ |
A new app for viewing and editing PDFs, built on the pdfjs-dist viewer components. - PDF.js' worker, form sandbox, CMaps, fonts, ICC profiles and wasm decoders are copied into dist/pdfjs, nothing is loaded from elsewhere. pdf_viewer.css is scoped to the app. - Loading documents, also password-protected ones, with load errors and retry. - PDF.js' texts translated with the app's translations.
Comments on selected text, highlights, drawings and images, a list of all comments of the document, popups to read, edit and delete them. Comments of other tools (e.g. Acrobat) are shown, rich text in the size and colors of OpenCloud.
Like the PDF.js viewer: page navigation, zoom (also pinching and Ctrl + wheel), scroll and spread modes, rotation, find bar, keyboard shortcuts, printing with forms and annotations, presentation mode, hand tool, document properties and page labels.
Thumbnails, document outline, attachments and layers in the sidebar, opened like the PDF asks for. Pages can be moved and deleted from a menu per page, with undo and redo.
Highlights, text, drawings and images (from the device or from OpenCloud) with the settings of the PDF.js viewer, alt texts, and signatures (typed, drawn or from an image), up to five saved for reuse. A tool picker on phones.
Form values, annotations and comments are tracked and written into the file, for OpenCloud's save, Ctrl+S and autosave. Form scripts run before saving, saving failures of PDF.js are reported instead of saving stale content.
A toolbar in the order of the PDF.js viewer with a "More actions" menu for what doesn't fit,
one row with bottom drawers on phones. The app opens PDFs in OpenCloud ("Open with"), also on
public links, read-only files get the viewer without editing tools. End-to-end tests.
75b0f14 to
72cecda
Compare
Squash of the follow-ups after the feature commits: - Review follow-ups: AppWrapper's register:onSaveCallback (web 8.1.0) instead of the etag watch, page number as oc-text-input, auto zoom for the page shown after page operations, the comments drop mounted together with its toggle, the signature dialog in the style of the design system. - Exploratory tests: single-key shortcuts don't reach the host (s), the find bar keeps the current match when reopened and doesn't highlight all by default, XFA forms print one page per sheet, typing goes on after Ctrl+S, the password prompt takes no empty password and shows the error in its input, comment popups stay clear of the list of comments, forced colors for swatches and active menu items, dirty state after a quick undo. - UX: the viewed page stays when deleting another page, authors of saved annotations in comment popups and the list, the list also has the comments of annotations PDF.js has no editor for (sticky notes, underlines, attachments), the drop of saved signatures fits the descriptions, cancelling the password prompt closes the app, a wrong password keeps the same prompt open. - Code review: comments of annotations that are their own trigger open from the list, the comments of a document are looked up once, a search without matches stays marked while the find bar is closed, PDF.js' editor toolbars keep their keys, deleting a page takes the page viewed once pending changes are written. - Simplification review: view options and signature options folded into their only users, computedAsync for saved signatures, the L10n object reduced to what PDF.js calls, dead guards and duplicate tests removed, the PDF.js polyfill as vitest setup file. - README: tool settings, dirty state of form values, password prompt.
a4c7fb0 to
f20ce91
Compare
|
PDF.js issues reported while building this. Visible to users of PDF Studio:
Worked around in PDF Studio (listed so the workaround can go once PDF.js fixes it):
|
62def5f to
f20ce91
Compare
…y on phones The tool picker showed them in a section of their own below all tools, far down in the drawer for the drawing tool. Now they follow the entry of the active tool like a sub menu, framed in the color of the entry, with the same spacing on all sides.
- Typing on after Ctrl+S: the text box is back in edit mode before the save runs, so no key is lost to the page, and the caret stays where it was when PDF.js moves the committed editor in the DOM a moment later. - A drawing counts as a change from its first stroke, not only once the pointer is released; dragging a selected annotation (which disables text selection the same way) does not. - A new image counts as a change while it decodes (PDF.js marks its layers as waiting), and a save in that window waits for the image instead of doing nothing. - README: PDF.js offers comments on new drawings, texts and images, not on saved ones.
d7aba33 to
6f57bd5
Compare
- Icons like in the preview app and the text editor: the sidebar toggle uses the preview's side-bar icon (filled while open), rotating its clockwise/anticlockwise icons, the find button the text editor's search icon, adding an image from the device its image icon. - Toolbar spacing like the text editor: 4 px between buttons and groups, and the separators between groups are visible again (bg-role-border doesn't exist as a background color, they are borders now).
6f57bd5 to
7be1f99
Compare
Forms are often only filled in to print them, an autosave would change the file meanwhile. Saving stays with the save button, Ctrl+S and the question when closing.
|
@kulmann @tbsbdr heads-up: I disabled autosave for PDF Studio ( Why: quite often you open a PDF form just to fill it in and print it, without wanting to change the file in the cloud. With autosave the filled-in values would end up in the file after two minutes without asking. Saving still works as usual via the save button, This is a product decision on my side, happy to hear other opinions 🎀 |
c1aaeaf to
5202124
Compare
- Printing renders all pages on one canvas and waits only until each page image is loaded, like the PDF.js viewer: about a third faster for long documents. - The page undo keeps up to 50 MB of file versions on touch devices instead of 200 MB, they have far less memory for a tab. - Changes of large files are written after the same short delay as others, PDF.js saves incrementally and takes well under a second even for big scans.
91dbfed to
7ca5486
Compare
- Inside the image area of the signature dialog, "Or pick from cloud" opens OpenCloud's file picker on top of the dialog, like for images of annotations; not on public links, where the picker only shows the shared files. - The save switch explains that saved signatures are kept in this browser only, unless the limit of saved signatures is reached, which it explains instead.
110f39f to
fc5a47c
Compare
…ight sidebar - The document properties are a panel of OpenCloud's right sidebar instead of a dialog, next to details, shares and versions. The entry in the more menu opens the sidebar on it. It follows the current page and rotation like in the PDF.js viewer, and is only offered for the open document, not in the sidebar of the files app. - The properties are grouped in boxes like the user settings in the admin settings, with OpenCloud's definition list. - The README is shorter and mentions the panel.
fc5a47c to
bb85665
Compare
- e2e tests for highlights, undo/redo, moving pages, the unsaved-changes prompt, editing and deleting comments, zoom, rotation, the hand tool, outline/attachments/layers, read-only links, images and their descriptions, signature descriptions, printing, presentation mode, password-protected files and sticky notes, with three small generated fixtures. - Contract tests against PDF.js' code: what it uses of the comment, signature and alt text managers, the text ids of the translations and the class names the app looks for. - Broken outlines, attachments, page labels, layers, page modes and metadata in a file are left out instead of loading forever. - Follow-ups of the architecture review: zoom gestures and the form field commit in their own composables, one placement map for toolbar and "More actions" menu, `editing` as one object. - The shared upload helper waits for its menu to open and close, it stayed open sometimes.
|
Plan before rolling out PDF Studio more widely
|
Remove the workarounds for PDF.js issues fixed in this release: - mozilla/pdf.js#22121: use the minified scripting sandbox again - mozilla/pdf.js#22212: dispatchWillSave() now waits for the WillSave scripts, no extra task needed before saving createScripting stays, PDF.js passing on the sandbox events itself (mozilla/pdf.js#22133 is fixed) would bypass usePdfFormFieldCommit.
|
Closing this one, we're moving PDF Studio into core instead: it replaces the built-in PDF viewer in opencloud-eu/web#4614 (same app name and icon as the old viewer). |
📄 PDF Studio
Fill in, sign, mark up and rearrange PDFs in OpenCloud – everything is saved into the PDF itself: form values, signatures, annotations, comments and page changes, through OpenCloud's save button,
Ctrl+Sand versions (no autosave, so a form can be filled in just to print it). Reopen it here or in any other PDF reader and it's all there; password-protected files stay encrypted.Built on the
pdfjs-distviewer components (web-app-pdf-studio), it shows up under "Open with" next to the built-in PDF viewer.🎬 Demo
pdf-studio-demo.mp4
📱 On the phone
pdf-studio-mobile-demo.mp4
✨ Features
🦊 Close to the PDF.js viewer
PDF Studio deliberately sticks to the PDF.js viewer that ships with Firefox: same tools, menus, shortcuts and behaviour, built with the OpenCloud design system.
Read-only shares and links get the viewer without editing tools.
🔮 Later
AppWrappersupport for apps that need a moment to write their content (web#3718)Known PDF.js limitations: some XFA values aren't saved, page operations drop layers and XMP metadata (pdf.js#22125), comments of e.g. underlines can't be changed.
🛠️ Under the hood
dist/pdfjs,pdf_viewer.cssis scoped to the appsaveDocument()debounced; save and close wait for the latest content