Answers.Body: <p>For anyone looking to do this on Craft 3, I used pThumb previously, but I created a plugin specifically to do this for Craft 3 - <a href="https://github.com/bymayo/craft-pdf-transform" rel="nofollow noreferrer">https://github.com/bymayo/craft-pdf-transform</a></p>
  
  <p>It takes Asset PDF files and coverts them to JPEG / PNG files automatically when they are uploaded.</p>
  
  <p>Or, do theres a Twig method that lets you convert the PDF to an image if the image already exists in Assets. But this can be a bit labour intensive on the server to do when a template is rendering so is only advised for small files.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-10T08:49:56.780Z
Answers.LastActivityDate: 2019-01-10T08:49:56.780Z
Answers.UserDisplayName: Jason Mayo
Body: <p>I'm using the most recent Craft CMS 2.6.2791. I'd like to generate preview thumbnails for pdf assets in my templates, so I found this plugin:</p>
  
  <p><a href="https://github.com/carnesmedia/pthumb" rel="nofollow">https://github.com/carnesmedia/pthumb</a></p>
  
  <p>However, following the instructions on the readme page gives a nonsense url. In my template, I have:</p>
  
  <pre><code>&lt;img src="{{ craft.PThumb.thumbnail(pdf) }}"&gt;
  </code></pre>
  
  <p>If I inspect the src generated by this I see</p>
  
  <pre><code>http://localhost:8888/myproject/public//assets/pdfs/previews/b15c8529f2b4a9b354c5e592e84d1ac5.png
  </code></pre>
  
  <p>However, this renders as a broken image. I check my project structure and the previews directory is nowhere to be found. Am I doing something wrong or perhaps missing a step? </p>
  
  <p>I'm also open to any other solutions that could generate a thumbnail from the first page of a pdf asset automatically. Thanks!</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-06-24T08:05:36.670Z
Comments.Text: You have two forward slashes after the public folder in your URL: `public//assets/pdfs`. If you visit the image URL and remove the extra slash, does the image load?
Comments.UserDisplayName: Jamie Wade
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-06-24T16:40:07.043Z
Comments.Text: Never used the plugin, but anything unusual showing up in `craft/storage/runtime/logs`?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-06-24T18:14:00.767Z
Comments.Text: the double slash doesn't seem to matter. Actually it's because I put my {{siteURL}} in front of the thumbnail expression so my img tag actually looks like `<img src="{{siteUrl}}{{ craft.PThumb.thumbnail(pdf) }}">`. When {{siteUrl}} gets interpreted, craft seems to always add a slash at the end. This doesn't really prevent the url from being loaded though, at least if you enter it in the browser url bar. And I don't see anything happen to the most recent log in `craft/storage/runtime/logs` when I make changes to this template.
Comments.UserDisplayName: ChaiTea
Tags: <templating><assets><pdf>
Title: PDF preview thumbnail options?
ThreadText: # PDF preview thumbnail options?
  
  (Asked by: username_0 on 2016-06-23)
  
  I'm using the most recent Craft CMS 2.6.2791. I'd like to generate preview thumbnails for pdf assets in my templates, so I found this plugin:
  
  <https://github.com/carnesmedia/pthumb>
  
  However, following the instructions on the readme page gives a nonsense url. In my template, I have:
  
  ```
  <img src="{{ craft.PThumb.thumbnail(pdf) }}">
  
  ```
  
  If I inspect the src generated by this I see
  
  ```
  http://localhost:8888/myproject/public//assets/pdfs/previews/b15c8529f2b4a9b354c5e592e84d1ac5.png
  
  ```
  
  However, this renders as a broken image. I check my project structure and the previews directory is nowhere to be found. Am I doing something wrong or perhaps missing a step?
  
  I'm also open to any other solutions that could generate a thumbnail from the first page of a pdf asset automatically. Thanks!
  
  **Tags:** templating, assets, pdf
  
  > **Comments:**
  > **username_1**: You have two forward slashes after the public folder in your URL: `public//assets/pdfs`. If you visit the image URL and remove the extra slash, does the image load?  
  > **username_2**: Never used the plugin, but anything unusual showing up in `craft/storage/runtime/logs`?  
  > **username_0**: the double slash doesn't seem to matter. Actually it's because I put my {{siteURL}} in front of the thumbnail expression so my img tag actually looks like `<img src="{{siteUrl}}{{ craft.PThumb.thumbnail(pdf) }}">`. When {{siteUrl}} gets interpreted, craft seems to always add a slash at the end. This doesn't really prevent the url from being loaded though, at least if you enter it in the browser url bar. And I don't see anything happen to the most recent log in `craft/storage/runtime/logs` when I make changes to this template.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_3 on 2019-01-10. Score: 3
  
  For anyone looking to do this on Craft 3, I used pThumb previously, but I created a plugin specifically to do this for Craft 3 - <https://github.com/bymayo/craft-pdf-transform>
  
  It takes Asset PDF files and coverts them to JPEG / PNG files automatically when they are uploaded.
  
  Or, do theres a Twig method that lets you convert the PDF to an image if the image already exists in Assets. But this can be a bit labour intensive on the server to do when a template is rendering so is only advised for small files.
  
  
  ---
  
  