PDF-XChange Editor SDK for Developers
Moderators: PDF-XChange Support , Daniel - PDF-XChange , Chris - PDF-XChange , Sean - PDF-XChange , Paul - PDF-XChange , Vasyl - PDF-XChange , Ivan - Tracker Software , Stefan - PDF-XChange
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.
jthomas
User
Posts: 31 Joined: Tue Oct 18, 2016 2:49 pm
Post
by jthomas » Fri Dec 02, 2016 4:31 pm
I have tried adding points to the Vertices list of a polygon annotation but have not had any success with the Insert functions. When the code executes, the count of Vertices stays the same. Why are the insert functions not adding the point?
Code: Select all
if (sortedDistances.Count > 2)
{
PXC_PointF pdfPointF = new PXC_PointF()
{
x = Convert.ToSingle(pdfPoint.x),
y = Convert.ToSingle(pdfPoint.y)
};
int p1Index = sortedDistances[ 0 ].Index;
int p2Index = sortedDistances[ 1 ].Index;
uint minIndex = Convert.ToUInt32(Math.Min(p1Index, p2Index));
polygonData.Vertices.Insert(pdfPointF, 1, minIndex);
polygonData.Vertices.Insert(polygonData.Vertices.get_Item(0));
viewer.UpdateAnnotation(annot, polygonData);
}
jthomas
User
Posts: 31 Joined: Tue Oct 18, 2016 2:49 pm
Post
by jthomas » Fri Dec 02, 2016 4:32 pm
To clarify, polygonData is of type IPXC_AnnotData_Poly.
Sasha - PDF-XChange
User
Posts: 5522 Joined: Fri Nov 21, 2014 8:27 am
Post
by Sasha - PDF-XChange » Sat Dec 03, 2016 1:18 pm
Hello Jared,
Have you tried using this operation:
https://sdkhelp.pdf-xchange.com/vie ... ot_setData
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
jthomas
User
Posts: 31 Joined: Tue Oct 18, 2016 2:49 pm
Post
by jthomas » Mon Dec 05, 2016 1:47 pm
Hi Alex,
The 'annot.setData' operation is being called in the viewer.UpdateAnnotation function.
How do I add a point to IPXC_PolygonSrcF object? The insert function has not worked for me.
Here is a link to the 'viewer.UpdateAnnotation Function'
https://www.pdf-xchange.com/forum3 ... 66&t=27608
Thanks,
Jared
Sasha - PDF-XChange
User
Posts: 5522 Joined: Fri Nov 21, 2014 8:27 am
Post
by Sasha - PDF-XChange » Mon Dec 05, 2016 2:19 pm
Hello Jared,
Well, here's the case where the C# itself is the case why the code is not working. Try this:
Code: Select all
IPXC_AnnotData_Poly_Vertices vert = polygonData.Vertices;
vert.Insert(pdfPointF, 1, minIndex);
vert.Insert(polygonData.Vertices.get_Item(0));
polygonData.Vertices = vert;
viewer.UpdateAnnotation(annot, polygonData);
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
jthomas
User
Posts: 31 Joined: Tue Oct 18, 2016 2:49 pm
Post
by jthomas » Thu Dec 08, 2016 2:56 pm
Hi Alex,
I tried the method listed above. The point was added to the list but it was not drawn to the UI.
I have found an alternative solution through JS.
Code: Select all
uint minIndex = Convert.ToUInt32(closestAnnotIndex);
string command = "var a = this.getAnnot(" +
(closestAnnot.PageIndex) + ", \"" + closestAnnot.Name +
"\"),verts = a.vertices; verts.splice(" +
(minIndex + 1) + ", 0,[" + pdfPointF.x + "," + pdfPointF.y +
"]),a.vertices = verts;";
PDFXEdit.IString res = viewer.IPxv.CreateString();
try
{
viewer.PdfCtrl.Inst.ExecuteJS(viewer.PdfCtrl.Doc, command, PDFXEdit.PXV_ActionTriggerClass.PAEC_External, PDFXEdit.PXV_ActionTriggerSubclass.PAESC_Exec, null, res);
}
catch { }
Thanks,
Jared
Sasha - PDF-XChange
User
Posts: 5522 Joined: Fri Nov 21, 2014 8:27 am
Post
by Sasha - PDF-XChange » Thu Dec 08, 2016 4:19 pm
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ