Text Columns in Aspose.words

Hi,

Thanks for your patience. The new version of Aspose.Words (13.1) has just been released. Please download it from the following link:
https://releases.aspose.com/words/net

Best regards,

The issues you have found earlier (filed as WORDSNET-2978) have been fixed in this .NET update and this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(105)

Hi Awais,
How to acheive below scenario using Apsoe.words 13.1 in .net
Read the first column end of text & checks whether the text is in specific format, if it is then moves one line down which would automaticaly moves to the next column.

Hi,
Whether this requirement could be acheived in Aspose words V13.1.0.

Hi Jayaprakash,

Thanks for your request. We are checking with this scenario and will get back to you soon.

Best regards,

Hi Awais,
Is there any update?

Hi Jayaprakash,

Thanks for your inquiry and sorry for the delay. We’re in communication with our development team and as soon as any information or code sample, to be able to achieve what you’re looking for, is available to us, we’ll be glad to share that with you.

Best regards,

Hi Awais,
Do you have any update on this one?

Hi Jayaprakash,

Thanks for your inquiry and sorry for the delay.

Update:
We will provide a way to access elements such as Paragraphs (lines) of a TextColumn and for this I have logged a new Task in our issue tracking system as WORDSNET-7780. Your request has been linked to this Task and you will be notified as soon as the requested sample code is available.

I apologize for any inconvenience.

Best regards,

Hi Jayaprakash,

Thanks for your inquiry and for your patience.

I believe what you are looking to achieve is possible using one of the samples provided in our offline samples pack. Please download that archive and from the DocumentLayoutHelper example include the RenderedDocument and LayoutEntities source files in to your application.

Then you can try using the code below to achieve your task:

Document doc = new Document(dataDir +  "Test.docx");

// This sample introduces the RenderedDocument class and other related classes which provide an API wrapper for
// the LayoutEnumerator. This allows you to access the layout entities of a document using a DOM style API.
// Create a new RenderedDocument class from a Document object.
RenderedDocument layoutDoc = new RenderedDocument(doc);
// Loop through the layout info of each page
foreach(RenderedPage page in layoutDoc.Pages)
{
    if (page.Columns.Count> 1)
    {
        // Find the last line in the first column on the page.
        RenderedLine lastLine = page.Columns.First.Lines.Last;
        // This is the pargraph which belongs to the last line on the page, implement required logic and checks here.
        Paragraph para = lastLine.Paragraph;
        if (para.ParagraphFormat.StyleIdentifier == StyleIdentifier.Heading1)
        {
            // Insert a blank paragraph before the last paragraph in the column.
            para.ParentNode.InsertBefore(new Paragraph(doc), para);
        }
        // This is how to get the first line in the second column and the related paragraph.
        // Use this if it is required.
        RenderedLine secondColumnLine = page.Columns[1].Lines.First;
        Paragraph secondColumnPara = lastLine.Paragraph;
    }
}
doc.Save(dataDir + "Test Out.docx");

Please let me know how it goes.

Thanks,

Hi Adam,
Thanks for response.
There are some concerns we are facing.
Issue 1 -
Last line is fetched wrong .Have attached document “Document-Wrong last line”
Issue is last line in first column is “The portfolio produced a positive return for the December quarter”.
But value returned from below code is “Fund Performance and Activity”

Paragraph para = lastLine.Paragraph;
para.gettext();

Issue 2-
Last line is not actually fetching last line, instead its fetching last complete paragraph. Have attached document “Document-Whole Para”
Issue is last line in first column is "At an industry group level, active stock positioning within the Consumer Staples sector was the largest area of underperformance, "
But value returned from below code is complete paragraph “At an industry group level, active stock positioning within the Consumer Staples sector was the largest area of underperformance, while positive performance in stock selection within the Materials sector was the largest positive offset. At a stock level, the largest positive contributers to active returns were JP Morgan, Discover, HSBC and Microsoft, while positioning in Bank of America, Apple, Qualcomm and EMC Corp were the largest detractors over the quarter.”

Paragraph para = lastLine.Paragraph;
para.getetxt();

Below code also returning last paragrah"“At an industry group level, active stock positioning within the Consumer Staples sector was the largest area of underperformance, while positive performance in stock selection within the Materials sector was the largest positive offset. At a stock level, the largest positive contributers to active returns were JP Morgan, Discover, HSBC and Microsoft, while positioning in Bank of America, Apple, Qualcomm and EMC Corp were the largest detractors over the quarter.”" from first column. Its not returning first line from second column which should be "while positive performance in stock selection within the Materials "

RenderedLine secondColumnLine = page.Columns[1].Lines.First;
Paragraph secondColumnPara = lastLine.Paragraph;

Issue 3-
Both document contains only 2 columns.But value page.Columns.Count is returning 3.
Issue 4 –
Suppose word document contains 4 columns. How to read last line (not paragraph) from 2nd column.

Hi Jayaprakash,

Thanks for your inquiry.

I managed to reproduce the issues you mentioned in your first and third points. I have logged these issues in our issue tracking system as WORDSNET-7791 and WORDSNET-7792 respectively. We will further look into the details of these problems and will keep you updated on the status of correction. We apologize for your inconvenience.

Secondly, to be able to read last line from second column, please use the following code:

layoutDoc.Pages[0].Columns[1].Lines.Last.Text;

I hope, this helps.

Best regards,

Hi Awais,
Thanks for response,
Have you had a look on to Issue 2. which I have mentioned Actually last complete paragraph is getting fetched, not the last line.

Hi Jayaprakash,

Thanks for your inquiry.

Issue 1: Please note that Aspose.Words implements it’s own document rendering engine that layouts document into pages and in addition to DOM (Document Object Model) it builds APS (Aspose Page Specification) model in memory. The newly introduced Aspose.Words.Layout Namespace just provides public classes to access those layout objects/entities when the document is formatted into pages. Moreover, when you convert a document to PDF format, the same rendering engine is used. In your case, when you produce a PDF document, you’ll notice that the last line in first column in PDF is indeed ‘Fund performance and activity’ and hence ‘layoutDoc.Pages[0].Columns[0].Lines.Last.Text’ returns the correct line.

Issue 2: In this case, Aspose.Words does the right thing; i.e. para.geText(); should return the complete text in the Paragraph. A Paragraph can have multiple lines and if you need to access the last line, please use the code mentioned in my previous post.

Issue 3: The problem occurs because you documents indeed have three columns. This is because it has two Sections on the first page. First Section has two columns and second Section has one more. So, in this case, there is no problem in Aspose.Words.

Please let me know if I can be of any further assistance.

Best regards,

Hi awais,
Thanks for reply.
Need one clarification. Suppose if ‘layoutDoc.Pages[0].Columns[0].Lines.Last.Text’’ returns last line how to check its heading and if ithe heading style is Heading 1 how to add a empty line before it.

Actually para.ParentNode.InsertBefore(new Paragraph(doc), para); is inserting a empty line before the paragraph, not before the line fetched from ‘layoutDoc.Pages[0].Columns[0].Lines.Last.Text’’

Hi Jayaprakash,

Thanks for your inquiry. Sure, you can achieve this by using the following code snippet:

Document doc = new Document(dataDir + "Document-Whole+Para.docx");

RenderedDocument layoutDoc = new RenderedDocument(doc);
Paragraph para = layoutDoc.Pages[0].Columns[0].Lines.Last.Paragraph;
Node node = para;
while (node != null)
{
    if (node.NodeType == NodeType.Paragraph)
    {
        Paragraph tempPara = (Paragraph) node;
        if (tempPara.ParagraphFormat.StyleName.Equals("Heading 1_0"))
        {
            node = tempPara;
            break;
        }
        node = node.PreviousSibling;
    }
}
if (node != null)
{
    Paragraph emptyPara = new Paragraph(doc);
    node.ParentNode.InsertBefore(emptyPara, node);
}
doc.Save(dataDir + "out.docx");

I hope, this helps.

Best regards,

The issues you have found earlier (filed as WORDSNET-7791) have been fixed in this .NET update and this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.

The issues you have found earlier (filed as WORDSNET-7792) have been fixed in this .NET update and this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.

The issues you have found earlier (filed as WORDSNET-7780) have been fixed in this .NET update and this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(1)