This section explains how to create and insert entities on a page. Entity types are listed in the section Entities.
Unless specific situation, the scenario is basically the same for all entities: the entity is created in a first step at a document level, then it is inserted and positioned on the page.
For widgets, the data is usually added on a third step by specific field functions or more generally by using data model (see section Data Model)
Inserting a text line
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 basic standard fonts in Adobe Reader, or chosen from a font installed on the machine running HOOPS Publish. The characters used in the text string are supposed to be supported by the font selected.
Using a basic standard font
Standard fonts are four faces (normal, italic, bold, bold-italic) of three Latin text typefaces: Courier, Helvetica, and Times. They are also two symbol fonts Symbol and ZapfDingbats. 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 Annex D.2 in the PDF reference, and "Symbol Set" described in Annex D.5 and D.6. Standard font is defined using A3DPDFTextData data structure.
Using a system font
Arbitrary system fonts can also be used for text lines. The font needs to be available in the system folder (C:\Windows\Fonts for Windows system) on the machine where HOOPS Publish is run, or in the 'Font' sub folder of the resource folder specified to A3DPDFInitializePDFLibAndResourceDirectory. A system font is subsetted in the final PDF, to only support the characters used in the page, leaving no need to have the font installed on the computer for the user who will open the document. System font is defined using A3DPDFTextDataEx data structure.
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 or A3DPDFTextCreateEx, then use A3DPDFPageInsertText to insert it on the page.
Inserting an image
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.
Inserting a link
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.
Inserting a table
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.
Inserting field widgets
You can create and insert fields in a page using HOOPS Publish API. Supported fields are text fields, 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.
Like all fields, buttons are referenced by their name member, 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 members using A3DPDFButtonData. This structure is not stored and can be used to create additional buttons. The name member m_pcName 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 field type has its own data structure that is used for defining the field. Many structure members are common, but each field type has a few special members.
Follow the above pattern to insert other fields - corresponding data structures are noted below:
|Field||Data structure||Creation function||Insertion function||Supporting function|
|Drop down list||A3DPDFDropDownListData||A3DPDFDropDownListCreate||A3DPDFPageInsertDropDownList||A3DPDFPageFieldListAddItem|
If you need more information on the fields themselves, including their members and functions, consult Adobe's documentation.
Specifying font for field
You can parameterize the font used for a field. The font specified must be installed on the machine running HOOPS Publish. Unfortunately, embedding a font is not completely possible for fields, as the text is theorically subject to change dynamically. Consequently, the font selected must also be installed on the machine used by the final user of the PDF document. If the font is not found by Adobe Reader, then a replacement font is tentatively selected by Adobe Reader that can display the characters used. Finally, note that an asian font selected for text field requires the Adobe Asian font package to be installed on the machine used by the final user.
Inserting rich text
Text field allows to define certain rich text attributes. For example, text color, alignment, and font, among others. To define a text field as rich text, you have to set the Boolean A3DPDFTextFieldData.m_bAllowRichText to true. Then, define a rich text value with A3DPDFTextFieldData.m_pcRichTextValue:
The above example gives us the following results:
Hello italic bold centered
Please note that the header is mandatory. Rich text strings are XHTML elements with a limited set of CSS2 style attributes:
The following piece of code is to create a text field in RTF format:
Rich text strings are defined in the PDF specification (see 188.8.131.52, "Rich Text Strings" in the section "Document management — Portable document format — Part 1: PDF 1.7").
Inserting a view carousel
HOOPS Publish 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.
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 m_ppcButtonsNames. 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.
View carousel is a high level widget. The widget is first created and inserted on a page as other entities, then the data and interactivity is defined following data model rules. A view carousel is specifically bound to a A3DPDFDataTable3DViews data table built from a A3DPDF3DArtwork and a A3DAsmModelFile. Different options exist to specify the view list and posters when the data table is created. Finally, the interaction of the view carousel with the 3D annotation must be explicitely set with function A3DPDFWidgetSetTargetBehaviour.
For a complete example, see the samples/publish/publishsource/PDFWithBOMAndCarousel.cpp sample included with the HOOPS Publish package. The function of interest is stAddViewCarousel.
Inserting a scroll table
A scroll table is a table that can be scrolled using a vertical scroll bar. HOOPS Publish has a simplified interface for inserting scroll tables. This function will implement the logic of populating the table rows as the user scrolls the table.
A scroll table is a high level widget. The widget is first created and inserted on a page as other entities, then the data and interactivity is defined following data model rules. A scroll table is bound to a A3DPDFDataTable data table. Finally, the interaction of the scroll table with other widgets must be explicitely set with function A3DPDFWidgetSetTargetBehaviour.
For a complete example, see the samples/publish/publishsource/PDFWithBOMAndCarousel.cpp sample included with the HOOPS Publish package. The function of interest is stAddScrollTable.
There isn't much to it: Just toggle the border and fill color members to true, set your desired RGB values, select a border thickness, and apply the changes to the sScrollTableData object.
Color settings can be applied to individual cells as well as to the table as a whole.