ggrossetie / asciidoctor-web-pdf

Convert AsciiDoc documents to PDF using web technologies
https://asciidoctor.org
MIT License
455 stars 92 forks source link

How to use asciidoctor-web-pdf with node.js script? #686

Closed stefaneidelloth closed 1 year ago

stefaneidelloth commented 1 year ago

Currently I use asciidoctor.js as shown below. How can I integrate asciidoctor-web-pdf in that worklfow to also produce pdf output and open the pdf file? I tried as denoted by the comments but it did not work.

// Run this file using npm from main directory: "npm run doc"
// Documentation of asciidoctor.js:
// https://docs.asciidoctor.org/asciidoctor.js/latest/setup/quick-tour/

const asciidoctor = require('asciidoctor')(); // eslint-disable-line import/no-extraneous-dependencies
//const asciidoctorPdf = require('asciidoctor-web-pdf')(); // eslint-disable-line import/no-extraneous-dependencies
const open = require('open'); // eslint-disable-line import/no-extraneous-dependencies

// create html output
asciidoctor.convertFile('doc/index.adoc', { safe: 'safe', to_dir: './public', mkdirs: true });

//create pdf output
//asciidoctorPdf.convertFile('doc/index.adoc', { safe: 'safe', to_dir: './public', mkdirs: true });

// open html output in default browser
open('./public/index.html');

Related:

https://github.com/asciidoctor/asciidoctor.js/issues/1703

ggrossetie commented 1 year ago

Please direct usage question to the project chat at chat.asciidoctor.org. You can find more information about the support policy on the following page in the docs: docs.asciidoctor.org/about/support.