private void Button_Click(object sender, RoutedEventArgs e) { try { using (PDFDoc doc = new PDFDoc()) { doc.InitSecurityHandler(); pdftron.PDF.Page newPg = doc.PageCreate(); doc.PagePushBack(newPg); Ink ink = Ink.Create(doc, new pdftron.PDF.Rect(110, 10, 300, 200)); pdftron.PDF.Point pt3 = new pdftron.PDF.Point(110, 10); //pt3.x = 110; pt3.y = 10; ink.SetPoint(0, 0, pt3); pt3.x = 150; pt3.y = 50; ink.SetPoint(0, 1, pt3); pt3.x = 190; pt3.y = 60; ink.SetPoint(0, 2, pt3); pt3.x = 180; pt3.y = 90; ink.SetPoint(1, 0, pt3); pt3.x = 190; pt3.y = 95; ink.SetPoint(1, 1, pt3); pt3.x = 200; pt3.y = 100; ink.SetPoint(1, 2, pt3); pt3.x = 166; pt3.y = 86; ink.SetPoint(2, 0, pt3); pt3.x = 196; pt3.y = 96; ink.SetPoint(2, 1, pt3); pt3.x = 221; pt3.y = 121; ink.SetPoint(2, 2, pt3); pt3.x = 288; pt3.y = 188; ink.SetPoint(2, 3, pt3); ink.SetColor(new ColorPt(0, 1, 1), 3); newPg.AnnotPushBack(ink); // Save as a linearized file which is most popular // and effective format for quick PDF Viewing. doc.Save("linearized_output.pdf", SDFDoc.SaveOptions.e_linearized); System.Console.WriteLine("Done. Results saved in linearized_output.pdf"); MessageBox.Show("Done. Results saved in linearized_output.pdf", "Document Creation"); } } catch (PDFNetException ex) { System.Console.WriteLine(ex.Message); } }
private static Ink setMarkArea(MarkArea ma) { pdftron.PDF.Rect r = AnnotationsMannager.ConvertRect(ma.RectArea()); Ink ink = Ink.Create(_currentDoc, r); pdftron.PDF.Point pt3 = new pdftron.PDF.Point(); #region Path Calculations //Bottom Path pt3.x = r.x1; pt3.y = r.y1; ink.SetPoint(0, 0, pt3); pt3.x = r.x1 + 10 * (r.x2 - r.x1) / 100; pt3.y = r.y1 + 7 * (r.y2 - r.y1) / 100; ink.SetPoint(0, 1, pt3); pt3.x = r.x1 + 20 * (r.x2 - r.x1) / 100; pt3.y = r.y1; ink.SetPoint(0, 2, pt3); pt3.x = r.x1 + 30 * (r.x2 - r.x1) / 100; pt3.y = r.y1 + 7 * (r.y2 - r.y1) / 100; ink.SetPoint(0, 3, pt3); pt3.x = r.x1 + 40 * (r.x2 - r.x1) / 100; pt3.y = r.y1; ink.SetPoint(0, 4, pt3); pt3.x = r.x1 + 50 * (r.x2 - r.x1) / 100; pt3.y = r.y1 + 7 * (r.y2 - r.y1) / 100; ink.SetPoint(0, 5, pt3); pt3.x = r.x1 + 60 * (r.x2 - r.x1) / 100; pt3.y = r.y1; ink.SetPoint(0, 6, pt3); pt3.x = r.x1 + 70 * (r.x2 - r.x1) / 100; pt3.y = r.y1 + 7 * (r.y2 - r.y1) / 100; ink.SetPoint(0, 7, pt3); pt3.x = r.x1 + 80 * (r.x2 - r.x1) / 100; pt3.y = r.y1; ink.SetPoint(0, 8, pt3); pt3.x = r.x1 + 90 * (r.x2 - r.x1) / 100; pt3.y = r.y1 + 7 * (r.y2 - r.y1) / 100; ink.SetPoint(0, 9, pt3); pt3.x = r.x2; pt3.y = r.y1; ink.SetPoint(0, 10, pt3); //Top Path pt3.x = r.x1; pt3.y = r.y2; ink.SetPoint(1, 0, pt3); pt3.x = r.x1 + 10 * (r.x2 - r.x1) / 100; pt3.y = r.y2 - 7 * (r.y2 - r.y1) / 100; ink.SetPoint(1, 1, pt3); pt3.x = r.x1 + 20 * (r.x2 - r.x1) / 100; pt3.y = r.y2; ink.SetPoint(1, 2, pt3); pt3.x = r.x1 + 30 * (r.x2 - r.x1) / 100; pt3.y = r.y2 - 7 * (r.y2 - r.y1) / 100; ink.SetPoint(1, 3, pt3); pt3.x = r.x1 + 40 * (r.x2 - r.x1) / 100; pt3.y = r.y2; ink.SetPoint(1, 4, pt3); pt3.x = r.x1 + 50 * (r.x2 - r.x1) / 100; pt3.y = r.y2 - 7 * (r.y2 - r.y1) / 100; ink.SetPoint(1, 5, pt3); pt3.x = r.x1 + 60 * (r.x2 - r.x1) / 100; pt3.y = r.y2; ink.SetPoint(1, 6, pt3); pt3.x = r.x1 + 70 * (r.x2 - r.x1) / 100; pt3.y = r.y2 - 7 * (r.y2 - r.y1) / 100; ink.SetPoint(1, 7, pt3); pt3.x = r.x1 + 80 * (r.x2 - r.x1) / 100; pt3.y = r.y2; ink.SetPoint(1, 8, pt3); pt3.x = r.x1 + 90 * (r.x2 - r.x1) / 100; pt3.y = r.y2 - 7 * (r.y2 - r.y1) / 100; ink.SetPoint(1, 9, pt3); pt3.x = r.x2; pt3.y = r.y2; ink.SetPoint(1, 10, pt3); //Left Path pt3.x = r.x1; pt3.y = r.y1; ink.SetPoint(2, 0, pt3); pt3.y = r.y1 + 10 * (r.y2 - r.y1) / 100; pt3.x = r.x1 + 7 * (r.x2 - r.x1) / 100; ink.SetPoint(2, 1, pt3); pt3.y = r.y1 + 20 * (r.y2 - r.y1) / 100; pt3.x = r.x1; ink.SetPoint(2, 2, pt3); pt3.y = r.y1 + 30 * (r.y2 - r.y1) / 100; pt3.x = r.x1 + 7 * (r.x2 - r.x1) / 100; ink.SetPoint(2, 3, pt3); pt3.y = r.y1 + 40 * (r.y2 - r.y1) / 100; pt3.x = r.x1; ink.SetPoint(2, 4, pt3); pt3.y = r.y1 + 50 * (r.y2 - r.y1) / 100; pt3.x = r.x1 + 7 * (r.x2 - r.x1) / 100; ink.SetPoint(2, 5, pt3); pt3.y = r.y1 + 60 * (r.y2 - r.y1) / 100; pt3.x = r.x1; ink.SetPoint(2, 6, pt3); pt3.y = r.y1 + 70 * (r.y2 - r.y1) / 100; pt3.x = r.x1 + 7 * (r.x2 - r.x1) / 100; ink.SetPoint(2, 7, pt3); pt3.y = r.y1 + 80 * (r.y2 - r.y1) / 100; pt3.x = r.x1; ink.SetPoint(2, 8, pt3); pt3.y = r.y1 + 90 * (r.y2 - r.y1) / 100; pt3.x = r.x1 + 7 * (r.x2 - r.x1) / 100; ink.SetPoint(2, 9, pt3); pt3.x = r.x1; pt3.y = r.y2; ink.SetPoint(2, 10, pt3); //Right Path pt3.x = r.x2; pt3.y = r.y1; ink.SetPoint(3, 0, pt3); pt3.y = r.y1 + 10 * (r.y2 - r.y1) / 100; pt3.x = r.x2 - 7 * (r.x2 - r.x1) / 100; ink.SetPoint(3, 1, pt3); pt3.y = r.y1 + 20 * (r.y2 - r.y1) / 100; pt3.x = r.x2; ink.SetPoint(3, 2, pt3); pt3.y = r.y1 + 30 * (r.y2 - r.y1) / 100; pt3.x = r.x2 - 7 * (r.x2 - r.x1) / 100; ink.SetPoint(3, 3, pt3); pt3.y = r.y1 + 40 * (r.y2 - r.y1) / 100; pt3.x = r.x2; ink.SetPoint(3, 4, pt3); pt3.y = r.y1 + 50 * (r.y2 - r.y1) / 100; pt3.x = r.x2 - 7 * (r.x2 - r.x1) / 100; ink.SetPoint(3, 5, pt3); pt3.y = r.y1 + 60 * (r.y2 - r.y1) / 100; pt3.x = r.x2; ink.SetPoint(3, 6, pt3); pt3.y = r.y1 + 70 * (r.y2 - r.y1) / 100; pt3.x = r.x2 - 7 * (r.x2 - r.x1) / 100; ink.SetPoint(3, 7, pt3); pt3.y = r.y1 + 80 * (r.y2 - r.y1) / 100; pt3.x = r.x2; ink.SetPoint(3, 8, pt3); pt3.y = r.y1 + 90 * (r.y2 - r.y1) / 100; pt3.x = r.x2 - 7 * (r.x2 - r.x1) / 100; ink.SetPoint(3, 9, pt3); pt3.x = r.x2; pt3.y = r.y2; ink.SetPoint(3, 10, pt3); #endregion Path Calculations return(ink); }