Can JS Doc generate PDF
Asked Answered
E

3

12

I am using JS Doc version 3 (https://github.com/jsdoc3/jsdoc). When I run the tool, by default it generates documentation in HTML format. Is it possible to generate doc in PDF format?

Extinction answered 11/10, 2016 at 15:2 Comment(3)
After you have your HTML run them through http://wkhtmltopdf.org/Maltase
This is the solution proposed by https://mcmap.net/q/1010078/-jsdoc-to-pdf-rendererVertu
No, not on it's own. Like @ZoltanToth suggested, use wkhtmltopdf.Indices
A
8

I would suggest you look at jsPDF. It is pretty cool and easy to use.

The code you download from the mentioned side contains reach examples.

What is jsPDF: A HTML5 client-side solution for generating PDFs. Perfect for event tickets, reports, certificates, you name it!

For example to generate pdf of html, just write following code.

var doc = new jsPDF();

// We'll make our own renderer to skip this editor
var specialElementHandlers = {
    '#editor': function(element, renderer){
        return true;
    }
};

// All units are in the set measurement for the document
// This can be changed to "pt" (points), "mm" (Default), "cm", "in"
doc.fromHTML($('body').get(0), 15, 15, {
    'width': 170, 
    'elementHandlers': specialElementHandlers
});

This is a snapshot of the sample page jsPDF that you get in your download. It contains different example types, codes and pdf generation example.

enter image description here

Armillas answered 16/10, 2016 at 17:17 Comment(0)
S
5

Currently there is no tool for converting jsdoc directly to PDF, but you can convert it to some intermediate format (markdown in this example), and then convert it to PDF:

  1. Install required tools

    $ npm install -g markdown-pdf
    $ npm install -g jsdoc-to-markdown
    
  2. Generate single markdown file with documentation

    $ jsdoc2md path/to/your/code/** > docs.md
    
  3. Convert markdown file to PDF:

    $ markdown-pdf docs.md
    

You can change how documentation looks using css stylesheets (here you can find an example stylesheet).

Sully answered 19/10, 2016 at 13:51 Comment(0)
S
0

you got html files now, there are so many tools to convert html to pdf (i assume you use node.js)

Spinifex answered 15/10, 2016 at 14:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.