Frequently Asked Question

How to add an Edit Text annotation
Last Updated 11 months ago

This article shows you how to add an Edit Text annotation to a pdf (note: this method is assumed to be added in PDFLayoutView).

public void addTextBox(float x, float y){
   float[] rect = new float[4];
   rect[0] = x;
   rect[1] = y;
   rect[2] = x + 300;
   rect[3] = y + 50;

   VPage vpage = m_layout.vGetPage(m_pageno);
   if( vpage == null ) return;
   Page page = m_doc.GetPage(vpage.GetPageNo());
   if (page == null ) return;

   Matrix mat = vpage.CreateInvertMatrix(m_layout.vGetX(), m_layout.vGetY());
   mat.TransformRect(rect);

   page.AddAnnotEditbox(rect, Color.TRANSPARENT, 0, Color.WHITE, 13, Color.BLACK);
   Page.Annotation newAnnot = page.GetAnnot(page.GetAnnotCount() - 1);
   newAnnot.SetEditText("Example Text");

   m_layout.vRenderSync(vpage);
   invalidate();
   //m_doc.Save();
}
    

AddTextBox method will add an Edit Text to a specific point:
- rect[2] is the width
- rect[3] is the height

You can edit these parameters as you want.

Loading ...