I was wondering if you could give me a quick example of how to draw a annotation rectangle via code e.g. by specifying the rectangle top, left, bottom, right coordinates
I have searched the forum and can't seem to find an example.
Thanks
Simon
Draw annotation rectangle via code
Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan
Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.
When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.
When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
- Tracker Supp-Stefan
- Site Admin
- Posts: 17908
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: Draw annotation rectangle via code
Hello Simon,
Probably the easiest would be to do it with JS code.
And if you want to do it directly with the SDK methods please take a look here:
https://sdkhelp.pdf-xchange.com/vi ... Annotation
and here
https://sdkhelp.pdf-xchange.com/vi ... rtNewAnnot
Cheers,
Stefan
Probably the easiest would be to do it with JS code.
Code: Select all
var annot = this.addAnnot({
page: 0,
type: "Square",
author: "A. C. Robat",
name: "myRect",
rect: [400, 400, 550, 500]
}
https://sdkhelp.pdf-xchange.com/vi ... Annotation
and here
https://sdkhelp.pdf-xchange.com/vi ... rtNewAnnot
Cheers,
Stefan
Re: Draw annotation rectangle via code
Thanks Stefan,
I am currently using the following code to place a square and this all works well, however is there a way that I could for example specify Fill Color, no border and opacity 40%
Thanks
Simon
I am currently using the following code to place a square and this all works well, however is there a way that I could for example specify Fill Color, no border and opacity 40%
Code: Select all
Dim rc As PDFXEdit.PXC_Rect
rc.left = charMin.left
rc.right = charMax.right
rc.top = charMin.top
rc.bottom = charMax.bottom
Dim pSInt As PDFXEdit.IPXS_Inst = CType(Me.docPreview.Inst.GetExtension("PXS"), PDFXEdit.IPXS_Inst)
Dim nTextBox As UInteger = pSInt.StrToAtom("Square")
Dim pPage As PDFXEdit.IPXC_Page = Me.docPreview.Doc.CoreDoc.Pages(CUInt(pageNumber))
Dim pAnnot As PDFXEdit.IPXC_Annotation = pPage.InsertNewAnnot(nTextBox, rc, 0)
If pAnnot IsNot Nothing Then
Dim nID As Integer = Me.docPreview.Inst.Str2ID("op.annots.addNew", False)
Dim pOp As PDFXEdit.IOperation = Me.docPreview.Inst.CreateOp(nID)
Dim input As PDFXEdit.ICabNode = pOp.Params.Root("Input")
input.Add().v = pAnnot
pOp.Do()
End If
Simon
Re: Draw annotation rectangle via code
OK, so I have figured out the color issue and border issue, however the opacity does not seem to be applied:
Thanks
Simon
Code: Select all
Dim mData As PDFXEdit.IPXC_AnnotData_SquareCircle = CType(pAnnot.Data, PDFXEdit.IPXC_AnnotData_SquareCircle)
Dim myBorder As New PXC_AnnotBorder
myBorder.nWidth = 0
mData.Border = myBorder
Dim color As PDFXEdit.IColor = auxInst.CreateColor(PDFXEdit.ColorType.ColorType_RGB)
color.Value = "rgbd(255,255,120)"
mData.SColor = color
mData.FColor = color
mData.Border = myBorder
mData.Opacity = 40.0
pAnnot.Data = mData
Dim nID As Integer = Me.docPreview.Inst.Str2ID("op.annots.addNew", False)
Dim pOp As PDFXEdit.IOperation = Me.docPreview.Inst.CreateOp(nID)
Dim input As PDFXEdit.ICabNode = pOp.Params.Root("Input")
input.Add().v = pAnnot
pOp.Do()
Simon
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Draw annotation rectangle via code
Hello Simon,
I suggest downloading the CoreAPIDemo project - where you will find many useful samples:
https://github.com/tracker-software/PDF ... oreAPIDemo
Here's a code snippet from that project that contains opacity setting:
Cheers,
Alex
I suggest downloading the CoreAPIDemo project - where you will find many useful samples:
https://github.com/tracker-software/PDF ... oreAPIDemo
Here's a code snippet from that project that contains opacity setting:
Code: Select all
[Description("7.1. Add Text annotations")]
static public int AddTextAnnotation(Form1 Parent)
//...
aData.Opacity = 0.5f;
//...
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ