Acrobat 3D - Resizing 3D Area Programmatically with JavaScript - Setting Annot3D.rect Not Working

New Here ,
May 26, 2020

Copy link to clipboard

Copied

I have a PDF that is displaying a 3D object. There are some other fields that I would like to hide/show/relocate on the click of a button and expand the 3D area to maximize the viewer size. The Annot3D object exposes a rect property similar to a property that fields/buttons expose. When trying to set the rect property on the Annot3D object, it does not resize. I follow this same process when resizing/relocating fields and buttons and it works just fine. I have confirmed in the documentation that the field is both readable and writable. If I select the frame while using the "Prepare Form" tool, I can resize it manually, but that does not work for my use case - it must be done programmatically. See below code sample - the code works for altering the display state of the list box and the placement of the button, just not the sizing of the Annot3D object. This code lives in a MouseUp event for the button.

 

var a3d = getA3d(this); // returns Annot3D object
console.println(a3d.rect);

var collapseExpandBomButton = this.getField('Collapse_Expand_BOM');
var bomListBox = this.getField('BOMListBox');

var buttonRect = collapseExpandBomButton.rect;
var bomRect = bomListBox.rect;
var a3dRect = a3d.rect;

switch (bomListBox.display) {
    case display.hidden:
        // display it
        bomListBox.display = display.visible;

        // update button placement
        var buttonHeight = Math.abs(collapseExpandBomButton.rect[1] - collapseExpandBomButton.rect[3]);
        buttonRect[3] = bomListBox.rect[1];
        buttonRect[1] = bomListBox.rect[1] + buttonHeight;
        collapseExpandBomButton.rect = buttonRect;

        //update 3D space placement
        a3dRect[2] = buttonRect[0];
        a3dRect.rect = a3dRect;

        break;
    case display.visible:
        bomListBox.display = display.hidden;

        // update button placement
        var buttonHeight = Math.abs(collapseExpandBomButton.rect[1] - collapseExpandBomButton.rect[3]);
        buttonRect[3] = bomListBox.rect[3];
        buttonRect[1] = bomListBox.rect[3] + buttonHeight;
        collapseExpandBomButton.rect = buttonRect;

        //update 3D space placement
        a3dRect[2] = buttonRect[2];
        a3dRect.rect = a3dRect;

        break;
}

  

TOPICS
Acrobat SDK and JavaScript, Rich media and 3D

Views

165

Likes

Translate

Translate

Report

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

Acrobat 3D - Resizing 3D Area Programmatically with JavaScript - Setting Annot3D.rect Not Working

New Here ,
May 26, 2020

Copy link to clipboard

Copied

I have a PDF that is displaying a 3D object. There are some other fields that I would like to hide/show/relocate on the click of a button and expand the 3D area to maximize the viewer size. The Annot3D object exposes a rect property similar to a property that fields/buttons expose. When trying to set the rect property on the Annot3D object, it does not resize. I follow this same process when resizing/relocating fields and buttons and it works just fine. I have confirmed in the documentation that the field is both readable and writable. If I select the frame while using the "Prepare Form" tool, I can resize it manually, but that does not work for my use case - it must be done programmatically. See below code sample - the code works for altering the display state of the list box and the placement of the button, just not the sizing of the Annot3D object. This code lives in a MouseUp event for the button.

 

var a3d = getA3d(this); // returns Annot3D object
console.println(a3d.rect);

var collapseExpandBomButton = this.getField('Collapse_Expand_BOM');
var bomListBox = this.getField('BOMListBox');

var buttonRect = collapseExpandBomButton.rect;
var bomRect = bomListBox.rect;
var a3dRect = a3d.rect;

switch (bomListBox.display) {
    case display.hidden:
        // display it
        bomListBox.display = display.visible;

        // update button placement
        var buttonHeight = Math.abs(collapseExpandBomButton.rect[1] - collapseExpandBomButton.rect[3]);
        buttonRect[3] = bomListBox.rect[1];
        buttonRect[1] = bomListBox.rect[1] + buttonHeight;
        collapseExpandBomButton.rect = buttonRect;

        //update 3D space placement
        a3dRect[2] = buttonRect[0];
        a3dRect.rect = a3dRect;

        break;
    case display.visible:
        bomListBox.display = display.hidden;

        // update button placement
        var buttonHeight = Math.abs(collapseExpandBomButton.rect[1] - collapseExpandBomButton.rect[3]);
        buttonRect[3] = bomListBox.rect[3];
        buttonRect[1] = bomListBox.rect[3] + buttonHeight;
        collapseExpandBomButton.rect = buttonRect;

        //update 3D space placement
        a3dRect[2] = buttonRect[2];
        a3dRect.rect = a3dRect;

        break;
}

  

TOPICS
Acrobat SDK and JavaScript, Rich media and 3D

Views

166

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
May 26, 2020 0

Have something to add?

Join the conversation