francoisjacquet / rosariosis

RosarioSIS Student Information System for school management.
https://www.rosariosis.org
GNU General Public License v2.0
513 stars 348 forks source link

Error generating report with wkhtmltopdf #247

Closed becosirtel closed 6 years ago

becosirtel commented 6 years ago

Good day François, I'm having an error while generating a pdf document and the error comes from i guest a missing / (slash) in the path to the file to be loaded. I've attached a pdf document of the outpout error message. May be the missing slash should be in between '~/assets/themes/' and '~/assets/js/' here is part of the error message "Warning: Failed to load file:///C:/wappstack/apache2/htdocs/rosariosis/assetsthemes/WPadmin/stylesheet_wkhtmltopdf.css (ignore) Warning: Failed to load file:///C:/wappstack/apache2/htdocs/rosariosis/assetsjs/warehouse_wkhtmltopdf.js (ignore)" wkhtmltopdf.pdf

I'm using Bitnami WAPP stack that ships with the following software versions: - Apache 2.4.12 - PostgreSQL 9.4.4-1, - PHP 5.4.45, - PHPPgAdmin 5.1 and rosarioSIS 3.8 on MS Windows 7 64bit.

francoisjacquet commented 6 years ago

Hello @becosirtel

Thank you for reporting the bug.

The lines of code translating paths to assets for PDF is here: https://github.com/francoisjacquet/rosariosis/blob/mobile/functions/PDF.php#L155

I was not able to reproduce the errors on a Windows 10 box with the WAPP stack and RosarioSIS 3.8 installed.

Maybe you have set the $RosarioPath variable in your config.inc.php file and forgot to add a trailing slash?

becosirtel commented 6 years ago

Good day dear François, Thank you about the missing trailing slash in the $RosarioPath in the config.inc.php file in front of 'assets' --> $wkhtmltopdfAssetsPath = 'C:/wappstack/apache2/htdocs/rosariosis/assets/'; In addition to that, I had to add the hyphens in front of the 'assets/' in the PDF.php#L123 to make it look like $wkhtmltopdfAssetsPath = $RosarioPath . '"assets/'; Finally I've installed the old wkhtmltox-win64_0.12.0-03c001d.exe instead of the new release of wkhtmltox-0.12.4_msvc2015-win64.exe. I don't know if it really matters but that's how I solved the solve issue. capture du 2018-04-18 08-40-05

francoisjacquet commented 6 years ago

Hello @becosirtel

Thank you for posting your solution.

I have tried setting those variables in the config.inc.php file on Windows 10, with trailing slash:

$wkhtmltopdfAssetsPath = 'C:/wappstack/apache2/htdocs/rosariosis/assets/';

and

$RosarioPath = 'C:/wappstack/apache2/htdocs/rosariosis/';

They both worked when trying to generate PDFs, and there was no need to edit the PDF.php file.