logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Paul Rayman  
#1 Posted : Saturday, August 21, 2021 11:26:47 PM(UTC)
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 1,011

Thanks: 5 times
Was thanked: 121 time(s) in 118 post(s)
Question:
I need to update the font of a PdfFreeTextAnnotation but it looks like I need to edit the TextObject used to create the annotation. Is there a way to access that object or s there a better way to change the text font of an annotation?

Answer:
Code:
var doc = pdfViewer1.Document;
var page = doc.Pages[0];
var annot = page.Annots[0] as PdfFreeTextAnnotation;
var font = PdfFont.CreateFont(doc, "Bradley Hand ITC");

string tag =doc.FormFill.InterForm.Fonts.Add(font);
annot.DefaultAppearance = $"/{tag} 14 Tf 0 0 0 rg 1 0 0 RG";
annot.RegenerateAppearances();

page.ReloadPage();
pdfViewer1.Invalidate();


where
/{tag} 14 Tf is a font name and size - required
0 0 0 rg is a fill color ( RGB black) - optional
1 0 0 RG is a stroke color (RGB red) - optional

Edited by user Saturday, August 21, 2021 11:27:31 PM(UTC)  | Reason: Not specified

Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.