We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Font name changed

I have extracted the image from the document. in the extracted image, the font name is changed. In the document, the font name is Times new roman and extracted pdf font is Calibri. i have retained some document properties but have not gotten the font name. how to retain the document font name and style?

Source Code:

private static Document docSetup(Document interimDoc, Table table)
{
    try
    {
        Document tableDoc = new Document();
        DocumentBuilder builder = new DocumentBuilder(interimDoc);
        builder.moveTo(table);
        PageSetup sourcePageSetup = builder.getCurrentSection().getPageSetup();
        tableDoc.getFirstSection().getPageSetup().setOrientation(
        ((Paragraph)table.getNextSibling()).getParentSection().getPageSetup().getOrientation());
        tableDoc.getFirstSection().getPageSetup().setPaperSize(sourcePageSetup.getPaperSize());
        tableDoc.getFirstSection().getPageSetup().setLeftMargin(sourcePageSetup.getLeftMargin());
        tableDoc.getFirstSection().getPageSetup().setRightMargin(sourcePageSetup.getRightMargin());

        return tableDoc;
    }
    catch (Exception e)
    {
        return interimDoc;
    }
}

Input: Fig 7.docx (2.9 MB)

Regards,
Mahesh

@Mahesh39 In you code you create new document, this document has different styles then the source document with the table. To keep the same styles and page setup you can simply clone the source document. For example see the following code:

private static Document docSetup(Table table)
{
    Document tableDoc = (Document)table.getDocument().deepClone(false);
    Section tableSection = (Section)table.getAncestor(NodeType.SECTION);
    tableDoc.appendChild(tableDoc.importNode(tableSection, false, ImportFormatMode.USE_DESTINATION_STYLES));
    tableDoc.ensureMinimum();

    return tableDoc;
}