BorderStyle enum

Hi. I can create annotation with 2 border style types: Solid and Dashed. But on Enum BorderStyle | Aspose.PDF for .NET API Reference there are Beveled, Inset and Underline border types. Does Aspose.Pdf support this 3 features (Beveled, Inset, Underline), because I can’t using it.

And does it possible to set the dashed line like on screenshot:
123.png (3.9 KB)

@tvv91

Thank you for contacting support.

Please note that the API references are reflecting the Enumeration values based on Aspose.PDF for .NET 18.7. Kindly ensure using latest version of the API in your environment. Moreover, the documentation article Working with Graphs explains how a rectangle and dashed line can be added on a PDF page.

We hope this will be helpful. Please feel free to contact us if you need any further assistance.

Thanks for answer. Yeah, I’m tested example with graph, works fine, I can set dash characteristic in DashArray. But problem that I don’t know how programmatically make dot-dashed border style by using FreeTextAnnotation class.

FreeTextAnnotation has Border.Dash property. For using this property we create new Dash object. For example:
freeTextAnnotation.Border.Dash = new Dash(2,2);
But Dash constructor has only 2 parameters, so create border dash style like on screenshot is impossible (programmatically): 123.png (26.4 KB)

Also, we can’t using Rect from FreeTextAnnotation (like in example with graphs), because in FreeTextAnnotation we are using Aspose.Pdf.Rectangle instead of Aspose.Pdf.Drawing.Rectangle in examples with graphs.

@tvv91

Thank you for elaborating it further.

We are afraid that only one format of Dashed line is supported at the moment. Which itself is not working fine and an issue with ID PDFNET-45092 has been logged to rectify the problem. Another ticket with ID PDFNET-45093 has been logged as a feature request to support more dashed styles as supported by Adobe Reader, which are displayed in your screenshot as well.

The ticket IDs have been linked with this thread so that you will receive notifications as soon as the tickets are resolved.

We are sorry for the inconvenience.

The issues you have found earlier (filed as PDFNET-45093) have been fixed in Aspose.PDF for .NET 24.4.

@tvv91

With the code below and using version from 24.3 library, the desired result is obtained.

var pdfDocument = new Document();
pdfDocument.Pages.Add();

var default_appearance = new DefaultAppearance("Arial", 28, System.Drawing.Color.Red);
var freetext = new FreeTextAnnotation(pdfDocument.Pages[1], new Aspose.Pdf.Rectangle(200, 400, 400, 600), default_appearance);
freetext.Contents = "Free Text";
pdfDocument.Pages[1].Annotations.Add(freetext);

var border = new Aspose.Pdf.Annotations.Border(freetext)
{
    Width = 5,
    Style = BorderStyle.Dashed,
    Dash = new Aspose.Pdf.Annotations.Dash(1, 1)
};
freetext.Border = border;

string output = dataDir + "Result.pdf";
pdfDocument.Save(output);

Result.pdf (76.4 KB)