// ExStart:DrawBox private static void DrawBox(PdfContentEditor editor, int page, TextSegment segment, System.Drawing.Color color) { var lineInfo = new LineInfo(); lineInfo.VerticeCoordinate = new[] { (float)segment.Rectangle.LLX, (float)segment.Rectangle.LLY, (float)segment.Rectangle.LLX, (float)segment.Rectangle.URY, (float)segment.Rectangle.URX, (float)segment.Rectangle.URY, (float)segment.Rectangle.URX, (float)segment.Rectangle.LLY }; lineInfo.Visibility = true; lineInfo.LineColor = color; editor.CreatePolygon(lineInfo, page, new System.Drawing.Rectangle(0, 0, 0, 0), null); }
public static void AddingBorderAroundAddedText() { // ExStart:AddingBorderAroundAddedText // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_Text(); PdfContentEditor editor = new PdfContentEditor(); editor.BindPdf(dataDir + "input.pdf"); LineInfo lineInfo = new LineInfo(); lineInfo.LineWidth = 2; lineInfo.VerticeCoordinate = new float[] { 0, 0, 100, 100, 50, 100 }; lineInfo.Visibility = true; editor.CreatePolygon(lineInfo, 1, new System.Drawing.Rectangle(0, 0, 0, 0), ""); dataDir = dataDir + "AddingBorderAroundAddedText_out.pdf"; // Save resulting PDF document. editor.Save(dataDir); // ExEnd:AddingBorderAroundAddedText Console.WriteLine("\nBorder around text added successfully.\nFile saved at " + dataDir); }