PDF export is not working

I may have found a workaround using SC PDF Export in an SSL-only environment on Linux.
Problem: As of SC 8.1.051, SC prefixes the intermediate HTML file URL with http, whether your server is running SSL or not. Even if you insert https in your PDF Server IP, it replaces it with http.(You can see this in action by inspecting the log files created during a PDF export). I also suspect that the old version of the WKHTMLtoPDF library that SC uses may reference a deprecated OpenSSL library. Another reason why the export fails.
Solution: Move to the latest WKHTMLtoPDF binary and use web server rewrite rules to redirect http traffic to https.
Implementation (for Linux, although the concept should work for other platforms as well):
(1) Download a new WKHTMLtoPDF binary (depending on your environment) from here: http://wkhtmltopdf.org/downloads.html (Note: 0.12.3 worked for me)
(2) Replace the default SC production library file located at _lib/prod/third/wkhtmltopdf/linux-i386/wkhtmltopdf-i386 (Note: There are different subdirectories for i386, AMD, OSX, WIN, and similar binaries. I have not tested other binaries, so YMMV. I found it safer to just rename the default SC file rather than delete it, although the default SC file did not work for me.)
(3) Change the permission of wkhtmltopdf-i386 to 754 (make sure the group and owner are set properly for your environment). (Note: 744 did not work for me. More permissions were not necessary.)
(4) Set _lib/tmp folder permissions to 775. (Note: Both intermediate HTML and final PDF files are written here)
(5) In your production environment, select Configure Production Environment, and enter the server name instead of an IP address for the field PDF Server IP. For example, sc.mydomain.com.
(6) In your Apache or NGINX configuration, you need to create a rule to redirect http traffic to https:. Here are the relevant lines for NGINX:
server {
listen 80;
server_name sc.mydomain.com;
return 301 https://$server_name$request_uri;
}
(7) Restart your server so that the new configuration is used. On Ubuntu, it looks something like this for NGINX: sudo service nginx restart

Happy PDF exporting!

I’ve just had to re-fix this issue on a new server and I’ve found out that it’s very easy.
I just edited the production environment and set the server local path as “PDF server IP”:

[ATTACH=JSON]{“data-align”:“none”,“data-size”:“full”,“title”:“sc_pdf.png”,“data-attachmentid”:90277}[/ATTACH]

sc_pdf.png

1 Like