3

I am using the Printmaker plugin to print a pdf. Everything seems to be working well when the site is not being forced to use SSL.

I am getting the message "Failed to load PDF document."

If I remove the SSL, the pdf renders correctly. I would really like to have my site be under https - is there any way to help printmaker work?

I don't see anything obvious in the craft.log that would indicate an error, is there a configuration setting I'm missing?

Thank you for any suggestions!

EDIT

It is the actual image(s) in the pdf that are causing the error.

The full path to the S3 bucket is https, and I'm able to access the image just straight through the browser. I've copied/paste into the url bar and the image will render.

  • If I set the S3 path to http, and set the browser to http - all is well.
  • If I set the S3 path to https, and the browser to http - all is well.
  • If I set the S3 path to https and the browser to https - pdf fails to render.

UPDATE

To further test and and attempt to get some kind of error message/log to help trouble shoot, I've moved my image directory to a local path. I now the error "Image not found or type unknown". It looks like this could be a DOMPDF issue. I will continue to update this thread as I uncover more.

UPDATE

It does seem to be something related to forcing requests to SSL. If I remove https, the pdf renders every single time, every browser. If the request is made to the pdf using https, it fails every time.

3

UPDATE 2/Resolution

I don't really have an explanation for what was happening. Hopefully this will help others if they experience the same. I'm happy to update the answer however if anyone has suggestions.

I am forcing https on my site via .htaccess.

The pdf would render 100% of the time in every browser when the request was made using http. When the pdf was requested using https In Chrome I would always get "Failed to load PDF document". Firefox would always work and Safari would give me a grey screen. For others, it would work sporadically.

All of my images are being served from an S3 source (all https) so all of my assets were secure.

I ended up making my .htaccess file force https for everything except the request to the pdf.

RewriteCond %{HTTP:X-Forwarded-Proto} !^https
RewriteCond %{QUERY_STRING} !(^|&)entryId=(.*?)(&|$) [NC]
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [NC,R=301,L]

RewriteCond %{HTTP:X-Forwarded-Proto} ^https
RewriteCond %{QUERY_STRING} entryId=(.*?)(&|$) [NC]
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [NC,R=301,L] 

The url to my pdf looks like this:

https://mysite.com/entry/pdf?entryId=123

When a user makes a request to that url, they are redirected (301) to a non-https version.

http://mysite.com/entry/pdf?entryId=123

Hope this helps someone else!

1

Check your urls in your admin panel - e.g. the site url under the "General" panel, and then also anything under Assets. Is that set to be https? Or just http?

If, for example, your asset folder is set to be http://www.mysite.com/images/ and you load https://www.mysite.com/page.html - images on that page will try to load from http://www.mysite.com/image.jpg

edit: Chrome will block http items from loading on an https page, and firefox will not. (at least by default)

7
  • Hi SamC - all of the assets are coming from an S3 prefix. I've made sure to set all of the S3 url's to include https. I did not have the site settings to include https. I tried but got the same result. "Failed to load PDF". Odly enough, Firefox works...
    – Damon
    Jun 23 '17 at 15:00
  • Ah. I haven't used S3 much via SSL - Can you get images to load on an https page from that S3 bucket?
    – SamC
    Jun 23 '17 at 19:01
  • Yep! Everything works great otherwise - Firefox even renders the PDF.
    – Damon
    Jun 23 '17 at 19:26
  • Well, firefox will display mixed http & https content with an error over the lock. Whereas chrome won't load the non-https stuff at all. I was suggesting that if chrome won't show an image from S3, it's an http/https setting. If chrome does show an image from the S3, it's something more specific to chrome. that make more sense?
    – SamC
    Jun 23 '17 at 19:57
  • Yep! makes sense to me. Turns out its the actual image(s) that are causing the problem.
    – Damon
    Jun 23 '17 at 21:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.