opening pdf files in Zotero

Below is my original question, posted to a different discussion, with adamsmith's response. He said I should start a new thread for this topic, which I am doing here. I tried your suggestion, which makes perfect sense, in both Zotero for Firefox and Standalone Zotero, but changing the launch NonNative files hidden preference to true didn't make a difference in either case.


This is a simpler problem, but I don't know the best place to raise it. I don't save pdf files with my Zotero database, but rather in a separate directory on my computer. If I have a pdf copy of a paper in my database, I show the location of that pdf in the URL field. When I open that pdf from Zotero in Firefox, it opens in a window without editing capabilities (highlighting, commenting, deleting pages, etc.). I use Adobe X Pro, which is what my installation of Firefox is set to use. I've discovered that this constraint is a consequence of Firefox, not Zotero or Adobe X Pro. However, when I try to open a stored pdf in Zotero Standalone, the pdf opens in a window that can't be moved or resized. The window may show only the closed button in the upper right, or it may not show the top bar of the window at all. I use Windows XP.

Can you tell me how to fix this?

Thanks,

Steve Jenkins

so you want the PDF to just open in Adobe Pro?
Set the launchNonNative Files hidden preference to true:
http://www.zotero.org/support/preferences/hidden_preferences
  • can you tell which program opens the PDF? (i.e. the PDF viewer in the Window you can't move/resize - is that Adobe? Firefox's built-in pdf.js?
  • Here's what works in Zotero for Firefox:

    1) In Adobe Acrobat X Pro, Preferences, Internet -- turn off display in browser default.

    2) In Firefox 19.0.2, use about:config to set hidden preferences (these aren't Zotero preferences, but Firefox ones). Set pdfjs.disabled to True.

    3) In Firefox, Options, Applications -- specify Use Adobe Acrobat for Adobe Acrobat files.

    The Zotero option to launchNonNativeFiles can remain set at False.

    In Zotero Standalone, changing this hidden preference doesn't solve the problem.

    Thanks

    Steve J.
  • OK, glad you have it working for FF.
    I don't think we've ever heard of such an issue with Standalone and presumably many people are working on set-ups similar to yours.
    Try this: http://www.zotero.org/support/kb/file_handling_issues#unexpected_behavior_wrong_action_gibberish_pdf_etc_when_opening_files_from_zotero

    If that doesn't work, could you tell me which application opens the PDF from Zotero Standalone?
  • I deleted mimeTypes.rdf from the profile directory, but that didn't fix the problem in Zotero Standalone. I'm sorry to have to ask this question, but can you tell me how to discover which application opens a pdf from Zotero Standalone?

    I mostly use Zotero FF, so it's not that critical to get Standalone to open pdf files properly, but I'm still curious, especially since others evidently haven't reported the same problem.
  • I think if you select the window with the opened PDF you should be able to tell which program is running by looking at the taskbar (or whatever that thing in Windows is called where the currently running programs show up). Also, every PDF viewer has a distinctive lay-out, you might be able to recognize that. Last idea would be the task manager - close the PDF window and see what changes.
  • Good suggestion -- I tried this. The task manager shows:

    "fname (application/ pdf Object) when the pdf window is opened from Zotero Standalone, and this task disappears when the pdf window is closed (which is all I can do when I open it from Zotero Standalone because the minimize and maximize buttons are missing).

    I did a quick Google search for "application / pdf Object" and found some comments suggesting that this string is used to deal with pdfs in programming, leading me to suspect that there is something in the Zotero Standalone program causing this behavior, though I'm surprised that no other users have mentioned it.

    Steve J.
  • application/pdfObject is just a mimeType - i.e. how pdf files are referred to in computers. That's not surprising
    I dont' think I can help you any further unless we get more reports on this.

    I'm still surprised you can't tell which PDF viewer you're looking at - as I say, every pdf viewer has a distinct layout - things like how the cursor looks, how you select text, the right-click menu etc.
  • How about a screenshot of what you see when you open the pdf? you can post it to any image hosting website, like imgur.com, and post a link here.
  • Report ID: 2095341960

    For many records in my Zotero database, I have a pdf file that I store in a location on my hard disk. I use the URL field to record this link (for other records, the URL field points to a web address). I use Acrobat X Pro as my pdf reader. Version 5 of Zotero opens a gratuitous empty window as well as another window containing the pdf file when I click on a record that contains a reference to the pdf file in the URL field of my Zotero database. This minor problem didn't occur in previous versions of Zotero.

    Thanks for any help you can provide.

    Steve Jenkins
  • You should not use the URL field for that. The URL field should only be used to store a URL where the full text can be publicly found, as it is used for citation purposes. Instead, right click on the item and choose Add Attachment -> Attach Link to File. That will also prevent a browser window from opening. To open the link, double click on the item in Zotero.
  • Thanks for this explanation of how the URL filed works. Unfortunately, your alternative suggestion isn't feasible for me (at least until full-text editing is available in Zotero), because I have about 900 such records.

    I guess the gratuitous empty window is not a bug in Zotero 5 per se, but rather a consequence of using the standalone version of Zotero, which I like otherwise (and am well-adjusted to using with Chrome after using Firefox with the Zotero add-on for many years).
  • @shjenkins you use the incorrect item in the Zotero for storing pathway to your PDF files, it can lead to wrong output from a lot of citation styles. I do not know how you can use a Zotero, but if you can use it for inserting correct citation to your documents (for example papers which you will send to any journal), then you have to correct your data. In your case, it is a lot of manual work to change it, unfortunately.

    I think the gratuitous empty window is not a bug in Zotero 5 in this case. The Zotero try to open URL in the web browser. Standard function of all web browsers is open HTML format, not open PDF format. Open other formats in the web browser windows is an additional function. And it seems like the current web browser in the Zotero does not have this function. It is not a bug, it is a limitation.
  • I have a very large number of pdf files of journal articles that I began collecting long before I started using Zotero. I need to be able to access those from Zotero using the url field (for new entries, I mostly use the online link in the url field, but these legacy entries require being able to access my copy of a pdf in a directory on my computer). This stopped working in the last day or so, I suspect after the last update to Zotero. In the general tab of preferences, I set the program to open pdfs with my version of Acrobat. Please advise, and be aware that redoing all my pdf files as attachments to items in my Zotero database simply isn't feasible.

    Thanks,

    Steve Jenkins
  • Yes, the field only launches actual URLs now and that was done intentionally (see https://github.com/zotero/zotero/commit/df40ee7216ac8d422a618336f768dd69116555ee )

    I'm not aware of any workarounds other than copy&pasting the file URIs into your browser or explorer window.
  • @shjenkins: These are file:// URLs? We could potentially give you some code to run that would convert all file:// URLs to linked-file attachments.
  • Here is the format of these formerly functional links in the url field of my Zotero database:

    c:\data\pdf files\fname.pdf

    e.g., c:\data\pdf files\breck_2019.pdf

    Thanks,

    Steve Jenkins
  • edited January 11, 2020
    Yeah, so as we've said before, that's not a URL and not something that ever should've been expected to work in that field, which is an item's URL for citation purposes. Incidentally, the thing that broke these for you was a fix for exactly the behavior that you reported above of an empty window being opened — that shouldn't have happened, because these weren't links to open in the first place.

    But to answer your question from five years ago, here's a script you can use to convert all the incorrect URL-field values to linked-file attachments. Before you run it, you should 1) temporarily disable syncing in the Sync pane of the preferences and 2) close Zotero and make a backup of the zotero.sqlite file in your Zotero data directory.

    Once you've done that, go to Tools → Developer → Run JavaScript, paste in this code, and run it:

    var s = new Zotero.Search();
    s.libraryID = Zotero.Libraries.userLibraryID;
    s.addCondition('url', 'beginsWith', 'C:\\');
    var ids = await s.search();
    if (!ids.length) {
    return "No items found";
    }
    var output = "";
    var numUpdated = 0;
    for (let id of ids) {
    let item = await Zotero.Items.getAsync(id);
    let path = item.getField('url');
    try {
    if (!await OS.File.exists(path)) {
    output += "Skipping missing file " + path + "\n";
    continue;
    }
    await Zotero.Attachments.linkFromFile({
    parentItemID: item.id,
    file: path
    });
    item.setField('url', '');
    await item.saveTx({
    skipDateModifiedUpdate: true
    });
    numUpdated++;
    }
    catch (e) {
    Zotero.logError(e);
    }
    }
    return output + "\n" + numUpdated + " item(s) updated";


    If there's a problem, close Zotero and replace zotero.sqlite in your data directory with the backup.

    You can turn syncing back on afterward if you're happy with the results.
  • Thanks very much. I followed your instructions and ran this JavaScript code, which seemed to be working, but when done hadn't created attachments to the pdfs as a substitute for my having entered the paths to the attachments in the url field.
    I don't have as many of these records as I thought -- 225 out of 4142 total records. So I can gradually fix this manually, by adding attachments to these 225 records and changing the url data to online links.

  • You're saying it didn't work at all? What does it say in the right-hand pane when you run it?

    There's no need to fix these manually.
  • It's unclear to me why this didn't work. I followed the instructions you provided, but nothing appeared in the right-hand pane when I ran the JavaScript (I don't know how long I should wait). NOr did error messages appear in that window. Although I've done a lot of programming in my career, initially in various versions of Basic, then in R, I never learned to program in JavaScript, so can't easily interpret your code. I did try copying the last line

    return output + "\n" + numUpdated + " item(s) updated";

    to after this line

    numUpdated++;

    and got output for 3 records in the right pane, but nothing more.

    Thanks again for your help.

    Steve Jenkins
  • edited January 14, 2020
    Have you been closing the window? If you're not getting anything in the right-hand pane, you may just not be waiting long enough. It won't display any output until the end.

    You can go to Help → Debug Output Logging → View Output to see whether Zotero is still doing anything while it's running.
Sign In or Register to comment.