PDF export is not working

PDF files get generated using HTTPS and authentication if in apache 2.4 I use this config to allow unauthenticated\HTTP from localhost

alias /cmdb “/var/www/html/prod/cmdb”
<Directory “/var/www/html/prod/cmdb”>
<If “%{REMOTE_ADDR} -ipmatch ‘x.x.x.x’”>
Require local granted
</If>
<Else>
SSLRequireSSL


</Else>
</Directory>

It seems to work only if, as x.x.x.x I use the real IP of the network interface and not 127.0.0.1.
The only issue with this is that the config should be reviewed in cases of migrations\changes of ip addresses.

Btw, I know next to nothing of apache configuration, so maybe someone has a better idea on how to accomplish the same.

I couldn’t live with an IP hardcoded in the apache config.
So I changed it to:


<Directory “/var/www/html/prod/cmdb”>
<If “%{HTTPS} = ‘off’”>
Require local granted
</If>
<Else>
SSLRequireSSL

And it still works: all HTTP requests are accepted from localhost only, so SC is still happy when creating PDF files.

I also noticed if the client is accessing the deployed app via https://servername.domain.com/
SC generates this command line on the server:

./wkhtmltopdf-amd64 --page-size Letter --orientation Portrait --header-right “[page]” --javascript-delay 2000 http://servername.domain.com/cmdb/_lib/tmp/sc_g…s4aebsjq3.html /var/www/html/prod/cmdb/_lib/tmp/sc_pdf_20150124132046_127_grid_ci.pdf

This can make PDF not working again when the server is not able to resolve correctly the name used by the client; e.g. if the client is in the public Internet namespace and the server is in a private DMZ.

As SC is changing the original client request from HTTPS to HTTP, maybe it should also change any ‘hostname.domain.tld’ in the HTTP header to ‘localhost’ .

Any feedback on this matter? Mine also have a same problem.

I can’t view the pdf and the downloaded pdf report also cannot be viewed. Do I need to upload the tcpdf to the server to and configure it back in my <prod>/_lib setting page?

No, this bug has been ignored by NetMake for more than a year.

Dave

[QUOTE=daveprue;33302]No, this bug has been ignored by NetMake for more than a year.

Dave[/QUOTE]

Means that it has been fixed or not? Really need help here as my production server has been up and running. The pdf works fine locally (including local separate development server for testing) but the production server is not working. Do I need to configure something in the production environment??

The bug still exists as far as I know.

After several months of waiting and hoping, I changed our site to use TCPDF calls directly, rather than using ScriptCase’s pdf functionality.

Dave

[QUOTE=daveprue;33302]No, this bug has been ignored by NetMake for more than a year.

Dave[/QUOTE]

BUG is whether you can replicate the problem in all situations, or under some specific situations.

AFAIK, PDF export problems are related to permissions.

Giu,

BUG is whether you can replicate the problem in all situations, or under some specific situations.

I appreciate you trying to clarify for me, however my 35 years of managing software development projects has given me a fairly good idea of what a bug is.

If you read the thread, scriptcase is inserting an http:// reference into the wkhtmltopdf input file. This is absolutely wrong. It should be an absolute path. It is a BUG. It does not cause problems for everyone, because some people do not care to use https, but it is repeatable and it is a bug.

AFAIK, PDF export problems are related to permissions.

Many times they are, but that is not what we are talking about.

I reported this bug well over a year ago, and like all the bugs I have reported, have heard nothing back.

Dave

[QUOTE=daveprue;33305]The bug still exists as far as I know.

After several months of waiting and hoping, I changed our site to use TCPDF calls directly, rather than using ScriptCase’s pdf functionality.

Dave[/QUOTE]

Hi Dave,

How to configure the site using TCPDF? I’ve downloaded TCPDF from their site and have no idea to install it. I’ve uploaded the whole TCPDF files to production server and put in into /home/<myservername>/public_html/tcpdf. However, I’ve no idea how to configure it inside the production environment area. Do I need to put it into PDF Server IP field? Is it localhost/tcpdf?

Kindly advise…

Sorry then Dave, didnt readed all the thread…my fault.

Zam2best… Tcpdf is bundled with SC. Sorry to not explain it more…im on mobile right now.

[QUOTE=Giu;33410]Sorry then Dave, didnt readed all the thread…my fault.

Zam2best… Tcpdf is bundled with SC. Sorry to not explain it more…im on mobile right now.[/QUOTE]

Hi Giu,

Yeah its true. TCPDF also included in library and once we deploy the application into production server, it suppose to work as the one that I’ve deployed in development server. Anyway, strangely the export to PDF didn’t work in production server (it works in deployment server). So, i’ve been thinking to use separate TCPDF deployed in seperate folder to solve the issue.

Anyone have done this before? Or is there any other way to solve the export to PDF issue? My application has up and running in production server, so I really need to solve this issue as fast as possible. Thank you in advance…

Hi to all (except john),

Do you have any update on this issue? I am also experiencing the same since I updated my scriptcase.

Hi

I am having the same problem here. I want to have export from sc grid to pdf working on an ssl enviroment. This is what I have tried so far :

  • Yes I am having my _lib/tmp and _lib/prod/third/wkhtmltopdf set to 777 to avoid security issues

  • Yes Java JRE is installed

  • I hired an other shared domain and tried to get the very willing helpdeskers so far to come with a solution. No success…

  • I hired a blade VPS with Linux CentOS.

  • I had to instal libXrender to get it working (this was promped when I tried to run it from the linux bash.

  • In my public_html folder now everything works without SSL fine. But using SSL I moved to private_html folder in the same domain. I am having the same problems.

When I try to export to PDF is says I can view or download. View results in a page not found. In the tmp folder there is no pdf file. The log file and the corresponding html are there.

This is my log :
./wkhtmltopdf-amd64 --page-size Letter --orientation Portrait --header-right “[page]” https://www.mydomain.eu/myapp/_lib/tmp/sc_grid_adressen_html_55rlrf2iaq2u15hkinsv2pfe47.html /home/admin/domains/mydomain.eu/private_html/myapp/_lib/tmp/sc_pdf_20150902102307_693_grid_adressen.pdf

As suggested I have run the command from the log file in the linux bash. Wkhtmltopdf results in an Error: Failed loading page. It is suggested to try the – ignore load error option. I tried that and than the pdf is generated. Thats nice, but it does not give me a solution for my problem.

my conclusions :

  • it cannot have anything to do with my application, it works fine without SSL.
  • It cannot have anything to do with my server configuration, because it works fine on the same server without SSL.
  • It cannot have anything to do with my grants, it is the samen in public_html and private_html.

I do not know how to go from here ? Any suggestions. Any help will be highly appreceated.

Greetings.

Roelof

@roelof

Does access to https://www.mydomain.eu requires authentication?

If so and that’s the issue you could try something like what I did on my CentOS box (see my previous posts in this thread).
I don’t think my specific confg would apply to your case (I also had the “HTTPS to HTTP” issue of the older SC version).
but if in the apache config you can differentiate when the request is coming from the pdf generation command line, you should be able to solve your issue.
Note that in the Production environment configuration there’s a “PDF Server IP” setting (blank by default).
I never used it but you could try and see if it can help you in differentiate the request from the normal access to your site, or maybe give you an idea for a different solution to your problem

Hi Robudago,

Thanks for your reply. My domain does not need any authentication other than scriptcase which is an authentication on application level. I have set the value to my prod server enviroment to www.mydomain.eu. I even tried my IP. My VPS is a CentOS box indeed. I installed the latest version wkhmltopdf and all the dependent font packages.

I can run it from SSL with the option load error handing ignore. It did generate a pdf but an empty one, only containing a number 1 but no data. The html looks fine. I cannot find a way to set the ignore option permanently. I do not think it is a good idea to hack my scriptcase code so it will put this option on. My CentOS box runs 3 ip adresses. Two of them are used by SSL domains. I can use wget to load the scriptcase html, i can write from wkhtml to the tmp folder I also checked that. I even replace the links to the css files with full path links and css. wget has no problem with these links. So that cannot be the problemen.

When I run wkhtmltopdf-amd64 https://www.google.com.ph google.pdf the result is perfect. But my scriptcase html was not accepted.

Has anybody a suggestion ?

Robydago can you document this : “apache config you can differentiate when the request is coming from the pdf generation command line”. It is possible apache is the problem here. How did you resolve this ? I googled a lot, but it didn’t help.

Roelof

See if it works for them …
grant permissions to 744 files
_lib / prod / third / wkhtmltopdf / linux-amd64 / wkhtmltopdf-amd64
There I generate PDF from a grid !!!
I guess you have to do the same in cases of i386 on
/ _lib / prod / third / wkhtmltopdf / linux-i386 / i386-wkhtmltopdf

Luis

It’s in this thread. see my previous messages.

What code call is ScriptCase making internally to generate the PDF? If it works on Windows, then it must be a permissions problem of some kind on Linux, or it can’t find
an external utility required to generate the PDF.

[QUOTE=jcrebel;31408]I have the same issue - Linux all rights are correct. PDF never gets generated. It says it does but the file is not in the tmp folder.
I have a windows dev environment and it does works as I have tested it. So anyone else have this issue on Linux? I believe this
could be just a run issue on commercial linux shared hosting systems? - no rights to run a bin from the user account ?

Any ideas?[/QUOTE]

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