c# - Drawing a rectangle annotation with PDFTron (PdfNet) -


i'm trying user create rectangle in pdf. user can drag rectangle on screen.

on mouseup event, rect object created , passed method addrectannotationtopage(rectangle rect)

the problem rectangle annotation differs rect user dragged. when user clicks or scrolls, annotation rectangle gets it's correct size (equal dragged rect passed argument)

why not take it's correct size immediately? , why resizes correct size whenever click on random spot in pdf?

    private void addrectannotationtopage(rectangle rect)     {         if (rect != null)         {             if (this.m_pagenumber < 0)             {                 m_pagenumber = this.getcurrentpage();             }              _cur_page = this.m_pagenumber;              if (_cur_page < 0)             {                 return;             }               double width = rect.width;             double height = rect.height;              double startx = rect.left;             double starty = rect.bottom;             double endx   = rect.right;             double endy   = rect.top;              double x1 = startx;             double y1 = starty;             double x2 = endx;             double y2 = endy;              convscreenpttopagept(ref x1, ref y1, this.getcurrentpage());             convscreenpttopagept(ref x2, ref y2, this.getcurrentpage());              rect pos = new rect(x1,y1,x2,x2);             polygon poly = pdftron.pdf.annots.polygon.create(m_pdfdocument.getsdfdoc(), pos);             pdftron.pdf.point p = new pdftron.pdf.point();             p.x = x1; p.y = y1;             poly.setvertex (0, p);             p.x = x1; p.y = y2;             poly.setvertex (1, p);             p.x = x2; p.y = y2;             poly.setvertex (2, p);             p.x = x2; p.y = y1;             poly.setvertex (3, p);               pdfdoc doc = getdoc();             doc.lock();             pdftron.pdf.page pag = doc.getpage(_cur_page);              obj annots = pag.getannots();             if (annots == null)             {                 // if there no annotations, create new annotation                  // array page.                 annots = m_pdfdocument.createindirectarray();                 pag.getsdfobj().put("annots", annots);             }              pag.annotpushback(poly);             doc.unlock();         }     } 

fixed calling refreshappearance() after setting vertices


Comments

Popular posts from this blog

testing - Detect whether test has failed within fixture -

android - Create single AAR file from multiple modules using Gradle -

AbotX : How do you create a parallel crawler that stays on and can be added to at run time from new requests -