retorquere / zotero-folder-import

304 stars 19 forks source link

Add Bookmarks index for imported PDFs #31

Open sancho-s opened 1 year ago

sancho-s commented 1 year ago

For a Zotero item, whenever I add a pdf file in disk (either the file or a link to it), the tag structure of the pdf is read, and it is shown as an hyperlinked table of contents, so clicking on it opens the pdf at the location of the item.

But when I add Zotero items via [zotero-folder-import], the table of contents is not added. Can this be done?

Thanks!

retorquere commented 1 year ago

I don't know this functionality. Where does this table of contents show up?

sancho-s commented 1 year ago

In Zotero, if you select an item, expand its attachments, and select a pdf attachment that was added via "Attach link to file", in the right hand panel you will see:

retorquere commented 1 year ago

Do you have a sample pdf known to trigger the desired behavior?

sancho-s commented 1 year ago

Yes, I am attaching it here. Buckling.pdf

PS: I found that, in Zotero, you may or may not get the table of contents, depending on how you add the pdf attachment to the Zotero item. If added via "Attach link to file", the table is created.

image

If added via Ctrl+Shift+drag, it is not. This is reported in a related thread in Zotero forum.

So, I guess there are two ways in which [zotero-folder-import] can get the table:

  1. By Zotero changing the behaviour of Ctrl+Shift+drag, and then that will be replicated in the add-on.
  2. By the add-on mimicking the behaviour of "Attach link to file" instead.
retorquere commented 1 year ago

According to that thread, the TOC thing is a Zotfile feature, so you would have to ask there why it isn't being generated. folder-import is calling the same functions that Zotero itself calls when importing/linking attachments.

sancho-s commented 1 year ago

I don't know about the interaction Zotero-Zotfile, and I am not even sure extraction of the table of contents is done by Zotfile or Zotero itself. For instance, apparently, since Zotero 6.0, extraction of annotations is not done by Zotfile anymore, but by Zotero.

At any rate, what I mean is that, apparently, Zotero has two different ways of attaching a PDF, and they perform differently:

  1. Via Ctrl+Shift+drag of the PDF into the Zotero item.
  2. Via menus and "Attach link to file". This creates the table of contents.

Perhaps [zotero-folder-import] can be instructed to work like #2, regardless of that being directly with Zotero or via Zotfile.

retorquere commented 1 year ago

If adamsmith says that this is done by Zotfile I'm inclined to believe him. Can you first go check whether @jlegewie agrees with adamsmith before I dive into the Zotero code? If it's Zotfile's feature to do this I'll be glad to help where needed, but would prefer to keep @jlegewie in the lead for it. If it is indeed not a Zotfile feature but something Zotero does itself, that would be a different matter.

sancho-s commented 1 year ago

Will do. On a separate note, now using Ctrl+Shift+drag does get the table of contents. I can't reproduce what I saw before.

What I can reproduce is that adding via [zotero-folder-import] does not get the table of contents. Which, on a file-by-file basis, can be fixed via Select the PDF item -> Right click -> Manage Attachments -> Get table of contents.

Summarizing, it seems that now [zotero-folder-import] does not do exactly the same a Zotfile... which is very strange.

retorquere commented 1 year ago

What is zotero's behavior if you don't have Zotfile installed?

retorquere commented 1 year ago

What I can reproduce is that adding via [zotero-folder-import] does not get the table of contents. Which, on a file-by-file basis, can be fixed via Select the PDF item -> Right click -> Manage Attachments -> Get table of contents.

Summarizing, it seems that now [zotero-folder-import] does not do exactly the same a Zotfile... which is very strange.

As soon as @jlewegie weighs in, I can see what to do about this (or whether there is anything to do). I do not know what initiates this behavior, and adamsmith, who is deeply involved with Zotero, says it is Zotfile doing this.