Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDF annotation support #787

Merged
merged 7 commits into from
Oct 25, 2023

Conversation

gpsrenewablesit
Copy link
Contributor

@gpsrenewablesit gpsrenewablesit commented Jul 19, 2023

I have enabled the annotation toolbar within the PDF viewer interface. This toolbar includes various annotation tools, such as freehand drawing and text boxes. Clicking the save button will save the updated PDF document to Nextcloud.

After the update

Screenshot from 2023-07-19 14-44-20

Changes after update

  • Enabled text annotation.
  • Enabled freehand drawing.
  • Enabled save button.
  • Saving the updated PDF to Nextcloud.

Similar Issues

Close #719
Close #647

Copy link
Collaborator

@szaimen szaimen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this and it works quite well. Thanks a lot for you contribution!

However from design perspective, this description is not really visible.
image

Also please make sure to translate all text that you added. See https://docs.nextcloud.com/server/latest/developer_manual/basics/front-end/l10n.html#javascript

appinfo/info.xml Outdated Show resolved Hide resolved
@szaimen
Copy link
Collaborator

szaimen commented Jul 19, 2023

Also @gpsrenewablesit can you please fix DCO, see https://github.com/nextcloud/files_pdfviewer/pull/787/checks?check_run_id=15161520585. Otherwise we cannot merge this. Thank you! :)

@github-actions
Copy link

github-actions bot commented Aug 3, 2023

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the reviewing process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR reviewing process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

Copy link
Collaborator

@szaimen szaimen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works well in my testing, thank you! :)

@nopper
Copy link

nopper commented Oct 7, 2023

What's the state of this? Can we get this approved?

@szaimen
Copy link
Collaborator

szaimen commented Oct 7, 2023

What's the state of this? Can we get this approved?

@danxuliu still needs to review...

Copy link
Member

@danxuliu danxuliu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the very long delay and thanks for your contribution!

In order to ask for some changes in the review I had to implement them by myself, as I was not sure if/how they could be done (and some were quite tricky...). However, as I had already implemented them for testing purposes I cleaned up my own code and ended commiting the changes too rather than just asking for them :-)

Due to that I also took the freedom to rework the commit history rather than asking for that (as, for example, the commits that fixed the minimum version or the translated strings should be squashed with the original commit, and the upload code could be set in the component since the beginning instead of moving it from the worker in an additional commit); I hope that is fine for you, but please accept my apologies if not.

Besides that, I have rebased the pull request on latest master to solve the conflicts.

I will now force push the branch with those changes.

templates/viewer.php Outdated Show resolved Hide resolved
templates/viewer.php Outdated Show resolved Hide resolved
src/workersrc.js Outdated Show resolved Hide resolved
templates/viewer.php Outdated Show resolved Hide resolved
src/workersrc.js Outdated Show resolved Hide resolved
src/workersrc.js Outdated Show resolved Hide resolved
@danxuliu
Copy link
Member

danxuliu commented Oct 9, 2023

There is something I would like to ask @nextcloud/designers about :-) In PDF.js UI the Save button (which has a Download icon) always downloads the PDF file. Here, on the other hand, the Save button uploads the changed file with the annotations to Nextcloud. This could be a surprising behaviour (specially for Firefox users, as Firefox uses PDF.js to show PDF files). Should a different button, maybe one with an upload icon, be used instead? Should Save still be used as caption?

And if an additional button to upload the file is used, should the download button be shown as well with its regular behaviour? Before this pull request the Save button was always hidden (as the file could be saved/downloaded using the button in the top bar from the viewer or the public page, depending on the case). However, if annotations are made and the user downloads the file through those means the downloaded file would not contain the annotations, it would still be the original file in the server. The user would need to first upload it and, then, download it to get the annotations. Which, obviously, changes the original file in the server and may not be desirable 🤷

On the other hand... if the download button inside the PDF viewer behaves differently than the download button in the file list or the public page buttons that could be confusing as well (and intercepting the clicks (or any other activation) on the top bar buttons to download the annotated file instead of the original file while not modifying the file in the server could be difficult, although I have not actually checked).

Thanks!

@szaimen
Copy link
Collaborator

szaimen commented Oct 18, 2023

There is something I would like to ask @nextcloud/designers about :-) In PDF.js UI the Save button (which has a Download icon) always downloads the PDF file. Here, on the other hand, the Save button uploads the changed file with the annotations to Nextcloud. This could be a surprising behaviour (specially for Firefox users, as Firefox uses PDF.js to show PDF files). Should a different button, maybe one with an upload icon, be used instead? Should Save still be used as caption?

And if an additional button to upload the file is used, should the download button be shown as well with its regular behaviour? Before this pull request the Save button was always hidden (as the file could be saved/downloaded using the button in the top bar from the viewer or the public page, depending on the case). However, if annotations are made and the user downloads the file through those means the downloaded file would not contain the annotations, it would still be the original file in the server. The user would need to first upload it and, then, download it to get the annotations. Which, obviously, changes the original file in the server and may not be desirable 🤷

On the other hand... if the download button inside the PDF viewer behaves differently than the download button in the file list or the public page buttons that could be confusing as well (and intercepting the clicks (or any other activation) on the top bar buttons to download the annotated file instead of the original file while not modifying the file in the server could be difficult, although I have not actually checked).

I'd say that we should change the save icon to a normal save icon and keep the caption (or maybe make it more explicit and change that to Save to Nextcloud.) Then we should be fine :)

Copy link
Collaborator

@szaimen szaimen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danxuliu I tested this and it works fine generally but I don't know why and if it is caused by this PR but somehow the pdf viewer has two scrollbars now:
image

danxuliu and others added 7 commits October 23, 2023 06:44
The Viewer provides several useful helper functions for DAV, but they
can not be used (or at least I did not find out how) from the PDF
viewer. Therefore, for now they were just copied over.

The original file is written in TypeScript, but as it was not
extensively typed and TypeScript is not currently supported in the PDF
viewer for simplicity it was adjusted and converted to JavaScript.

The file was copied from "src/utils/davUtils.ts" of repository
"https://github.com/nextcloud/viewer" at commit
"854e63d33a8fd304a6c4ea6704f0f68c6308f4b8".

Signed-off-by: Daniel Calviño Sánchez <[email protected]>
In Nextcloud the background of disabled buttons does not change when
hovered.

Signed-off-by: Daniel Calviño Sánchez <[email protected]>
The "Save" button was always enabled, but saving and uploading the file
would be needed only if there is an unsaved annotation. Therefore now
the button is initially disabled, and it is enabled only when an
annotation is added; once the file is saved the button is disabled and
it will be enabled again once a new annotation is added.

Signed-off-by: Daniel Calviño Sánchez <[email protected]>
The "Download / Save" button uses a "Download" icon by default. For
clarity, and to differentiate from the default PDF.js behaviour that
downloads the file with the added annotations rather than saving it in
place, the button now uses a "Save" icon instead.

Like other icons used in Nextcloud, the "Save" icon was copied from
Material Icons, which are licensed under the Apache License Version 2.0:
https://fonts.google.com/icons?selected=Material+Icons:save:

Signed-off-by: Daniel Calviño Sánchez <[email protected]>
@danxuliu
Copy link
Member

I'd say that we should change the save icon to a normal save icon and keep the caption (or maybe make it more explicit and change that to Save to Nextcloud.) Then we should be fine :)

I have replaced the default "Download" icon with a "Save" icon from Material Icons. If the button title was changed it should be "Save to XXX", where XXX is the Nextcloud name configured in the theme. That is probably easy to do, but... something for the future ;-) (but feel free to change that if you know how to, of course :-) ).

I tested this and it works fine generally but I don't know why and if it is caused by this PR but somehow the pdf viewer has two scrollbars now:

I have not been able to reproduce neither on this branch nor in master 🤷 Could you check if you also have that in master? If you do then it would be unrelated to this pull request, so please merge if the icon change is fine (I would like to avoid another rebase due to conflicts caused by dependency updates :-P ).

Copy link
Collaborator

@szaimen szaimen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say that we should change the save icon to a normal save icon and keep the caption (or maybe make it more explicit and change that to Save to Nextcloud.) Then we should be fine :)

I have replaced the default "Download" icon with a "Save" icon from Material Icons. If the button title was changed it should be "Save to XXX", where XXX is the Nextcloud name configured in the theme. That is probably easy to do, but... something for the future ;-) (but feel free to change that if you know how to, of course :-) ).

Tested and looks good to me :)

I tested this and it works fine generally but I don't know why and if it is caused by this PR but somehow the pdf viewer has two scrollbars now:

I have not been able to reproduce neither on this branch nor in master 🤷 Could you check if you also have that in master? If you do then it would be unrelated to this pull request, so please merge if the icon change is fine (I would like to avoid another rebase due to conflicts caused by dependency updates :-P ).

Yes, could also reproduce on master. So merging 👍

@szaimen szaimen merged commit c5c920d into nextcloud:master Oct 25, 2023
27 checks passed
@szaimen
Copy link
Collaborator

szaimen commented Oct 25, 2023

🎉🎉🎉🎉🎉

@mkrecek234
Copy link

@danxuliu @szaimen When is this going to be released to Nextcloud app store? Would love to use it. Am currently on 2.8.0

@szaimen
Copy link
Collaborator

szaimen commented Oct 27, 2023

It will be released with Nextcloud 28 (Hub 7)

@mkrecek234
Copy link

mkrecek234 commented Oct 27, 2023

@szaimen You mean 28? We are on 27.1.3 already. Would love to see it as an app update already in NC27

@szaimen
Copy link
Collaborator

szaimen commented Oct 27, 2023

Sorry, made a typo. Meant 28 (hub 7)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature request]: PDF annotation and insert picture Store PDF forms & annotations
5 participants