Skip to content

Instantly share code, notes, and snippets.

@Polaringu
Created March 31, 2016 09:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Polaringu/7143244f4812884ece45e1c28ef00f25 to your computer and use it in GitHub Desktop.
Save Polaringu/7143244f4812884ece45e1c28ef00f25 to your computer and use it in GitHub Desktop.
private void changeAnnotationScaleToolStripMenuItem_Click(object sender, EventArgs e)
{
PDFXEdit.IPXC_Annotation annot = pdfCtl.Doc.CoreDoc.Pages[0].GetAnnot(0);
PDFXEdit.IPXC_AnnotData_Poly PData = (PDFXEdit.IPXC_AnnotData_Poly)annot.Data;
PDFXEdit.IPXC_MeasureRL measure = (PDFXEdit.IPXC_MeasureRL)PData.Measure;
//We'll set the scale from 33mm to 11m
measure.Ratio = "33 mm = 11 m";
PDFXEdit.IPXC_NumberFormatArray nfa = measure.GetX();
PDFXEdit.IPXC_NumberFormatItem nfi = nfa.CreateNewItem();
nfi.FractionType = PDFXEdit.PXC_MeasureFractionType.MFT_AsDecimal;
nfi.Units = "m";
//pt 2 unit = 254.0 / 720.0; // pt to mm
nfi.Coefficient = 11.0 * (254.0 / 720.0) / 33;
nfi.Precision = 100;
nfi.ThousandSep = " ";
nfi.DecimalSep = ",";
nfi.NoReduceFraction = false;
nfi.UnitsPrefix = " ";
nfi.UnitsSuffix = " ";
nfa.Clear();
nfa.Insert(nfi, 0);
int nID = pdfCtl.Inst.Str2ID("op.annot.setData", false);
PDFXEdit.IOperation Op = pdfCtl.Inst.CreateOp(nID);
PDFXEdit.ICabNode input = Op.Params.Root["Input"];
input.Add().v = annot;
PDFXEdit.ICabNode options = Op.Params.Root["Options"];
options["NewData"].v = PData;
Op.Do();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment