protected void AddTextDataToPdfPage(PDFDoc pdfDoc, pdftron.PDF.Page pdfPage, string text)
        {
            var elementWriter = new ElementWriter();

            try
            {
                elementWriter.Begin(pdfPage);

                var elementBuilder = new ElementBuilder();
                var textFont       = Font.Create(pdfDoc, Font.StandardType1Font.e_times_roman);
                var textFontSize   = 10.0;
                var textElement    = elementBuilder.CreateTextBegin(textFont, textFontSize);
                elementWriter.WriteElement(textElement);
                elementBuilder.CreateTextRun(text);
                elementWriter.WriteElement(textElement);
                var textEnd = elementBuilder.CreateTextEnd();
                elementWriter.WriteElement(textEnd);

                elementWriter.Flush();
                elementWriter.End();
            }
            finally
            {
                elementWriter.Dispose();
            }
        }
        static Obj CreateHighlightAppearance(List <Rect> boxes, ColorPt highlightColor, double highlightOpacity, Document document)
        {
            var elementBuilder = new ElementBuilder();

            elementBuilder.PathBegin();

            boxes.ForEach(box => elementBuilder.Rect(box.x1 - 2, box.y1, box.x2 - box.x1, box.y2 - box.y1));

            Element element = elementBuilder.PathEnd();

            element.SetPathFill(true);
            element.SetPathStroke(false);

            GState elementGraphicState = element.GetGState();

            elementGraphicState.SetFillColorSpace(ColorSpace.CreateDeviceRGB());
            elementGraphicState.SetFillColor(highlightColor);
            elementGraphicState.SetFillOpacity(highlightOpacity);
            elementGraphicState.SetBlendMode(GState.BlendMode.e_bl_multiply);

            var elementWriter = new ElementWriter();

            elementWriter.Begin(document);

            elementWriter.WriteElement(element);
            Obj highlightAppearance = elementWriter.End();

            elementBuilder.Dispose();
            elementWriter.Dispose();

            Rect boundingBox = RectangleUnion(boxes);

            highlightAppearance.PutRect("BBox", boundingBox.x1, boundingBox.y1, boundingBox.x2, boundingBox.y2);
            highlightAppearance.PutName("Subtype", "Form");

            return(highlightAppearance);
        }