How to set Aspose.Pdf.Table.Cell border : dotted

Hi,

I am currently trying to set the Aspose.Pdf.Table.Cell border style to “dotted”. This value doesn’t exist in the BorderStyle enum. Is there a way to do this ?

Regards

Hello Cuisinier,

Thanks for your interest in our products.

We are working over this query and will get back to you soon. We are really sorry for this inconvenience.

Thanks to you, I’ll waiting.


Regards

Hello Cuisinier,

Thanks for your patience.

Please try using the following code snippet to accomplish your requirements. I have also attached the sample PDF document that I have generated using Aspose.Pdf for .NET 5.4.0

[C#]

//Instantiate a Pdf object by calling its empty constructor
Pdf pdf1 = new Pdf();
//Instantiate attachment instance
Aspose.Pdf.Section sec1 = pdf1.Sections.Add();

//Instantiate a table object
Aspose.Pdf.Table tab1 = new Aspose.Pdf.Table();
//Add the table in paragraphs collection of the desired section
sec1.Paragraphs.Add(tab1);
//Set with column widths of the table
tab1.ColumnWidths = "50 50 50";
//Create a Graph object
GraphInfo Border_Graph = new GraphInfo();
// specify the dash length in white
Border_Graph.DashLengthInWhite = 2F;
// specify the dash length in Black
Border_Graph.DashLengthInBlack= 1;
//Set table border using customized BorderInfo object
tab1.DefaultCellBorder = new BorderInfo((int)BorderSide.All, Border_Graph);
//Create MarginInfo object and set its left, bottom, right and top margins
MarginInfo margin = new MarginInfo();
margin.Top = 5f;
margin.Left = 5f;
margin.Right = 5f;
margin.Bottom = 5f;
//Set the default cell padding to the MarginInfo object
tab1.DefaultCellPadding = margin;

//Create rows in the table and then cells in the rows
Row row1 = tab1.Rows.Add();
row1.Cells.Add("col1");
row1.Cells.Add("col2");
row1.Cells.Add("col3");
Row row2 = tab1.Rows.Add();
row2.Cells.Add("item1");
row2.Cells.Add("item2");
row2.Cells.Add("item3");
//save the resultant PDF
pdf1.Save(@"d:/pdftest/TableBorder_5.4.0.pdf");

You may also try using the following XML file to generate the PDF document with table having dotted border. Following XML only shows how to create dotted border and it's different from above code snippet.

[XML]

<?xml version="1.0" encoding="utf-8" ?>
<Pdf xmlns="Aspose.Pdf">
<Section>
<Table ColumnWidths="100" DefaultCellPaddingLeft="7.25" DefaultCellPaddingRight="7.25" DefaultCellPaddingTop="7.25" DefaultCellPaddingBottom="7.25">
<DefaultCellBorder>
<Box Dash="1 1" LineWidth="1.0" />
</DefaultCellBorder>
<Row>
<Cell>
<Text>
<Segment>Dotted border</Segment>
</Text>
</Cell>
</Row>
</Table>
</Section>
</Pdf>

In case you have any further query, please feel free to contact.

Perfect !
I did not know the GraphInfo class.

Thank you.