We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Border style single- thick- hairline- outset and inset produce the same behavior for both Word and PDF

Hi Support,

The below code creates a table with border style set to single, thick,hairline, outset and inset irrespectively, but will get the same result no matter which above border style is set. Is there anything I missed, or it is a defect of Aspose?

Thanks & regards.
Vincent

DocumentBuilder docBuilder = new DocumentBuilder();
com.aspose.words.Style style = docBuilder.getDocument().getStyles().get(“Normal”); //$NON-NLS-1$
if (style != null)
{
docBuilder.getParagraphFormat().setStyle(style);
}

docBuilder.clearRunAttrs();
// begin table
Table table = docBuilder.startTable();
docBuilder.getParagraphFormat().clearFormatting();
docBuilder.getCellFormat().clearFormatting();

// The first row
docBuilder.getRowFormat().setHeight(0);

// The first cell
docBuilder.insertCell();
docBuilder.getCellFormat().clearFormatting();
docBuilder.getCellFormat().getBorders().setColor(Color.black);

//docBuilder.getCellFormat().getBorders().setLineStyle(LineStyle.SINGLE);
//docBuilder.getCellFormat().getBorders().setLineStyle(LineStyle.THICK);
//docBuilder.getCellFormat().getBorders().setLineStyle(LineStyle.HAIRLINE);
//docBuilder.getCellFormat().getBorders().setLineStyle(LineStyle.OUTSET);
docBuilder.getCellFormat().getBorders().setLineStyle(LineStyle.INSET);

docBuilder.getCellFormat().getBorders().setLineWidth(1);
docBuilder.getParagraphFormat().clearFormatting();
docBuilder.write(“xxxxxxxxxxxx”);

// End the first row
docBuilder.endRow();
// end table
docBuilder.endTable();
table.setAllowAutoFit(true);

docBuilder.getDocument().save(“c:\test.doc”);
docBuilder.getDocument().save(“c:\test.pdf”);

Hi

Thank you for reporting this problem to us. I managed to reproduce the problem on my side. Your request has been linked to the appropriate issue. You will be notified as soon as it is resolved.

Best regards,

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


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

Hi Andrey,

I still see this issue with AsposeWordForJava v 13.3. Find the testcase below.

writeTableWithBorder(docBuilder, “SINGLE”);
writeTableWithBorder(docBuilder, “THICK”);
writeTableWithBorder(docBuilder, “HAIRLINE”);
writeTableWithBorder(docBuilder, “INSET”);
writeTableWithBorder(docBuilder, “OUTSET”);

private static void writeTableWithBorder(DocumentBuilder docBuilder,
String borderStyle) throws Exception {
docBuilder.clearRunAttrs();
// begin table
docBuilder.getParagraphFormat().clearFormatting();
docBuilder.getCellFormat().clearFormatting();

// The first row
docBuilder.getRowFormat().setHeight(0);

// The first cell
docBuilder.insertCell();
docBuilder.getCellFormat().clearFormatting();
docBuilder.getCellFormat().getBorders().setColor(Color.BLACK);

if (“SINGLE”.equals(borderStyle))
docBuilder.getCellFormat().getBorders()
.setLineStyle(LineStyle.SINGLE);
if (“THICK”.equals(borderStyle))
docBuilder.getCellFormat().getBorders()
.setLineStyle(LineStyle.THICK);
if (“HAIRLINE”.equals(borderStyle))
docBuilder.getCellFormat().getBorders()
.setLineStyle(LineStyle.HAIRLINE);
if (“OUTSET”.equals(borderStyle))
docBuilder.getCellFormat().getBorders()
.setLineStyle(LineStyle.OUTSET);
if (“INSET”.equals(borderStyle))
docBuilder.getCellFormat().getBorders()
.setLineStyle(LineStyle.INSET);

docBuilder.getCellFormat().getBorders().setLineWidth(1);
docBuilder.getParagraphFormat().clearFormatting();
docBuilder.writeln(borderStyle);

// End the first row
docBuilder.endRow();
// end table
docBuilder.endTable();
}

Thanks,
Kumar

Hi Support, any update on this?

Thanks,
Kumar

Hi Kumar,


Please accept my apologies for late response.

Thanks for your inquiry. I have verified the detail of WORDSNET-5598 from our issue tracking system and I would like to update you that this issue is not a bug. So, we closed this issue as ‘Not a Bug’.

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

Hi Tahir,

Since MS Word doesn’t have border style naming, it’s difficult to come up with an example.
I
guess you should be knowing the difference for single, thick,
hairline,etc better since com.aspose.words.LineStyle has different
styles.

I’ve attached a doc with example for inset and outset border style.

public final class LineStyle
{
private LineStyle()
{
}
public static final int NONE = 0;
public static final int SINGLE = 1;
public static final int THICK = 2;
public static final int DOUBLE = 3;
public static final int HAIRLINE = 5;

Thanks,
Kumar

Hi Kumar,


Thanks for sharing the details. The Inset/Outset borders applied to cell are rendered as simple black thin borders. This is external behaviour by MS Word. In the shared document, the line styles are ENGRAVE_3_D and EMBOSS_3_D.

Please use the following code snippet to work with line style as ENGRAVE_3_D or EMBOSS_3_D. Hope this helps you. Please let us know if you have any more queries.

DocumentBuilder docBuilder = new DocumentBuilder();<o:p></o:p>

docBuilder.insertCell();

docBuilder.getCellFormat().clearFormatting();

docBuilder.getCellFormat().getBorders().setColor(Color.BLACK);

docBuilder.getCellFormat().getBorders().setLineStyle(LineStyle.EMBOSS_3_D);

docBuilder.getCellFormat().getBorders().setLineWidth(10);

docBuilder.getParagraphFormat().clearFormatting();

docBuilder.writeln("Table Border Style 1");

// End the first row

docBuilder.endRow();

// end table

docBuilder.endTable();

docBuilder.writeln();

docBuilder.insertCell();

docBuilder.getCellFormat().clearFormatting();

docBuilder.getCellFormat().getBorders().setColor(Color.BLACK);

docBuilder.getCellFormat().getBorders().setLineStyle(LineStyle.ENGRAVE_3_D);

docBuilder.getCellFormat().getBorders().setLineWidth(10);

docBuilder.getParagraphFormat().clearFormatting();

docBuilder.writeln("Table Border Style 1");

// End the first row

docBuilder.endRow();

// end table

docBuilder.endTable();

docBuilder.writeln();

docBuilder.getDocument().save(MyDir + "out.docx");

Hi Tahir,

Let me put it in a simpler way.

I could see multiple border style options like single, thick, hairline, inset, outset. When I use them, I see same border style.

As per Aspose documentation or coding or design, how is it supposed to work?
Could you come up with Aspose code to show difference between these border style when applied to a cell? because, I see no difference. Do they work or it a defect?

Thanks,
Kumar

Hi Kumar,


Thanks for sharing the detail. I have logged this issue as WORDSNET-8257 in our issue tracking system. I have linked this forum thread to the same issue and you will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Hi Kumar,


Thanks for your patience.

On further investigation our development team came to know that they won’t be able to implement the fix to your issue. Your issue will be closed with ‘‘Won’t Fix’’ resolution.

MS Word shows the same line style for single, thick, hairline, inset, outset. This is external behaviour by MS Word. You can see the correct line style if you open the internal document.xml found inside the DOCX file.


<w:top w:val=“outset” w:sz=“40” w:space=“0” w:color=“000000” />…

<w:tcBorders>
<w:top w:val=“inset” w:sz=“40” w:space=“0” w:color=“000000” />…

<w:tcBorders>
<w:top w:val=“single” w:sz=“40” w:space=“0” w:color=“000000” />…

<w:tcBorders>
<w:top w:val=“thick” w:sz=“40” w:space=“0” w:color=“000000” />