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

MouseOver events - interactive svg

Community Beginner ,
Jan 07, 2021 Jan 07, 2021

Hi,

 

I have an interactive svg document that I want to convert into an interactive pdf.  As I understand it there are no simple ways to add mouseover events to different areas of a pdf document based upon the content in the pdf itself.  For the purposes of understanding consider a patchwork diagram where each patch has data which I want to display when the cursor moves over the corresponding area.  I'm trying to replicate through code what an interactive svg can do readily.

 

I have been able run a simple document javascript set Interval function that gives me a mouseX and mouseY position at regular intervals.  I am able to define the locations of the patches as a series of polygons realating to document vertices.  I could sub-divide those polygons into triangles and test if the X and Y coordinates are within those areas using a triangle barycentric algorithm.  If I have say 6000 patches I’m worried that this may all get rather slow to compute every time the setInterval function is called - currently 50 milliseconds.

 

I’m wondering if I’m missing some capability that I don’t know about (is there a 2d equivalent of the 3dannots object for example – or should I do this using a 3D object with a fixed camera ?) .

 

I could map all of the pixels to a reference number and look that up (a table with about half a million entries ...) – is that too many pixels to loop through at each setInterval call ?  Is there anything in the inner workings of an image structure definition that is a useful trick ?

 

Many thanks for any tips !

TOPICS
JavaScript , Rich media and 3D
991
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 ,
Jan 07, 2021 Jan 07, 2021

The only objects that trigger "Mouse Over"-type events in PDF files are fields. They have a Mouse Enter and Mouse Exit triggers that can be used for that.

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 ,
Jan 15, 2021 Jan 15, 2021
LATEST

Hi try67,

 

many thanks for taking the time to answer my question it is really appreciated.  I actually got the methodology that I outlined above to work, I even have a semi-invisble button following the mouse around the screen so that an annotation object appears to have some sort of mousedown type functionality.  I wrote a script outside of acrobat that creates a pixel map and have a super big variable in my acrobat file called pixels that looks somehting like

var pixels = [

[0,0,0,0,0,1,1,1,1,1,........],

[0,0,0,0,0,1,1,1,1,1,........],

[0,0,0,0,0,2,2,2,2.2,........],

....

];

 

so with the mouseX and mouseY I reference a position in the array and that then drives an annotation object that mateches that position

 

Clearly this is all rather contrived and needs a lot of work to create the pixel map .

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