Sidebar

Are there any alternatives for converting RTF to PDF other than open office?

0 votes
615 views
asked Jul 7, 2017 by marc-m-9513 (570 points)
We are using the apache open office service but it is failing frequently.

1 Answer

0 votes

You could convert the RTF to plain text without the use of any external jars using something like this:

var docData = qie.doQuery(channelCache.getValue('dbName'),
"select data from docdata where sdid = " + message.getNode('/'));

var rtf = '';
for (var i = 1; i <= docData.getRowCount(); i++) {
   rtf += docData.getNode('data', i);
}
rtf = new java.lang.String(rtf);

//Convert to text from RTF
var rtfEditorKit = new javax.swing.text.rtf.RTFEditorKit();
var rtfDocument = rtfEditorKit.createDefaultDocument();
rtfEditorKit.read(new java.io.ByteArrayInputStream(rtf.getBytes()), rtfDocument, 0);
rtf = rtfDocument.getText(0, rtfDocument.getLength());

message.setNode('/', StringUtils.replace(rtf, '\n', '~'));

There are other external jars you could find with a google search for "rtf to pdf jar".

Or

Maybe one of these KB articles would be a good resource:

https://www.qvera.com/kb/index.php/287/how-do-i-create-a-pdf-from-an-oru?show=287#q287

https://www.qvera.com/kb/index.php/683/how-do-i-create-a-pdf-when-obx-5-is-in-rtf-format?show=683#q683

answered Jul 7, 2017 by michael-h-5027 (14,350 points)
...