PROGRAMMING GUIDE
You can insert a text line in a page. The text should only be one line and cannot contain carriage return. You can parameterize the font for the text, chosen beyond one of the standard fonts in Adobe Reader. Standard fonts are four faces (normal, italic, bold, bold-italic) of three Latin text typefaces: Courier, Helvetica, and Times. These standard fonts are automatically handled by Adobe Reader and don’t require any font installation. The text string content is restricted by the use of these fonts. The supported character set is the "Latin Character Set" with the Standard Encoding described in the PDF reference. The text can be positioned anywhere on the page, specified by a position in page unit, from the bottom left of the page. To create a text line, use A3DPDFTextCreate, then use A3DPDFPageInsertText to insert it on the page.
You can insert an image in a page. HOOPS Publish supports the most popular image formats (BMP, PNG, JPEG, GIF ...). The image can be positioned anywhere on the page, specified by a position in page unit, from the bottom left of the page. To create an image, use A3DPDFImageCreate, then use A3DPDFPageInsertImage to insert it on the page.
You can insert a link in a page. The link can be positioned anywhere on the page, specified by a position in page unit, from the bottom left of the page. To create a link, use A3DPDFLinkCreate, then use A3DPDFPageInsertLink to insert it on the page.
You can insert a table in a page. The table implementation uses an add-on to HOOPS Publish (TableToPDF) which is provided for free by Tech Soft 3D. The add-on is using components that are licensed under GNU LGPL terms. Consequently, the usage of tables using HOOPS Publish add-on requires our customer’s application to comply with LGPL requirements. TableToPDF can be downloaded at http://developer.techsoft3d.com/add-ons/tabletopdf/. The deployment process is simple and just requires to copy the provided DLLs in HOOPS Publish binaries folder.
Any number of tables can be positioned anywhere on the page. To create a table, use A3DPDFTableCreate, then use A3DPDFPageInsertTable to insert it on the page. The table insertion point is the top left corner of the table. The coordinate origin (0, 0) is the bottom left of the page. The unit is point.
More information is available on the Table Module.
HOOPS Publish supports text boxes, buttons, checkboxes, radio buttons, list boxes, drop down lists, and signature fields. They are all inserted similarly. The following example demonstrates how to insert a button.
When clicked, a button will execute Javascript that you specify. Like all widgets, buttons are referenced by their name field, which is a string that you specify at creation time. Buttons can use text or images as the button label.
The first thing to do when inserting a button is to define an area on the page where you want it to be displayed. Remember that the coordinate system unit is points, and the origin is the bottom left corner of the page. The following code defines the button's area in the bottom left corner:
Next, define the button's fields using A3DPDFButtonData. This structure is not stored and can be used to create additional buttons. The name field is required:
Finally, the button is created and inserted. It is not shown here, but you should always remember to handle potential errors by checking return values for all A3D* functions:
Each widget type has its own data structure that is used for defining the widget. Many fields are common, but each widget type has a few special fields. For the widgets that accept user input, the input can only be retrieved using Javascript.
Follow the pattern above to insert other widgets - corresponding data structures are noted below:
Widget | Data structure | Creation function | Insertion function | Supporting function |
---|---|---|---|---|
Button | A3DPDFButtonData | A3DPDFButtonCreate | A3DPDFPageInsertButton | |
Check box | A3DPDFCheckBoxData | A3DPDFCheckBoxCreate | A3DPDFPageInsertCheckBox | |
Drop down list | A3DPDFDropDownListData | A3DPDFDropDownListCreate | A3DPDFPageInsertDropDownList | A3DPDFPageFieldListAddItem |
List box | A3DPDFListBoxData | A3DPDFListBoxCreate | A3DPDFPageInsertListBox | A3DPDFPageFieldListAddItem |
Signature field | A3DPDFDigitalSignatureData | A3DPDFDigitalSignatureCreate | A3DPDFPageInsertDigitalSignature | |
Radio button | A3DPDFRadioButtonData | A3DPDFRadioButtonCreate | A3DPDFPageInsertRadioButton | |
Text field | A3DPDFTextFieldData | A3DPDFTextFieldCreate | A3DPDFPageInsertTextField |
If you need more information on the widgets themselves, including their members and functions, consult Adobe's documentation.
HOOPS Publish v7.2+ facilitates the creation of a view carousel. This is a component which becomes useful when you have many defined views and would like a way for the end user to browse them. The carousel, outlined in red in the image below, is scrolled by a set of buttons that you have previously defined.
In the code sample below, A3DPDFDefineViewCarousel is used to create the carousel. uiNbViews and ppViews control which views will be inserted into the carousel. Set these to 0 and NULL, respectively, to insert all views. The last parameter can be used to provide preprocessed images to be used as posters for the buttons. All buttons, including the "up" and "down" buttons, but be previously defined and are referenced by their name.
For a complete example, see the samples/publish/publishsource/DemoFunctionalities.cpp sample included with the HOOPS Publish package. The function of interest is stWriteCarousel.
The view carousel renders button icons based on the views you specify. Then, it will apply the icons to the buttons automatically. As an example, let's say you have ten views, and would like to show four buttons at a time in the carousel. Only four (not ten) buttons need to be provided in ppButtonsNames. The carousel will alternate the button icons automatically as it is scrolled. Simply click on a button to activate that view.
If you want to scroll one page of views at a time, set the scroll step to the number of views in your carousel. For example, if you have a 2x2 carousel, set the scroll step to 4. To scroll half a page at a time, set the scroll step to 2.
A slide table is an HTML table that can be scrolled using buttons. HOOPS Publish has a simplified interface for inserting slide tables. Slide tables are defined in HTML before being passed to A3DPDFDefineSlideTable. This function will take implement the logic of populating the table rows as the user scrolls the table.
Example of slide table end result:
A complete example is demonstrated in samples/publish/publishsource/DemoFunctionalities.cpp.