elliotblackburn/mdpdf

The "path" argument must be one of type string, Buffer, or URL. Received type boolean

enisz opened this issue · 7 comments

enisz commented

Hi @BlueHatbRit,

I was trying to generate a PDF file with your module with the programmatic API and I would like to keep the generated temporary HTML file (passed the debug: true to the options object). When the program is executed I get the error message mentioned in the title. I was using the following code (this example code is from the README):

const mdpdf = require('mdpdf');
const path = require('path');

let options = {
    source: path.join(__dirname, 'README.md'),
    destination: path.join(__dirname, 'output.pdf'),
    debug: true,
    pdf: {
        border : {
            top: "20mm",
            left: "20mm",
            right: "20mm",
            bottom: "20mm"
        },
        format: 'A4',
        orientation: 'portrait'
    }
};

mdpdf.convert(options).then((pdfPath) => {
    console.log('PDF Path:', pdfPath);
}).catch((err) => {
    console.error(err);
});

This is the full output of the program:

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be one of type string, Buffer, or URL. Received type boolean
    at Object.open (fs.js:408:3)
    at WriteStream.open (internal/fs/streams.js:267:12)
    at new WriteStream (internal/fs/streams.js:254:10)
    at Object.createWriteStream (fs.js:1731:10)
    at writeFile.then.then.then.then.then.then (C:\wamp64\www\pdf\node_modules\mdpdf\src\index.js:199:51)
    at tryCatcher (C:\wamp64\www\pdf\node_modules\bluebird\js\release\util.js:16:23)
    at Promise._settlePromiseFromHandler (C:\wamp64\www\pdf\node_modules\bluebird\js\release\promise.js:512:31)
    at Promise._settlePromise (C:\wamp64\www\pdf\node_modules\bluebird\js\release\promise.js:569:18)
    at Promise._settlePromise0 (C:\wamp64\www\pdf\node_modules\bluebird\js\release\promise.js:614:10)
    at Promise._settlePromises (C:\wamp64\www\pdf\node_modules\bluebird\js\release\promise.js:694:18)
    at _drainQueueStep (C:\wamp64\www\pdf\node_modules\bluebird\js\release\async.js:138:12)
    at _drainQueue (C:\wamp64\www\pdf\node_modules\bluebird\js\release\async.js:131:9)
    at Async._drainQueues (C:\wamp64\www\pdf\node_modules\bluebird\js\release\async.js:147:5)
    at Immediate.Async.drainQueues [as _onImmediate] (C:\wamp64\www\pdf\node_modules\bluebird\js\release\async.js:17:14)
    at runCallback (timers.js:705:18)
    at tryOnImmediate (timers.js:676:5)

Despite of the error message, every file is generated (even the _temp.html)

Project Folder Screenshot

Can you take a look?

Thanks!

Hi there @enisz, thanks for reporting this one, it's pretty weird! Sorry the example hasn't worked for you first time around, I'll take a look now since I have some time but may not be able to get back to you until the morning (UK time).

Hi @enisz, so sorry for the delay. The weekend was very busy and I unfortunately can only maintain this in my spare time.

I've just had a look and it would seem the documentation example is out of date which is really awful, so sorry! The debug option should actually be the path you wish to save the html debug file.

I hope this hasn't delayed you too much. I'm going to update the documentation now.

Docs are updated in released in 2.0.4 😄

enisz commented

Hi @BlueHatbRit,

No problem at all, thanks for checking it! My application is still in testing phase.

Thanks for your time!

Great, feel free to open a ticket if you notice any other issues or have any questions.

If you're able to, it would be really great to know what sort of application you're building so I can better understand how mdpdf is being used in the wild. I understand that may not be possible though :)

enisz commented

We need some kind of automated solution to process our software's install manual. The final document can contain different paragraphs and steps depending on our client's IT infrastructure. At the moment editing the word document is a manual task.

Now I'm converting this word document to markdown files (several files actually) and my program will gather these individual template files using a document config file. This config file will define which templates are required for our clients. I'm building a command line tool, and the parameters can be provided by flags.

The templates will be joined in a single markdown document. From this markdown file I'm generating a PDF using your program. I need the HTML file, to see how the elements are formatted in it to be able to create a CSS file to change the appereance similar to my company's documentation colors, fonts, etc...

Sounds like a great use of mdpdf! Good to know people are using the api as well, I thought most people just used the cli. Do feel free to send PR's or put in feature suggestions, I don't get a huge amount of time for it these days but I'm always looking to improve the project when I can.

Thanks for sharing the details :)