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

Notification

Icon
Error

New Topic Post Reply
Options
Go to last post Go to first unread
jmclsdy  
#1 Posted : Tuesday, March 17, 2020 3:50:01 AM(UTC)
Quote
jmclsdy

Rank: Newbie

Groups: Registered
Joined: 3/4/2020(UTC)
Posts: 2
China

hi:

Code:
Private Sub addUnderlineannot(ByVal page As PdfPage,byval rect As FS_RECTF)
		If page.Annots Is Nothing Then page.CreateAnnotations()	
		Dim pathobj =PdfPathObject.Create(FillModes.Winding,True)
		pathObj.Path.AppendRect(rect)
		pathObj.StrokeColor = FS_COLOR.Transparent
		pathObj.FillColor =  FS_COLOR.Transparent 
		pathObj.CalcBoundingBox()
		Dim annot As PdfTextMarkupAnnotation 
		annot=New PdfUnderlineAnnotation(page)
		annot.Color = FS_COLOR.Black 
		annot.Opacity = 1.0f
		annot.Rectangle = rect	
		annot.QuadPoints.add((new FS_QUADPOINTSF(rect)))
		annot.CreateEmptyAppearance(AppearanceStreamModes.Normal)
		annot.NormalAppearance.Add(pathobj)	
		annot.GenerateAppearance(AppearanceStreamModes.Normal)	
		page.annots.Add(annot)
		page.Dispose()
	End Sub


1、Object reference is not set to an instance of the object
2、Don't show the underline(Delete this line annot.QuadPoints.add((new FS_QUADPOINTSF(rect))))

Edited by moderator Wednesday, March 18, 2020 12:05:16 AM(UTC)  | Reason: Not specified

Paul Rayman  
#2 Posted : Wednesday, March 18, 2020 12:21:40 AM(UTC)
Quote
Paul Rayman

Rank: Administration

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

Thanks: 3 times
Was thanked: 110 time(s) in 107 post(s)
you have two ways to create an underline annotation

1.
Code:

var page = pdfViewer1.Document.Pages[0];
if (page.Annots == null)
	page.CreateAnnotations();
page.Annots.Add(new PdfUnderlineAnnotation(page, new FS_POINTF(40, 450), new FS_POINTF(140, 490), new FS_POINTF(130, 400), new FS_POINTF(30, 360), FS_COLOR.Black));
page.Dispose();


2.
Code:

var underlineAnnotWithoutAppearance = new PdfUnderlineAnnotation(page);
underlineAnnotWithoutAppearance.Color = FS_COLOR.Blue;
underlineAnnotWithoutAppearance.Opacity = 1.0f;
underlineAnnotWithoutAppearance.QuadPoints = new PdfQuadPointsCollection();
underlineAnnotWithoutAppearance.QuadPoints.Add(new FS_QUADPOINTSF(20, 40, 120, 40, 20, 10, 120, 10));
underlineAnnotWithoutAppearance.QuadPoints.Add(new FS_QUADPOINTSF(130, 80, 300, 180, 140, 10, 250, 40));
page.Annots.Add(underlineAnnotWithoutAppearance);
underlineAnnotWithoutAppearance.RegenerateAppearances();
page.Dispose();

jmclsdy  
#3 Posted : Wednesday, March 18, 2020 2:34:41 AM(UTC)
Quote
jmclsdy

Rank: Newbie

Groups: Registered
Joined: 3/4/2020(UTC)
Posts: 2
China

thank you,very good
Quick Reply Show Quick Reply
Users browsing this topic
New Topic Post Reply
Forum Jump  
You can post new topics in this forum.
You can reply to topics in this forum.
You can delete your posts in this forum.
You can edit your posts in this forum.
You cannot create polls in this forum.
You can vote in polls in this forum.