Warning: https://ipfire.localdomain:444/include/rrdimage.js:32 SyntaxError: Parse error

Hello Leo @luani,

Hope all is well with you!

I am experimenting with wkhtmltopdf and I was printing some IPFire WebGUI pages and I came across an error.

I don’t know javascript and so I don’t know if this is an issue or not.

Warning: https://ipfire.localdomain:444/include/rrdimage.js:32 SyntaxError: Parse error

for more info on the error - click here
iMac3:~ jcmurphy$ wkhtmltopdf --debug-javascript --username admin --password <myPassword> https://ipfire.localdomain:444/cgi-bin/index.cgi index.cgi.pdf
Loading pages (1/6)
Warning: SSL error ignored                                        
Warning: SSL error ignored                                        
Warning: SSL error ignored
Warning: SSL error ignored
Warning: https://ipfire.localdomain:444/include/rrdimage.js:32 SyntaxError: Parse error
libpng warning: iCCP: known incorrect sRGB profile
Counting pages (2/6)                                               
Resolving links (4/6)                                                       
Loading headers and footers (5/6)                                           
Printing pages (6/6)
Done                                                                      
iMac3:~ jcmurphy$

Which I think is this line:

Is this something that needs attention? Should I add a bug report in bugzilla?


Also I did noticed is that rrdimage.js is part of every IPFire WebGUI page even though there is no rrd image on every page.

Should this only be included when an rrd image is present?

Sorry for putting my nose where it does not belong!

Jon

Hello @jon,

I’m fine, and I hope all is well with you too!

I never heard of wkhtmltopdf before, but I think I might be able to help.
(Edit 2: Thanks for the great bug description, I could easily reproduce the issue!)

I used some “modern” javascript features in rrdimg.js, which were introduced with ECMAScript 6 in 2015.
As far as I could find, wkhtmltopdf uses QtWebkit as the underlying web engine. Unfortunately, this engine seems to be outdated/unmaintained and does not support ES6:

So rrdimg.js should work fine in any modern browser and you don’t need to report a bug :slight_smile:

To make this all work for you with wkhtmltopdf, you can use a javascript transpiler and convert rrdimg.js back to the ES5 standard (look for the !es2015 preset).
But I’m afraid you might also run into issues with jQuery and CSS.

Edit: On second thought, I think you can even ignore the error, if that’s possible. rrdimage.js doesn’t do anything necessary for the initial page content that you want to capture.

In a perfect world, yes. But there is no good system in the existing CGIs to add such scripts dynamically to the header. And I couldn’t think of an easy way to add one either.
All the javascript does by itself is search for graphs and attach events to the time range select buttons. Yes, this does waste a few milliseconds on each page load, but I don’t think anybody minds.

No worries! I enjoy discussing my work and I always learn something new along the way. I hope I could help!

Regards
Leo

2 Likes

Hi Leo,

Thank you for the quick answer!

Glad to hear! I assumed it was a wkhtmltopdf issue but I wanted to be sure.

I don’t want to be re-compiling the code. I’m going try a few more things with wkhtmltopdf. I know I can add a parameter to --disable-javascript and that gets rid of the error.

I may end up going back to the “manual” method.

For an overly complete back-up of my system I do a page print to PDF of most every IPFire WebGUI page. This is only done once a year but I have found it to be a lifesaver when all goes bad/ugly!

for boring Manual Method - click here

Manual Method

  • Go to menu System > Home
  • click Print
  • click Save to PDF

  • Go to menu System > Mail Service
  • click Print
  • click Save to PDF

  • [continue for most every menu item]

:sleeping: :sleeping:

So I want to automate this using wkhtmltopdf…

Would you mind trying one more thing?

wkhtmltopdf --debug-javascript --username admin --password <myPassword> https://ipfire.localdomain:444/cgi-bin/backup.cgi backup.cgi.pdf

If you open backup.cgi.pdf do you get LOTS of extra pages? (it should only be one PDF page long)

Again I am guessing this is a wkhtmltopdf issue and I’ll take it up with them. I am worried it might be a IPFire webgui issue.

Hi Jon,

That is a great idea, I like to do that too! I believe there is a firefox addon to assign a hotkey with “save to pdf”, but I can’t find it anymore.

I only get one page. But my backup list contains only three backups. Maybe it fails if there are more entries?

.\wkhtmltoimage.exe --version
wkhtmltoimage 0.12.6 (with patched qt)

Maybe: print (and then save to file)?

1 Like