Copying Control Field contents from word to pdf

20172018_0_SB16_12-05-2016_Wieckowski_Appropriations_STR_42701.zip (37.1 KB)

Working on a requirement wherein I need to generate a 2 column layout pdf with contents copied from word into pdf.

Evaluating aspose pdf to see if the requirement can be fulfilled using the api.

@wrushu2004

Thank you for contacting support.

Using Aspose.Words for .NET API, you can convert the word document to plain TXT file using below code snippet as explained in Save in the Plain Text (.TXT) Format.

Document doc = new Document(MyDir + "sample_doc.doc");
TxtSaveOptions options = new TxtSaveOptions();
options.PreserveTableLayout = true;
options.ExportHeadersFooters = false;
doc.Save(MyDir + "18.10.txt", options);

Once the text is extracted, you can read that text into TextFragment and create a multi-column PDF file with Aspose.PDF for .NET API as explained in Create Multi-Column PDF document.

We hope this will be helpful. Please feel free to contact us if you need any further assistance.

public class TwoColumnDoc {

public static void main(String[] args) {
    try {
        Document doc = new Document();
        DocumentBuilder docB = new DocumentBuilder(doc);
        TextColumnCollection textColumns = docB.getPageSetup().getTextColumns();
        textColumns.setCount(2);

        for (int i = 0; i < 10; i++) {
            docB.write("This is a sample Paragraph");
            docB.write("This is a sample Paragraph");
            docB.write("This is a sample Paragraph");
            docB.write("This is a sample Paragraph");
            docB.write("This is a sample Paragraph");
            docB.write("This is a sample Paragraph");
            docB.write("This is a sample Paragraph");
            docB.write("This is a sample Paragraph");
            docB.write("This is a sample Paragraph");
            docB.write("This is a sample Paragraph");
            docB.write("This is a sample Paragraph");
            docB.write("This is a sample Paragraph");
            docB.write("This is a sample Paragraph");
            docB.write("This is a sample Paragraph");
            docB.write("This is a sample Paragraph");
            docB.write("This is a sample Paragraph");
            docB.write("This is a sample Paragraph");
            docB.write("This is a sample Paragraph");
            docB.write("This is a sample Paragraph");
            docB.write("This is a sample Paragraph");
            docB.write("This is a sample Paragraph");
            docB.write("This is a sample Paragraph");
            docB.write("This is a sample Paragraph");
            docB.write("This is a sample Paragraph");
            docB.write("This is a sample Paragraph");
            docB.write("This is a sample Paragraph");
            docB.write("This is a sample Paragraph");
            docB.write("This is a sample Paragraph");
            docB.write("This is a sample Paragraph");
            docB.write("This is a sample Paragraph");
            docB.write("This is a sample Paragraph");
            docB.write("This is a sample Paragraph");
            docB.write("This is a sample Paragraph");
            docB.write("This is a sample Paragraph");
            docB.write("This is a sample Paragraph");
            docB.write("This is a sample Paragraph");
        }
        doc.save("2columndocument.docx");
    } catch (Exception ex) {
        Logger.getLogger(TwoColumnDoc.class.getName()).log(Level.SEVERE, null, ex);
    }
}

File Item 45.zip (10.5 KB)

I able to achieve column page layout with above code.

I have attached a sample word which I want to create programmatically.

Also I want to add a footer with bold font and to be right aligned. Can you direct me if there is any sample.

@wrushu2004

Thanks for your inquiry.

You can achieve your requirement by using the same approach as you are using in TwoColumnDoc class. In your document (File Item 45.docx), the table is in the first text column. We suggest you please read following article about creating the tables.
Creating Tables

You need to move the cursor to the header/footer of document and write the text. Plase use ParagraphFormat.Alignment property to set text alignment for the paragraph. Please read following article about specifying formatting.
Specifying Formatting

You can set the text columns of a section for an exiting document. Please use TextColumnCollection.SetCount method to arrange text into the specified number of text columns.

Document doc = new Document(MyDir + "in.doc");
doc.getFirstSection().getPageSetup().getTextColumns().setCount(2);
doc.save(MyDir + "18.10.doc");
doc.save(MyDir + "18.10.pdf");