HOOPS Publish Documentation

< Home

< Reference Manual

< File Formats

PROGRAMMING GUIDE

Contents

Programming with HOOPS Publish

Initializing and terminating a session

Handling Errors

Working with a PDF document

Inserting data on a page

Defining 3D

Populating page fields

Getting PDF nodes unique identifiers

Animation API

Populating page fields

HOOPS Publish has functions to populate fields on a page. These fields must have been created with Adobe Acrobat and the Forms tool. As an example, visit the pdf_samples directory in the HOOPS Publish package and open any PDF file using Acrobat. Then edit the file with the Forms tool and the Edit menu. There, you’ll have a view on all the fields contained in the PDF file. Using Acrobat Forms, you can design the PDF page to contain different type of fields. HOOPS Publish functions supports text fields or buttons fields. All functions have the same kind of prototype: It always has the field name as an argument to identify the field, as well as an argument to set a value to the field.

Populating a text field

Acrobat Forms enables customers to define text fields. With text fields you can predefine a large set of options for the text appearance or the behavior. These options will be respected by the population function. Options are for example the font, the text or background color, the alignment in the field, or a multiline capability. To populate a text field, use the function A3DPDFPageFieldTextSetValue. The text value is specified as a UTF-8 string and characters are only restricted to the characters supported by the font selected for the field. The text can have multiple lines, in this case the carriage return character should be ’\r’.

"AdditionalText",
"This is an example of a populated text field");

Populating a field with an image

Customers can design a PDF page to receive an image. For this, you need to design a button and set the layout option to contain an icon (’icon only’ for example). The image can be stored at the template creation and never change, or can be programmatically filled with the HOOPS Publish function A3DPDFPageFieldButtonSetIcon. With this function, the value argument is an A3DPDFImage object which has to be created with the function A3DPDFImageCreate.

A3DPDFImageData sImageData;
sImageData.m_pcFileName = "c:\\temp\\myimage.jpg";
sImageData.m_iHeight = 500;
sImageData.m_iWidth = 500;
A3DPDFImage* pImage;
iRet = A3DPDFImageCreate(pDoc, &sImageData, &pImage);
iRet = A3DPDFPageFieldButtonSetIcon(pPage, "Logo", pImage);

Setting a field visibility

The visibility for a field can be programmatically specified. This enables customers to design a PDF template with a large list of fields and to adapt the list of visible fields at runtime depending on the context.

iRet = A3DPDFPageFieldSetVisibility(pPage, "SupplierRow40", false);

Setting a JavaScript action on a field

Customers can design fields to invoke JavaScript when the field is triggered by the end user. To store Javascript so that it is invoked when the user triggers a widget, see the following code snippet:

char myjs[1024]="c3d=this.getAnnots3D(0)[0].context3D;c3d.runtime.setView(\"View_3\",true);";
iRet = A3DPDFPageFieldSetActionJavascriptFromString(pPage, "Button", myjs);

Note: JavaScript variables or functions can be defined at a document level. To store JavaScript at a document level, use the function A3DPDFDocumentAddJavaScriptFromString.

The action event is different depending on the type of the field.

For documentation on the JavaScript supported by Acrobat, please consult Adobe documentation.