Docx via stream?
Closed this issue · 7 comments
Not sure if this is just me, but I am having trouble converting markdown to docx via pdc.stream
. All other formats I've tried work, and md => docx works via the pandoc command line. Running through pdc stream results in a zero-byte file.
Any ideas?
While the following command line works,
pandoc -f markdown -t docx -o README.docx README.md
the following (which is what pdc does) doesn't work.
cat README.md | pandoc -f markdown -t docx > README.docx
Pandoc will print the following message to stderr.
pandoc.exe: Cannot write docx output to stdout.
Specify an output file using the -o option.
So this won't work with streams, sorry.
The same applies to PDF, which will say:
pandoc.exe: Unknown writer: pdf
To create a pdf with pandoc, use the latex or beamer writer and specify
an output file with .pdf extension (pandoc -t latex -o filename.pdf).
So this is basically an issue with Pandoc itself, since it doesn't support streams for PDF and DOCX.
It also applies to EPUB and probably all other binary formats.
Here's a workaround for using DOCX with stdin only:
var fs = require('fs');
var pdc = require('pdc');
var rs = fs.createReadStream('README.md');
var pandoc = pdc.stream('markdown', 'docx', [ '-o', 'README.docx' ]);
rs.pipe(pandoc.stdin);
Sorry for the delay, meant to close this. Thanks for the update and the workaround.
@pvorb can I use url as input here ? I just want to get an docx file use url . thanks a lot
@zhouseahe I guess so. Test it and tell us what you found out.