How to convert a RTF string or stream to PDF without passing the filepath

Product: PDFNet Windows

Product Version:9.2.0

I am trying to convert a RTF stream or a string to PDF using the toPdf() option in Convert class. But it only takes the file path as the input. Is there any other way to send an RTF string or a stream to convert into PDF? I tried using the Filter options as well StreamingPDFConversion(), but it doesn’t support the RTF extension. Any idea on this one?

Thank you,

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:


Please note that we do not currently support direct/internal conversion of RTF files. Instead, a 3rd party application, installed on the Windows computer, is needed, and this communication with the 3rd party application requires the file to be on the filesystem.

You could try using a RAM Drive as a work around.

So just to clarify this point with what’s in the (nodeJs) docs for toPdf:
in_filename: the path to the document to be converted to pdf Note: Internally formats include BMP, EMF, JPEG, PNG, TIF, XPS. Note: Formats that require external applications for conversion use the Convert::Printer class and the PDFNet printer to be installed. This is only supported on Windows platforms. Document formats in this category include RTF(MS Word or Wordpad), TXT (Notepad or Wordpad), DOC and DOCX (MS Word), PPT and PPTX (MS PowerPoint), XLS and XLSX (MS Excel), OpenOffice documents, HTML and MHT (Internet Explorer), PUB (MS Publisher), MSG (MS Outlook).

But then there’s Convert.office2PDF:
<static> office2PDF(input [, options]) Convert the an office document (in .docx, .xlsx, pptx, or .doc format) to pdf.

Which just leaves ‘unconvertable’ when not running Windows:
RTF, OpenOffice documents, HTML/MHT, PUB, and MGS.

Is that right?

HTML (and possibly MHT) files can be handled on Linux/macOS, using our HTML2PDF module.

You can simply do the following, if you do not need to modify the HTML2PDF output.

Convert.ToPdf(pdfdoc, "pathToHtml");

And ToPdf will try to use the HTML2PDF module first, whether Windows or Linux.

As for RTF, OpenOffice, PUB and MGS you might want to try LibreOffice command line on Linux.

1 Like