Hi,
I have a rtf document which contains a paragraph border. I want to replace the border with table programmatically using Aspose Api. But I am unable to get the borders using the examples given in your forum. I tried the following methods to get the borders but none of them are working.
indent preformatted text by 4 spaces
DocumentBuilder builder = new DocumentBuilder(doc);
Border topBorder = builder.ParagraphFormat.Borders[BorderType.Top];
StyleCollection sampleStyles = doc.Styles;
foreach (Aspose.Words.Style sampleStyle in sampleStyles)
{
Font sampleStyleFont = sampleStyle.Font;
if (sampleStyleFont != null)
{
Border b = sampleStyleFont.Border;
Shading s= sampleStyleFont.Shading;
}
}
In the above code, I am not able to get the border in the document. I am attaching the sample documentBorder.zip (8.6 KB).
Thanks for your inquiry. The ParagraphFormat.Borders property returns collection of borders of the paragraph. To get the border of table’s cell, please use Cell.CellCellFormat.Borders. This method returns collection of borders of the cell.
I tried to get the borders present in the document by using “builder.ParagraphFormat.Borders”. But this always returns a collection with 6 length array of Border object for all the documents irrespective of a blank document or a document with borders in it.
All of these borders in the Borders collection having the same values as “IsVisible = false, LineStyle=None, LineWidth=0, Shadow=false”.
So, I cannot use this property to get the actual border present in the document.
Thanks for your inquiry. Please use Paragraph.ParagraphFormat.Borders property instead of “builder.ParagraphFormat.Borders”. We shared the code snippet in this thread. Please check the code snippet below.