Title: Cannot open PDFs
Last modified: May 11, 2022

---

# Cannot open PDFs

 *  Resolved [Gerdski](https://wordpress.org/support/users/gerdski/)
 * (@gerdski)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/cannot-open-pdfs/)
 * Hello,
 * this is a great plugin. Perhaps too great for me, because I cannot solve an error.
 * I am trying to display a number of PDFs with this Shortcode:
 * [mla_gallery link=file post_mime_type=application/pdf ids=”1,2,3″]
 * What I see in the FrontEnd are the correct thumbnails of the PDFs.
    When I click
   on them I see my default lightbox viewer, as with [gallery]. But the PDFs won’t
   open and there’s no way to click on them, the spinner rotates on forever.
 * When I try “…link=file mla_named_transfer=true…” I get a forced download of admin-
   ajax.pdf, but the PDF file is the right one.
 * What I’d like to achieve is to have clickable thumbnails, but instead of opening
   a lightbox viewer or forcing a download, I’d just like to open them in the browser.
   Preferrably with the nice mla_named_transfer=true option.
 * What did I do wrong?
 * Thanks 🙂

Viewing 12 replies - 1 through 12 (of 12 total)

 *  Plugin Author [David Lingren](https://wordpress.org/support/users/dglingren/)
 * (@dglingren)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/cannot-open-pdfs/#post-15640667)
 * Thanks for your positive feedback and for the question. Thanks as well for the
   details and your shortcode text.
 * I believe you can get the results you seek by adding an `mla_target="_blank"`
   parameter to your shortcode. Both of these examples are working well on my system
   with the Microsoft Edge and Chrome browsers:
 *     ```
       [mla_gallery post_mime_type=application/pdf post_parent=all link=file mla_target="_blank"]
   
       [mla_gallery post_mime_type=application/pdf post_parent=all link=file mla_named_transfer=true mla_target="_blank"]
       ```
   
 * When I click on a thumbnail the PDF document opens in a new browser tab. You 
   wrote “**_When I click on them I see my default lightbox viewer, as with [gallery]._**”
   It is possible that your theme is interfering with the document display.
 * I am marking this topic resolved, but please update it if you have problems or
   further questions regarding the above suggestions. If you still have a lightbox
   issue, post a link to the page you’re having trouble with and I will investigate
   further. Thanks for your interest in the plugin.
 *  Thread Starter [Gerdski](https://wordpress.org/support/users/gerdski/)
 * (@gerdski)
 * [4 years ago](https://wordpress.org/support/topic/cannot-open-pdfs/#post-15672335)
 * Hello,
 * sorry for the late reply, and thanks for your answer. With your code
 *     ```
       [mla_gallery post_mime_type=application/pdf post_parent=all link=file
       mla_target=&quot;_blank&quot; mla_named_transfer=true]
       ```
   
 * I get a list of thumbnails with this (obscured) link structure:
 * …/admin-ajax.php?action=mla_named_transfer&mla_item=mypdfname&mla_disposition
   =inline.
 * Clicking on them starts a download of admin-ajax.pdf, which ist the correct file,
   just with the wrong name.
 * This code
 * `[mla_gallery post_mime_type=application/pdf post_parent=all link=file mla_target
   ="_blank"]`
 * gives me the same list of thumbnails with a different link structure:
    /wp-content/
   uploads/2022/03/mypdfname.pdf
 * and clicking on them downloads the right file with the right name.
 * Can I have “best of both worlds”? 🙂 The right filename AND the obscured link
   structure?
 * Thanks a lot!
    -  This reply was modified 4 years ago by [Gerdski](https://wordpress.org/support/users/gerdski/).
 *  Plugin Author [David Lingren](https://wordpress.org/support/users/dglingren/)
 * (@dglingren)
 * [4 years ago](https://wordpress.org/support/topic/cannot-open-pdfs/#post-15679455)
 * Thanks for your update with the good news on your progress. The `admin-ajax.php`
   refers to the WordPress code that processes the download request; it cannot be
   changed directly.
 * You might find a solution in the “MLA Item Transfer Pretty Links” example plugin,
   created for this earlier topic:
 * [How about [mla_gallery list=mask]?](https://wordpress.org/support/topic/how-about-mla_gallery-listmask/#post-9679887)
 * Have a look at that topic and the example plugin and let me know if it works 
   for you.
 *  Thread Starter [Gerdski](https://wordpress.org/support/users/gerdski/)
 * (@gerdski)
 * [4 years ago](https://wordpress.org/support/topic/cannot-open-pdfs/#post-15690770)
 * Hello,
 * thanks for your reply.
 * I installed the other plugin, but [mla_gallery list=mask] shows nothing.
    But
   maybe I haven’t understood the earlier topic you were linking to.
 * I failed at “I created a “publication” for a PDF file and looked at the corresponding
   single publication page, which lists the document title, file name and links 
   for “view” and “download”. Does this mean that I have to create a “publication”
   for every PDF file? This would make things hard for the customer, who is not 
   a web developer 🙂
 * But it doesn’t matter too much, I just thought that te obfuscation of the download
   link would be a nice security feature. I can use maybe .htaccess to hide files
   to non-logged-in-users.
 * Thanks a lot!
 *  Plugin Author [David Lingren](https://wordpress.org/support/users/dglingren/)
 * (@dglingren)
 * [4 years ago](https://wordpress.org/support/topic/cannot-open-pdfs/#post-15697356)
 * Thanks for finding and installing the example plugin I suggested. I regret that
   the instructions for using it are not very clear; I will update the settings 
   page to give more details along the lines of these remarks in the earlier topic:
 * >  The `mla_named_transfer=true` parameter implements the “simple” approach described
   > in the Settings/Media Library Assistant Documentation tab. The example plugin
   > adds the “more complex” alternative, transforming the links from the `admin-
   > ajax.php` format to something like:
   >     ```
   >     http://www.mysite.com/mla-transfer/view/my-item-slug
   >     http://www.mysite.com/mla-transfer/download/my-item-slug
   >     ```
   > 
   > The example plugin adds a Settings/MLA Pretty Links page that allows you to
   > change the “mla-transfer”, “download” and “view” portions of the pretty links.
   > It will transform any [mla_gallery] shortcode containing a mla_named_transfer
   > =true parameter.
 * The `list=mask` parameter was a suggestion from the person who started the earlier
   topic; I did not use it in the actual implementation. All you have to do is install**
   and activate** the example plugin and add `mla_named_transfer=true` to your shortcode(
   s).
 * Let me know if that works for you.
 *  Thread Starter [Gerdski](https://wordpress.org/support/users/gerdski/)
 * (@gerdski)
 * [4 years ago](https://wordpress.org/support/topic/cannot-open-pdfs/#post-15718163)
 * Hello,
 * thanks for your reply.
 * I have installed and activated WP Publication Archive Plugin (but have done nothing
   else with it).
 * With this shortcode:
    [mla_gallery post_mime_type=application/pdf post_parent
   =all link=file mla_target="_blank" mla_named_transfer=true] I am getting the 
   same results, no matter if the plugin is active or not: A download with the name
   of admin-ajax.pdf
 * Maybe I must do something with the other Plugin, but I have no Idea how it works…
 *  Plugin Author [David Lingren](https://wordpress.org/support/users/dglingren/)
 * (@dglingren)
 * [4 years ago](https://wordpress.org/support/topic/cannot-open-pdfs/#post-15721052)
 * Thanks for your update. I am not sure what the “WP Publication Archive Plugin”
   is, but it is not the plugin I recommended for your application. From the earlier
   topic:
 * >  To install the example plugin, navigate to the Settings/Media library Assistant
   > Documentation tab and click the “Example Plugins” button. You will see a table
   > that lists all the example plugins and gives you a “one-click” action for installing
   > them. Type “pretty” in the text box and click “Search Plugins” to filter the
   > table. You are looking for the “MLA Item Transfer Pretty Links” example plugin.
   > Find that plugin and hover over the title in the left-most column. Click the“
   > Install” rollover action, then go to the WordPress Plugins/Installed Plugins
   > submenu and activate it as you would any other plugin.
 * Please try the “MLA Item Transfer Pretty Links” example plugin and see if it 
   helps. Thanks..
 *  Thread Starter [Gerdski](https://wordpress.org/support/users/gerdski/)
 * (@gerdski)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/cannot-open-pdfs/#post-15776688)
 * Hello,
 * I think I know why there was a misunderstanding about the right plugin:
 * In the link you gave me:
    [https://wordpress.org/support/topic/how-about-mla_gallery-listmask/#post-9679887](https://wordpress.org/support/topic/how-about-mla_gallery-listmask/#post-9679887)
   the user “lwcorp” speaks of this plugin: [https://wordpress.org/plugins/wp-publication-archive/](https://wordpress.org/plugins/wp-publication-archive/)
   but you meant this one: MLA Item Transfer Pretty Links.
 * Will try that now…
 *  Thread Starter [Gerdski](https://wordpress.org/support/users/gerdski/)
 * (@gerdski)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/cannot-open-pdfs/#post-15776786)
 * Thanks for your great support! Sorry that my reply took so long…it is because
   the customer’s reply took so long :-/
    OK, I have activated the MLA Item Transfer
   Pretty Links Plugin.
 * (Wow…you wrote 75 Plugins for your main plugin!)
 * This Shortcode here gives me the link in a good format: /mla-transfer/view/mypdfname,
   but I get admin-ajax.pdf for download:
    [mla_gallery post_mime_type=application/
   pdf post_parent=all link=file mla_target=”_blank” mla_named_transfer=true include
   =”1,2,3″]
 * While this one here gives me the full path to /wp-content/2022/06/mypdfname.pdf,
   and I get mypdfname.pdf for download:
    [mla_gallery post_mime_type=application/
   pdf post_parent=all link=file mla_target=”_blank” include=”1,2,3″]
 * So, sorry to say, but it does not work for me yet.
 * Is there something wrong with my shortcode?
 * Thanks!
 *  Plugin Author [David Lingren](https://wordpress.org/support/users/dglingren/)
 * (@dglingren)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/cannot-open-pdfs/#post-15783189)
 * Thanks for your updates and for reporting your results.
 * You wrote “**_ I get admin-ajax.pdf for download_**“. I copied your shortcode
   to my test system and ran a test. As you wrote, the link embedded in the gallery
   item has the `/mla-transfer/view/` form generated by the Pretty Links plugin.
   When I click on the item, the document is downloaded and opens in a new browser
   tab. The URL displayed in the browser navigation text box has the form:
 *     ```
       http://mysite.com/wp-admin/admin-ajax.php?action=mla_named_transfer&mla_item=myitemd&mla_disposition=inline
       ```
   
 * Is that what you mean when you write “**_I get admin-ajax.pdf for download_**“?
   If so, I regret to confirm that this is a function of the way the browser and
   server work and I do not know any way to change that at this time. If you want
   to see the “pretty” link in the browser navigation text box I can look for a 
   solution but I cannot promise a good result. Let me know if I understand you 
   correctly and thanks for your understanding of my response.
 *  Thread Starter [Gerdski](https://wordpress.org/support/users/gerdski/)
 * (@gerdski)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/cannot-open-pdfs/#post-15788552)
 * > Is that what you mean when you write “I get admin-ajax.pdf for download“?
 * Yes. The browser wants to download admin-ajax.pdf, and it has the contents of
   the desired PDF.
 * > If you want to see the “pretty” link in the browser navigation text box I can
   look for a solution
 * No, that’s not necessary.
 * I was looking for a way to change the name from admin-ajax.pdf to the original
   file name of the pdf. If that’s not possible: no problem…the customer has just
   decided to display the PDF file name instad of the PDF preview, so there is no
   immediate solution needed any more.
 * I’ll definitely use your plugin/s in future projects where pretty links don’t
   need to be obfuscated 🙂
 * Thanks a lot for your help!
 *  Plugin Author [David Lingren](https://wordpress.org/support/users/dglingren/)
 * (@dglingren)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/cannot-open-pdfs/#post-15791586)
 * Thanks for confirming my understanding of your issue.
 * For others reading this topic in the future, let me give a more complete description
   of what is happening. The browser does not “download admin-ajax.pdf”.
 * The URL invokes the PHP code in the file `admin-ajax.php`. That code intreprets
   the `action=mla_named_transfer` argument and runs some PHP code within MLA, passing
   the `mla_item=myitemd` and `mla_disposition=inline` arguments to the MLA code.
   The MLA code
    finds the item named by `mla_item` and then downloads the file “
   attached” to that item.
 * The “MLA Item Transfer Pretty Links” plugin translates the original URL, e.g.,`/
   mla-transfer/view/myitemd` to the format required to perform the transfer. As
   I wrote, it might be possible to restore this original URL in the response returned
   from the transfer, but I have not looked into whether that is possible.
 * I hope that gives you and other MLA users a more detailed understanding of the
   process. I am marking this topic resolved, but please update it if you have problems
   or further questions about this MLA feature and example plugin. I hope you find
   MLA of use in future projects!

Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘Cannot open PDFs’ is closed to new replies.

 * ![](https://ps.w.org/media-library-assistant/assets/icon-256x256.png?rev=973502)
 * [Media Library Assistant](https://wordpress.org/plugins/media-library-assistant/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/media-library-assistant/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/media-library-assistant/)
 * [Active Topics](https://wordpress.org/support/plugin/media-library-assistant/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/media-library-assistant/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/media-library-assistant/reviews/)

 * 12 replies
 * 2 participants
 * Last reply from: [David Lingren](https://wordpress.org/support/users/dglingren/)
 * Last activity: [3 years, 11 months ago](https://wordpress.org/support/topic/cannot-open-pdfs/#post-15791586)
 * Status: resolved