Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How do you get a draw rectangle to stay displayed

Community Beginner ,
Mar 10, 2017 Mar 10, 2017

I drew a rectangle on a document using the function AVPageViewDragOutNewRect, however, the rectangle flashes on the screen for a second and then disappears. How do I go about getting he rectangle to remain showing?

TOPICS
Acrobat SDK and JavaScript
3.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Contributor , Mar 10, 2017 Mar 10, 2017

Your code itself looks fine, but where are you calling it from?  You should do drawing only during one of the drawing callbacks, i.e. a handler for AVAnnotHandlerDrawProc or AVAnnotHandlerDrawExProc., or a function passed to AVAppRegisterForPageViewDrawing.

Translate
Adobe Employee ,
Mar 10, 2017 Mar 10, 2017

Something that is part of the PDF itself? Look at the PDEdit layer of APIs

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 10, 2017 Mar 10, 2017

I actually don't need the rectangle to be apart of the PDF itself. I just want it to remain displayed on the page and get the AVFixedRect associated with it. As of right now I can get the rectangle but I can't get it to stay. Here is a sample code.

AVPageViewDragOutNewRect(pageView,xHit,yHit,&resultRect);

ASFixedRect fixedRect;

AVPageViewDeviceRectToPage(pageView,&resultRect,&fixedRect);

AVPageViewGhostRectOutline(pageView, &resultRect);

AVPageViewInvalidateRect(pageView, &resultRect);

AVPageViewDrawNow (pageView);

AVPageViewDrawRect(pageView, &resultRect);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Mar 10, 2017 Mar 10, 2017

You will have ot redraw the rect as the view changes then…

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 10, 2017 Mar 10, 2017

As of right now I'm not changing the view, however, the rectangle still disappears.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Mar 10, 2017 Mar 10, 2017

Your code itself looks fine, but where are you calling it from?  You should do drawing only during one of the drawing callbacks, i.e. a handler for AVAnnotHandlerDrawProc or AVAnnotHandlerDrawExProc., or a function passed to AVAppRegisterForPageViewDrawing.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 13, 2017 Mar 13, 2017

I'm calling it from a DoClick function

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 13, 2017 Mar 13, 2017
LATEST

When you draw a rectangle - remember, this is not static PDF content, it's just information you draw in the UI - it will stay on the screen until Acrobat sees a need to redraw the page. This can be because you are scrolling, zooming, or doing anything else with the user interface, but it can also be because Acrobat, or some other plug-in decides that it's time to redraw the screen, without any user interaction. You need to keep track of these redraw operations, and then draw your rectangle again (in the correct position). Take a look at the callbacks that Dan provided. I have not done this particular operation in a while, but if I remember correctly I registered for the AVPageViewDidChange and AVPageViewDidDraw callbacks.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines