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

Feature-Request: "copy open-pdf link" #182

Open
bthomaslee opened this issue Feb 12, 2021 · 9 comments · May be fixed by #264
Open

Feature-Request: "copy open-pdf link" #182

bthomaslee opened this issue Feb 12, 2021 · 9 comments · May be fixed by #264

Comments

@bthomaslee
Copy link

I love the "copy select items link" feature (using the zotero://select protocol). How easy would it be to add a "copy open-pdf link" (using the zotero://open-pdf protocol)? I would use that feature all day long if it existed, as I sprinkle links to open pdfs to particular pages in various notes, pdfs, and Zotero entries.

@wshanks
Copy link
Owner

wshanks commented Feb 18, 2021

This just requires replacing select with open-pdf in the "copy select items link" function, right? That should be pretty easy. I tried running "copy select item link", pasting it and changing select to open-pdf and then putting that URI into my browser. It still just selected the item in Zotero rather than opening the PDF. That might just be because I don't have protocol handling set up properly on my system.

@bthomaslee
Copy link
Author

That's true -- you're right -- it is pretty easy to run the "copy select items link" function, paste that link into a URI field or into a document (as a link), and then simply edit the link (manually), by deleting the part of the link that says select and typing open-pdf in its place. I've been doing that, successfully, for a little while now. I'm doing it so often, though, that it's becoming tedious. So I was wondering... since the "copy select items link" function exists, if it wouldn't be pretty easy to replicate it (creating another, almost identical function) that would generate the link that's needed (without having to manually edit it each time). It wouldn't be a big deal, except that I'm making so many open-pdf links each day.

@wshanks
Copy link
Owner

wshanks commented Feb 18, 2021

Right. I just wanted to check that I understood the request since it didn't seem to work for me. I think it is just something wrong in my system's protocol handling. It would be pretty easy to refactor the current select links function into something that could be used for both cases.

@bthomaslee
Copy link
Author

Gotcha. Thanks! It occurs to me that maybe I should say that, on the surface, when it comes to one's workflow with Zotero, the difference between the select and open-pdf functions might seem insignificant, because it's only one, simple, additional step to go from selecting a Zotero item in the Library to opening it (once the item is selected). The powerful thing about the zotero://open-pdf protocol, though, is that it allows you to append a page number to the item key at the end of the link, by manually typing ?page=x where x is a page number in the relevant pdf. When you activate the open-pdf link, with a page number parameter appended to it, Zotero will open the pdf and jump straight to the specified page. In terms of workflow, this makes the open-pdf protocol a powerful tool. I can copy a link to a particular page in a particular pdf and then paste that link anywhere (e.g., in a sticky note in Zotero, in the URI field in a Zotero item, in Simplenote, in Scrivener, in MS Word, MS Excel, etc.). When the link is clicked in any of those contexts, on my machine, Zotero will open the relevant pdf and jump straight to the specified page. I've got a lot of pdfs that contain a lot of pages; so the open-pdf protocol, when combined with this page number parameter, is super useful for my workflow. Just clarifying, if needed.

@bthomaslee
Copy link
Author

bthomaslee commented Mar 10, 2021

I successfully edited line 786 in "zoteroOverlay.js" (i.e., the copyZoteroSelectLink function) so that it reads links.push('zotero://open-pdf/' + path + '/items/'+ zitems[ii].key + '?page='). Now, after installing my modified Zutilo.xpi, I can use the "copy select items link" feature to copy the open-pdf link to the clipboard. I can paste the link, add the page number to the end of the link, and, when clicked, the link will open the pdf to that page.

I tried, unsuccessfully, to create a new function called copyZoteroOpenLink.

  1. I copied the original code for the copyZoteroSelectLink function, pasted it right below the original, and changed the relevant lines (i.e., every instance of copyZoteroSelectLink became copyZoteroOpenLink, and I changed the text from line 786, as described above).
  2. Then I inserted 'copyZoteroOpenLink', in line 34 of "zutilo.js."
  3. Then I copied lines 137-140 in "keys.js" (i.e., the key for the copyZoteroSelectLink function), pasted them immediately below, and, again, changed every instance of copyZoteroSelectLink to copyZoteroOpenLink.

This missed the target. It created an un-named shortcut in the "copying" category, which, when I assigned a key to it and ran it, copied the following text to the clipboard:

'copyZoteroSelectLink',

I'm trying to figure it out. Still tinkering. If it's clear what I'm missing, and you're able to help, I'd be grateful! Thanks!

@wshanks
Copy link
Owner

wshanks commented Mar 10, 2021

No, I can't think of how that would happen. It should just be the contents of the links variable. I would look carefully at the copyZoteroOpenLink function for what it does with links. If you put your version on GitHub, I can look at the diff.

If we added this function to Zutilo, do you think adding on ?page= by default is the best option? Will the pdf open without putting a number in? Maybe the default could be ?page=1 so the link is valid and the user can change the 1 to something else if they want.

@qqobb
Copy link
Collaborator

qqobb commented Mar 15, 2021

@bthomaslee: Why don't you try adapting an export translator to your needs, see here for an example. The advantage would be that you're more flexible, you can keep changing it while your workflow evolves.

You can use Zutilo's "QuickCopy items" function for additional keyboard shortcuts, as explained in the command reference.

The new Zotero beta comes with a new PDF reader and note editor, see here. Some of your workflows could be affected by these updates. Automatically adding the correct page to the open-pdf links might also be possible.

@bthomaslee
Copy link
Author

Thanks @qqobb. Alas, even with your helpful links (and some online tutorials), I'm not skilled enough to install a custom translator. After a couple of hours tinkering with it, I've given up.

And I didn't know about Zotero beta's new PDF reader and note editor. I've played around with it. It's fast. I'm sure it'll become more powerful, too, over time. But, for now, I still prefer to open and edit PDFs in Adobe Acrobat. With Acrobat, I can embed annotations automatically, edit bookmarks, use stamps, create links to particular page views internally, reorder pages, etc.

@wshanks: Here's a link to a fork (if it deserves to be called that) that I made today, using the latest release of Zutilo (3.8.1). I did everything as described in my previous post. It's not producing the same results as I described in that post. Not sure why. Instead of what I described, the Zutilo preferences menu is incomplete. Perhaps the update to Zotero affected things (I'm running Zotero 5.0.97-beta.9+f690c666d).

Also, in answer to your question about adding on ?page= by default, I do think that would be best. I tested it a bit, and the link behaves exactly the same with or without the ?page= at the end. This is true (at least on my machine) with the new Zotero PDF viewer and with Acrobat. If you're using the new Zotero PDF viewer, then Zotero will remember the last page that was active when the PDF was closed, and it'll open PDFs to that page; and, when the open-pdf link is used, Zotero will open to that page, with or without the ?page= appended to the end of the link. If you're using an external PDF viewer/editor, then the link opens to the first page of the PDF in all of the following cases: 1. ?page= is omitted, 2. ?page= is appended, 3. ?page=1 is appended.

It might cause a bit of confusion for some Zutilo users, at first, when they see ?page= at the end of the link that's generated by a copyZoteroOpenLink function. But I think that confusion could be mitigated in the readme. And the potential for confusion isn't great enough, in my view, to sacrifice the ability to copy, paste, and simply type a page number. But, of course, there may be something significant that I'm missing from a programming perspective -- esp. as Zotero's own PDF viewer/editor evolves.

@luiandresgonzalez
Copy link

Hi, just commenting on this to maybe gather some momentum for this improvement. It would really become a good addition to the plugin, since I think what you want the most when you link a document from outside zotero is for it to open the actual document right away and not the extra step of going to the selected item and then opening it.

@swfc swfc linked a pull request Dec 27, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants