Hello,
I want to create a pdf document in which I want to insert a text and that it can be underlined or crossed out, I found in the documentation the classes PdfTextDecoration and PdfTextMarkupAnnotation which seem to perform these operations but I can’t use them and I can’t find an example of use.
Could you help me please?
Thank you !
Hi Florian,
Try this:
using var document = new PdfDocument();
var page = document.Pages.Add();
using var formattedText = new PdfFormattedText();
formattedText.Underline = new PdfTextDecoration(
style: PdfTextDecorationStyle.Single,
wordsOnly: false,
thickness: 4,
color: PdfColors.Red,
opacity: 1,
dashPattern: PdfLineDashPatterns.Solid);
formattedText.Append("Hello World!");
page.Content.DrawText(formattedText, new PdfPoint(100, 700));
document.Save("output.pdf");
I hope this helps, let me know if you need anything else.
Regards,
Mario
Thanks for your answer,
I don’t have .Underline and PdfTextDecoration in my assembly.
I am using the Nuget package GemBox.Pdf 17.0.1474 in a .net 8.0 class library project
and I have the usings :
using GemBox.Pdf;
using GemBox.Pdf.Content;
Support for underline and strikethrough text decorations was added in version 17.0.1528:
See the release notes:
Thank you verry much.
Have a good day.