1.1.3 • Published 4 years ago

@infosupport/kc-print v1.1.3

Weekly downloads
2
License
UNLICENSED
Repository
gitlab
Last release
4 years ago

kc-print

The best way to print kc cli presentations to PDF.

Why this repo exists

The kc-cli uses Reveal.js and we wanted to export our slick presentations to PDF as handouts. There are a couple of options to do this:

  • Append ?print-pdf to the address bar, then print. In the print screen, Chrome offers a "Save as PDF" destination.

    This option is easy to accomplish, but slides do not come out well. At all. Slides overlap, styling disappears, fonts gets mangled, no corporate design.

  • Use an external PDF printer, like Decktape. This export shows the slides as they are, which is great.

    Decktape unfortunately has a dependency called HummusJS, a PDF library that requires Visual Studio C++ compilers to be installed on the machine.

  • Get creative. For example, one could grab Puppeteer, create screenshots of every slide and use a PDF library like PDFKit to generate a PDF.

    With this, the PDF looks exactly how we want it and we don't have any pesky dependencies that rely on C++ compilers, so it works everywhere. But, because we're placing lots of screenshots in a PDF, the PDF size increases dramatically (> 100MB). Also, the PDF cannot be searched for text.

Initially, we executed the last option. But searchability was too important to simply discard.

So we went back to the drawing board and decided to combine Decktape with a bit of customization. Decktape exports the presentation to one big PDF where every slide is a page and we transform that into a PDF that complies with our corporate design. This way, we get a PDF that looks exactly how we want it, it's small in size and it's searchable. Yay!

Unfortunately, because of the reliance on C++ compilers, this solution does not work on all machines. Specially Windows machines that do not have Visual Studio installed. During the installation of the npm package, it will crash. This is why this is in a separate repo. The kc cli installation should not fail because of some PDF printer. People have presentations or courses to give.

Installation

As mentioned above, the installation phase is where it will crash if your machine is not equipped with the right stuff. See Possible solutions for help.

npm install --global @infosupport/kc-print

Usage

First, use the kc cli to serve your presentation (kc serve). Then run kc print.

optiondescription
kc print --url [url] --output [filename]print presentation to pdf

Possible solutions

  • Install Visual Studio. I know. That's a lot.
  • Install windows-build-tools. This can take several hours. Not kidding.
    npm install --global windows-build-tools --production
  • If, after installing windows-build-tools, you get this error:

    MSBUILD : error MSB4132: The tools version "2.0" is unrecognized. Available tools versions are "4.0"

    Check this issue for possible fixes, like:

    open up a new cmd as administrator and run this command:

    		npm install --global --production windows-build-tools
    		```
    then
    ```bash
    		npm config set msvs_version 2015 --global
    		```
    close all instances of shell/cmd, reopen a cmd (regular this time, non-administrator) return to your directory where you are trying to run npm install and run it again
  • Ask a colleague to export the PDF for you. Hopefully kc print will work on his machine.

2.0.0-beta.1

4 years ago

2.0.0-beta.0

4 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.1-beta.3

5 years ago

1.0.1-beta.2

5 years ago

1.0.1-beta.1

5 years ago

1.0.1-beta.0

5 years ago

1.0.0

5 years ago