I have an RTF file, trying to convert it to a PDF file. When I use following code, I get malformed PDF
Document rtfDoc = new Document(rtf);
DocumentBuilder builder = new DocumentBuilder(rtfDoc);
Document pdfDoc = rtfDoc.deepClone();
ImportFormatOptions options = new ImportFormatOptions();
options.setSmartStyleBehavior(false);
builder.insertDocument(pdfDoc, ImportFormatMode.*KEEP_SOURCE_FORMATTING*);
pdfDoc.save(pdf);
// and when I use the following code, I get a perfect PDF however, I have an extra blank pdf page.
Document invoicePdf = new Document();
// Open an existing document B
Document invoiceRtf = new Document(rtf);
// Add document B to the and of document A, preserving document B formatting
invoicePdf.appendDocument(invoiceRtf, ImportFormatMode.*KEEP_SOURCE_FORMATTING*);
// Save the output as PDF
invoicePdf.save(pdf, SaveFormat.*PDF*);
Please advice? Thanks