Paragraph and Text Column

Hi!

I’m developing an android app and this forum really has helped to me and I hope this time can help me again.
I’m using TextColumn Collection and it works fine, the problem is that I need to put a title before the columns, I tried many times and many ways and the title always appears at the finish of the document not at the beginning like a normal title, how can I do to put a title before the column text?

Hi Alejandro,

Thanks for your inquiry.

Please manually create your expected Word document using Microsoft Word and attach it here for our reference. We will investigate as to how you want your final Word output be generated like. We will then provide you more information on this along with code.

thank you for the answer
what I need is create a document like this format:

TITLE OF DOCUMENT

column1column1column1 column2column2column2
column1column1column1 column2column2column2
column1column1column1 column2column2column2
column1column1column1 column2column2column2
column1column1column1 column2column2column2

But the document does not looks like that, the title appears at the end like this:

column1column1column1 column2column2column2
column1column1column1 column2column2column2
column1column1column1 column2column2column2
column1column1column1 column2column2column2
column1column1column1 column2column2column2
TITLE OF DOCUMENT

Hi Alejandro,

Thanks for your inquiry. In your case, we suggest you please insert the text ‘TITLE OF DOCUMENT’ in separate Section and column’s contents in separate Section.

Please insert the text ‘TITLE OF DOCUMENT’ at the start of document and then insert section break of type continues. After this section break, please create the columns and insert your desired column’s contents.

Hope this helps you. Please let us know if you have any more queries.

I’m trying but I can’t do it works.

I got this, I don’t know what is wrong

DocumentBuilder builders = new DocumentBuilder(doc);
builders.getPageSetup().setSectionStart(SectionStart.CONTINUOUS);
builders.getFont().setName("Times New Roman");
builders.getFont().setBold(false);
builders.getFont().setItalic(false);
builders.getFont().setSize(20);
builders.getFont().setColor(Color.BLACK);
builders.writeln("Title of document");

DocumentBuilder builder = new DocumentBuilder(doc);
builder.getPageSetup().setSectionStart(SectionStart.CONTINUOUS);
TextColumnCollection columns = builder.getPageSetup().getTextColumns();
columns.setLineBetween(false);
columns.setEvenlySpaced(false);
columns.setCount(2);

// Set the first column to be narrow.
TextColumn c1 = columns.get(0);
PageSetup ps2 = builder.getPageSetup();
double contentWidth2 = (ps2.getPageWidth() - ps2.getLeftMargin() - ps2.getRightMargin())/2;
c1.setWidth(contentWidth2);
c1.setSpaceAfter(20);

What is wrong?
Thank you for help!

Hi Alejandro,

Thanks for your inquiry. Please check following code example for your kind reference. Hope this helps you. Please let us know if you have any more queries.

Document doc = new Document();
DocumentBuilder builders = new DocumentBuilder(doc);
builders.getFont().setName("Times New Roman");
builders.getFont().setBold(false);
builders.getFont().setItalic(false);
builders.getFont().setSize(20);
builders.getFont().setColor(Color.BLACK);
builders.getParagraphFormat().setAlignment(ParagraphAlignment.CENTER);
builders.writeln("Title of document");
builders.insertBreak(BreakType.SECTION_BREAK_CONTINUOUS);
TextColumnCollection columns = builders.getPageSetup().getTextColumns();
columns.setCount(2);
columns.setSpacing(100);
builders.writeln("Text in column 1.");
builders.insertBreak(BreakType.COLUMN_BREAK);
builders.writeln("Text in column 2.");
doc.save(MyDir + "Out.docx");

It works ! thank you !

Hi Alejandro,

Thanks for your feedback. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.