astefanutti / decktape

PDF exporter for HTML presentations
MIT License
2.21k stars 177 forks source link

Escaping problem with relative path on Windows #45

Closed gdrolet closed 7 years ago

gdrolet commented 8 years ago

I run this command in Windows 7 (64):

> bin\phantomjs.exe decktape.js reveal file:///E:\Code\conf1.html E:\Temp\test_decktape.pdf

I get the pdf but there's also an error that seems to be caused by escaping of special characters in the windows shell:

Loading page file:///E:\Code\conf1.html ...
+- Unable to load resource from URL: e:Codeconf1_fileseveal.js-3.2.0/css/print/paper.css
|_ Error code: 301
|_ Description: Protocol "e" is unknown
Loading page finished with status: success
Reveal JS DeckTape plugin activated
Printing slide #/portrait-statistique-pour-le-quebec-2003-2014-1 (7/7) ...
Printed 7 slides

Is this a bug or is just that I should specify my input file name differently?

astefanutti commented 8 years ago

It may be related to ariya/phantomjs#14194. Is the CSS file path relative?

gdrolet commented 8 years ago

In the HTML, there's this block:

    <script>
      var link = document.createElement( 'link' );
      link.rel = 'stylesheet';
      link.type = 'text/css';
      link.href = window.location.search.match( /print-pdf/gi ) ? 'conf1_files\reveal.js-3.2.0/css/print/pdf.css' : 'conf1_files\reveal.js-3.2.0/css/print/paper.css';
      document.getElementsByTagName( 'head' )[0].appendChild( link );
    </script>

I replaced (relative) paths to pdf.css with absolute paths (also replacing all backslashes with one forward slash):

<script>
      var link = document.createElement( 'link' );
      link.rel = 'stylesheet';
      link.type = 'text/css';
      link.href = window.location.search.match( /print-pdf/gi ) ? /E:/Code/conf1_files/reveal.js-3.2.0/css/print/pdf.css' : 'E:/Code/conf1_files/reveal.js-3.2.0/css/print/pdf.css';
      document.getElementsByTagName( 'head' )[0].appendChild( link );
    </script>

I don't get any error message when I run decktape but the result is not pretty... The same slide is repeated on all the slides and is an overlap of a few slides, not centered (i.e. text is cut as if text was out of the slide).

Do you have any suggestions on what I should do next or if you think this is a bug?

PhantomJS version: 2.0.0 (installed from Win 64 binaries) Windows 7 Enterprise

Thanks

astefanutti commented 8 years ago

The original issue is likely related to ariya/phantomjs#14194.

When you test with the absolute path, could you try adding the file:// prefix?

As you're using Reveal.js, one option is to run grunt serve so that it's served on http://localhost:8000 and export it by using HTTP.

gdrolet commented 8 years ago

Ok thanks. And how would I export it using HTTP? With the Chrome PDF exporter plugin?

I tried creating the HTML (from markdown) with the self_contained = FALSE (I was using self_contained = TRUE). In the resulting HTML I get much more paths to reveal.js files but even after making the path modifications it doesn't work. In fact I get many more error messages (one for each of the paths its trying to access). Since when I use self_contained = TRUE I get only one error message (the one related to the Githubissues.

  • Githubissues is a development platform for aggregating issues.