/////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance"). // All rights reserved. // // This software and its documentation and related materials are owned by // the Alliance. The software may only be incorporated into application // programs owned by members of the Alliance, subject to a signed // Membership Agreement and Supplemental Software License Agreement with the // Alliance. The structure and organization of this software are the valuable // trade secrets of the Alliance and its suppliers. The software is also // protected by copyright law and international treaty provisions. Application // programs incorporating this software must include the following statement // with their copyright notices: // // This application incorporates Open Design Alliance software pursuant to a license // agreement with Open Design Alliance. // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance. // All rights reserved. // // By use of this software, its documentation or related materials, you // acknowledge and accept the above terms. /////////////////////////////////////////////////////////////////////////////// #include "OdaCommon.h" #include "DynamicLinker.h" #include "PdfPublish/PdfPublish.h" #include using namespace OdPdfPublish; OdResult OdPdfPublishControlsEx(OdDbBaseHostAppServices* pHostApp, const OdString& sOutPdf) { if (sOutPdf.isEmpty()) { return eInvalidInput; } OdFilePtr pPublisher = OdFile::createObject(); OdDocumentPtr pDoc = OdDocument::createObject(); pDoc->setInformation(L"Pdf Publish Controls Sample Document", L"Author", L"Controls Sample", L"Oda Pdf Publish", L"ODA, PDF", L"Oda Pdf Publish"); pDoc->setHostServices(pHostApp); OdPagePtr pPage = OdPage::createObject(); pPage->setFormat(Page::kA3); pPage->setOrientation(Page::kLandscape); pDoc->addPage(pPage); OdUInt32 top_line_top = 830; OdUInt32 top_line_text_top = 650; OdRect button_rect(20, 200, top_line_top - 80, top_line_top); OdButtonPtr pButton = OdButton::createObject(); OdString button_name(L"TestButton"); pButton->setName(button_name); pButton->setLabel(L"Test"); pPage->addButton(pButton, button_rect); OdRect tx_button_rect(20, 200, top_line_text_top - 30, top_line_text_top); OdTextFieldPtr tx2button = OdTextField::createObject(); OdString tx2button_name(L"ButtonText"); tx2button->setName(tx2button_name); pPage->addTextField(tx2button, tx_button_rect); const OdChar* buttonActionBase = L"var text_field = getField('%s');\n" L"if(text_field != null) \n" L" text_field.value = '%s'; \n"; pPage->addJavaScriptActionByField(button_name, OdString().format(buttonActionBase, tx2button_name.c_str(), L"button is pressed"), Action::kButtonPressed); pPage->addJavaScriptActionByField(button_name, OdString().format(buttonActionBase, tx2button_name.c_str(), L"button is released"), Action::kButtonReleased); pPage->addJavaScriptActionByField(button_name, OdString().format(buttonActionBase, tx2button_name.c_str(), L"cursor enters"), Action::kCursorEnter); pPage->addJavaScriptActionByField(button_name, OdString().format(buttonActionBase, tx2button_name.c_str(), L"cursor exits"), Action::kCursorExit); OdRect listbox_rect(220, 420, top_line_top - 160, top_line_top); OdListBoxPtr pListBox = OdListBox::createObject(); OdString listbox_name(L"TestListBox"); pListBox->setName(listbox_name); OdStringArray displayed_values; OdStringArray export_values; for(int i = 0; i < 15; ++i) { displayed_values.append(OdString().format(L"lb_disp%i", i)); export_values.append(OdString().format(L"lb_exp%i", i)); } pListBox->setContents(displayed_values, export_values); pPage->addListBox(pListBox, listbox_rect); OdRect tx_listbox_rect(220, 420, top_line_text_top - 30, top_line_text_top); OdTextFieldPtr tx2listbox = OdTextField::createObject(); OdString tx2listbox_name(L"ListBoxText"); tx2listbox->setName(tx2listbox_name); pPage->addTextField(tx2listbox, tx_listbox_rect); const OdChar* listboxActionBase = L"var text_field = getField('%s'); \n" L"var field = getField('%s'); \n" L"if(text_field != null && field != null) \n" L"{ \n" L" text_field.value = field.value; \n" L"} \n"; pPage->addJavaScriptActionByField(listbox_name, OdString().format(listboxActionBase, tx2listbox_name.c_str(), listbox_name.c_str()), Action::kLoseFocus); OdRect dropdown_rect(440, 640, top_line_top - 30, top_line_top); OdDropDownListPtr pDropDown = OdDropDownList::createObject(); OdString dropdown_name(L"TestDropDown"); pDropDown->setName(dropdown_name); OdStringArray dddisplayed_values; OdStringArray ddexport_values; for(int i = 0; i < 15; ++i) { dddisplayed_values.append(OdString().format(L"dd_disp%i", i)); ddexport_values.append(OdString().format(L"dd_exp%i", i)); } pDropDown->setContents(dddisplayed_values, ddexport_values); pPage->addDropDownList(pDropDown, dropdown_rect); OdRect tx_dropdown_rect(440, 640, top_line_text_top - 30, top_line_text_top); OdTextFieldPtr tx2dropdown = OdTextField::createObject(); OdString tx2dropdown_name(L"DropDownText"); tx2dropdown->setName(tx2dropdown_name); pPage->addTextField(tx2dropdown, tx_dropdown_rect); pPage->addJavaScriptActionByField(dropdown_name, OdString().format(listboxActionBase, tx2dropdown_name.c_str(), dropdown_name.c_str()), Action::kLoseFocus); OdRect checkbox_rect(755, 805, top_line_top - 30, top_line_top); OdCheckBoxPtr pCheckBox = OdCheckBox::createObject(); pCheckBox->setBorder(true); pCheckBox->setBorderStyle(Border::kDashed); pCheckBox->setFontSize(20); OdString checkbox_name(L"TestCheckBox"); pCheckBox->setName(checkbox_name); pCheckBox->setExportValue(L"CheckBox Exported Value"); pPage->addCheckBox(pCheckBox, checkbox_rect); OdRect tx_checkbox_rect(680, 880, top_line_text_top - 30, top_line_text_top); OdTextFieldPtr tx2checkbox = OdTextField::createObject(); OdString tx2checkbox_name(L"CheckBoxText"); tx2checkbox->setName(tx2checkbox_name); pPage->addTextField(tx2checkbox, tx_checkbox_rect); const OdChar* checkboxActionBase = L"var text_field = getField('%s'); \n" L"var cb_field = getField('%s'); \n" L"if(text_field != null && cb_field != null) \n" L"{ \n" L" if(cb_field.value == 'Yes') \n" L" text_field.value = cb_field.exportValues[0]; \n" L" else \n" L" text_field.value = cb_field.value; \n" L"} \n"; pPage->addJavaScriptActionByField(checkbox_name, OdString().format(checkboxActionBase, tx2checkbox_name.c_str(), checkbox_name.c_str()), Action::kButtonReleased); OdRect radio_btn_rect(975, 1025, top_line_top - 30, top_line_top); OdString radio_btn_name(L"TestRadioButton"); for(int i = 0; i < 3; ++i) { OdRadioButtonPtr pRadioButton = OdRadioButton::createObject(); pRadioButton->setGrouping(true); pRadioButton->setName(radio_btn_name); if(1 == i) pRadioButton->setDefaultState(true); pRadioButton->setExportValue(OdString().format(L"RadioButton Exported Value %i", i)); pPage->addRadioButton(pRadioButton, radio_btn_rect); radio_btn_rect.m_max.y = radio_btn_rect.m_min.y - 10; radio_btn_rect.m_min.y = radio_btn_rect.m_max.y - 30; } OdRect tx_radio_btn_rect(900, 1100, top_line_text_top - 30, top_line_text_top); OdTextFieldPtr tx2radio_btn = OdTextField::createObject(); OdString tx2radio_btn_name(L"RadioButtonText"); tx2radio_btn->setName(tx2radio_btn_name); pPage->addTextField(tx2radio_btn, tx_radio_btn_rect); const OdChar* radio_btnActionBase = L"var text_field = getField('%s'); \n" L"var rb_field = getField('%s'); \n" L"if(text_field != null && rb_field != null) \n" L"{ \n" L" count = rb_field.page.length; \n" L" for(var i = 0; iaddJavaScriptActionByField(radio_btn_name, OdString().format(radio_btnActionBase, tx2radio_btn_name.c_str(), radio_btn_name.c_str()), Action::kButtonReleased); OdRect text_rect(20, 1100, top_line_text_top - 80, top_line_text_top - 50); OdTextFieldPtr pTextField = OdTextField::createObject(); OdString text_name(L"TextText"); pTextField->setName(text_name); pPage->addTextField(pTextField, text_rect); const OdChar* textActionBase = L"var text_field = getField('%s'); \n" L"if(text_field != null) \n" L"{ \n" L" text_field.value = Date().toString() + ': ' + \n" L" text_field.value; \n" L"} \n"; pPage->addJavaScriptActionByField(text_name, OdString().format(textActionBase, text_name.c_str()), Action::kLoseFocus); OdRect rect_table1(20, 550, 100, 550); OdRect rect_table2(600, 1100, 100, 550); OdDoubleArray columns_sizes; columns_sizes.resize(10, 0.1); OdSlideTablePtr table1 = OdSlideTable::createObject(); table1->setDimensions(columns_sizes, 30); OdSlideTablePtr table2 = OdSlideTable::createObject(); table2->setDimensions(columns_sizes, 30); OdTextFieldPtrArray fields; OdUInt32 col_count = 10; OdUInt32 row_count = 20; for(OdUInt32 i=0; isetName(fieldName); textField->setDefaultValue(fieldName); textField->setBorder(true); fields.append(textField); } } table1->setHeader(true); table1->setText(row_count, col_count, fields); table2->setHeader(true); table2->setText(row_count, col_count, fields); table2->setButtons(L"Prev", L"Next"); pPage->addSlideTable(table1, rect_table1); pPage->addSlideTable(table2, rect_table2); OdRect sign_rect(20, 1100, 40, 80); OdSignatureFieldPtr pSignatureField = OdSignatureField::createObject(); OdString sign_name(L"SignatureFieldTest"); pSignatureField->setName(sign_name); pPage->addSignatureField(pSignatureField, sign_rect); // Annotations Page OdPagePtr pPage1 = OdPage::createObject(); pPage1->setFormat(Page::kA3); pPage1->setOrientation(Page::kLandscape); pDoc->addPage(pPage1); const long startX = 50; const long startY = 800; const long stepX = 130; const long width = 100; const long height = 50; // --- StickyNoteAnnotations { int idx = 0; for (auto type : { StickyNotes::kComment, StickyNotes::kKey, StickyNotes::kNote, StickyNotes::kHelp }) { OdStickyNotePtr note = OdStickyNote::createObject(); note->setStickyNoteType(type); note->setPopupLocation(OdRect(440, 600, startY - 90, startY)); note->setContents(L"Note 1 contents \nsecond line \nthird line"); note->setTitle(L"user name"); note->setDescription(L"Node 1 Description"); note->setColor(ODRGB(255, 0, 0)); note->setLock(true); note->setOpacity(50); note->setMarkedState(MarkupAnnotations::kMarkedState); note->setReviewState(MarkupAnnotations::kAccepted); OdTimeStamp time(OdTimeStamp::kInitLocalTime); note->setCreationDate(time); pPage1->addStickyNote(note, OdRect(startX + idx * stepX, startX + idx * stepX + width, startY - height, startY)); ++idx; } } std::vector borderStyles = { Border::Style::kSolid, Border::Style::kDashed }; std::vector effects = { Border::Effect::kNoEffect, Border::Effect::kCloudy }; // --- SquareAnnotations { int idx = 0; for (auto style : borderStyles) { for (auto effect : effects) { OdSquareAnnotationPtr square = OdSquareAnnotation::createObject(); OdAnnotationBorderStylePtr bstylePtr = OdAnnotationBorderStyle::createObject(); bstylePtr->setWidth(2.0); bstylePtr->setStyle(style); if (style == Border::Style::kDashed) { OdDoubleArray dash; dash.append(1.); dash.append(1.); bstylePtr->setDashPattern(dash); } square->setLineStyle(bstylePtr); OdAnnotationBorderEffectPtr effectPtr = OdAnnotationBorderEffect::createObject(); effectPtr->setEffect(effect); if (effect == Border::kCloudy) effectPtr->setIntensity(1.3); square->setLineEffect(effectPtr); square->setColor(ODRGB(255, 0, 0)); square->setOpacity(50); pPage1->addSquareAnnotation(square, OdRect(startX + idx * stepX, startX + idx * stepX + width, startY - 150, startY - 100)); ++idx; } } } // --- CircleAnnotations { int idx = 0; for (auto style : borderStyles) { for (auto effect : effects) { OdCircleAnnotationPtr circle = OdCircleAnnotation::createObject(); OdAnnotationBorderStylePtr bstylePtr = OdAnnotationBorderStyle::createObject(); bstylePtr->setWidth(3.0); bstylePtr->setStyle(style); if (style == Border::Style::kDashed) { OdDoubleArray dash; dash.append(2.); dash.append(3.); bstylePtr->setDashPattern(dash); } circle->setLineStyle(bstylePtr); OdAnnotationBorderEffectPtr effectPtr = OdAnnotationBorderEffect::createObject(); effectPtr->setEffect(effect); if (effect == Border::Effect::kCloudy) effectPtr->setIntensity(1.0); circle->setLineEffect(effectPtr); circle->setColor(ODRGB(0, 0, 255)); circle->setOpacity(70); pPage1->addCircleAnnotation(circle, OdRect(startX + idx * stepX, startX + idx * stepX + width, startY - 230, startY - 180)); ++idx; } } } // --- PolygonAnnotations { int idx = 0; for (auto sides : { 3, 5, 7 }) { OdPolygonAnnotationPtr polygon = OdPolygonAnnotation::createObject(); OdGePoint2dArray points; const long cx = startX + idx * stepX + width / 2; const long cy = startY - 280; const double radius = 25.0; for (int i = 0; i < sides; ++i) { double angle = i * 2.0 * OdaPI / sides - OdaPI / 2.0; points.push_back(OdGePoint2d(cx + radius * cos(angle), cy + radius * sin(angle))); } polygon->setVertices(points); OdAnnotationBorderStylePtr bstylePtr = OdAnnotationBorderStyle::createObject(); bstylePtr->setWidth(2.0); bstylePtr->setStyle(Border::Style::kSolid); polygon->setLineStyle(bstylePtr); OdAnnotationBorderEffectPtr effectPtr = OdAnnotationBorderEffect::createObject(); effectPtr->setEffect(Border::Effect::kNoEffect); polygon->setLineEffect(effectPtr); polygon->setColor(ODRGB(0, 128, 0)); polygon->setOpacity(80); pPage1->addPolygonAnnotation(polygon, OdRect(cx, cx + 100, cy, cy + 100)); ++idx; } } // --- PolylineAnnotations { int idx = 0; for (auto startLE : { LineEnding::kNone, LineEnding::kOpenArrow, LineEnding::kClosedArrow }) { for (auto endLE : { LineEnding::kNone, LineEnding::kCircle, LineEnding::kDiamond }) { OdPolylineAnnotationPtr polyline = OdPolylineAnnotation::createObject(); OdGePoint2dArray pts; pts.push_back(OdGePoint2d(startX + idx * stepX, startY - 360)); pts.push_back(OdGePoint2d(startX + idx * stepX + 40, startY - 390)); pts.push_back(OdGePoint2d(startX + idx * stepX + 80, startY - 360)); polyline->setVertices(pts); polyline->setEndings(startLE, endLE); OdAnnotationBorderStylePtr bstylePtr = OdAnnotationBorderStyle::createObject(); bstylePtr->setWidth(2.0); bstylePtr->setStyle(Border::Style::kDashed); polyline->setLineStyle(bstylePtr); polyline->setColor(ODRGB(128, 0, 128)); polyline->setOpacity(75); pPage1->addPolylineAnnotation(polyline, OdRect(startX + idx * stepX, startX + idx * stepX + 100, startY - 390, startY - 360)); ++idx; } } } // --- CaretAnnotation & TextAnnotation { OdTextPtr text_caret = OdText::createObject(); text_caret->setText(L"Example text with caret annotation"); pPage1->addText(text_caret, OdRect(startX, startX + 200, startY - 450, startY - 400)); OdCaretAnnotationPtr caret = OdCaretAnnotation::createObject(); text_caret->addCaretAnnotation(caret, 7); const OdChar* textContent[] = { L"Highlight", L"Underline", L"Squiggly", L"StrikeOut" }; for (int t = TextMarkupAnnotations::kHighlight; t <= TextMarkupAnnotations::kStrikeOut; ++t) { OdTextPtr pText = OdText::createObject(); pText->setText(textContent[t]); pPage1->addText(pText, OdRect(startX + 200 + t * stepX, startX + 300 + t * stepX, startY - 450, startY - 400)); OdTextMarkupAnnotationPtr pMarkup = OdTextMarkupAnnotation::createObject(); pMarkup->setColor(ODRGB(50 + t * 40, 200 - t * 30, 100 + t * 20)); pMarkup->setTextMarkupAnnotationType((TextMarkupAnnotations::TextMarkupAnnotationTypes)t); pText->addTextMarkupAnnotation(pMarkup); } } // --- InkAnnotation { OdInkAnnotationPtr ink = OdInkAnnotation::createObject(); OdGePoint2dArray stroke1 = { OdGePoint2d(startX, startY - 500), OdGePoint2d(startX + 30, startY - 530), OdGePoint2d(startX + 60, startY - 490) }; OdGePoint2dArray stroke2 = { OdGePoint2d(startX + 70, startY - 530), OdGePoint2d(startX + 100, startY - 490), OdGePoint2d(startX + 130, startY - 500) }; OdArray inkList; inkList.push_back(stroke1); inkList.push_back(stroke2); ink->setInkList(inkList); OdAnnotationBorderStylePtr bstylePtr = OdAnnotationBorderStyle::createObject(); bstylePtr->setWidth(2.0); bstylePtr->setStyle(Border::Style::kSolid); ink->setLineStyle(bstylePtr); ink->setColor(ODRGB(0, 0, 0)); pPage1->addInkAnnotation(ink, OdRect(startX, startX + 132, startY - 500, startY - 490)); } // --- StampAnnotations { int idx = 0; for (auto stampType : { StampAnnotations::StampAnnotationTypes::kApproved, StampAnnotations::StampAnnotationTypes::kExperimental, StampAnnotations::StampAnnotationTypes::kNotApproved, StampAnnotations::StampAnnotationTypes::kDraft, StampAnnotations::StampAnnotationTypes::kConfidential }) { OdStampAnnotationPtr stamp = OdStampAnnotation::createObject(); stamp->setStampAnnotationType(stampType); stamp->setOpacity(90); pPage1->addStampAnnotation(stamp, OdRect(startX + idx * stepX, startX + idx * stepX + width, startY - 630, startY - 580)); ++idx; } } // --- LineAnnotations { int idx = 0; OdLineAnnotationPtr line1 = OdLineAnnotation::createObject(); line1->setPoints(OdGePoint2d(startX + idx * stepX, startY - 700), OdGePoint2d(startX + idx * stepX + 100, startY - 750)); OdAnnotationBorderStylePtr bstylePtr = OdAnnotationBorderStyle::createObject(); bstylePtr->setWidth(2.0); bstylePtr->setStyle(Border::Style::kSolid); line1->setLineStyle(bstylePtr); line1->setColor(ODRGB(255, 0, 0)); line1->setCaption(L"Line caption"); line1->setEndings(LineEnding::kOpenArrow, LineEnding::kClosedArrow); pPage1->addLineAnnotation(line1, OdRect(startX + idx * stepX, startX + idx * stepX + 100, startY - 750, startY - 700)); ++idx; OdLineAnnotationPtr line2 = OdLineAnnotation::createObject(); line2->setPoints(OdGePoint2d(startX + idx * stepX, startY - 700), OdGePoint2d(startX + idx * stepX + 100, startY - 750)); OdAnnotationBorderStylePtr bstylePtr2 = OdAnnotationBorderStyle::createObject(); bstylePtr2->setWidth(2.0); bstylePtr2->setStyle(Border::Style::kDashed); OdDoubleArray dash; dash.append(1.); dash.append(1.); bstylePtr2->setDashPattern(dash); line2->setLineStyle(bstylePtr2); line2->setColor(ODRGB(0, 255, 0)); line2->setCaptionPosition(LineOptions::kTop); line2->setCaption(L"Line caption"); line2->setEndings(LineEnding::kDiamond, LineEnding::kNone); pPage1->addLineAnnotation(line2, OdRect(startX + idx * stepX, startX + idx * stepX + 100, startY - 750, startY - 700)); ++idx; OdLineAnnotationPtr line3 = OdLineAnnotation::createObject(); line3->setPoints(OdGePoint2d(startX + idx * stepX, startY - 700), OdGePoint2d(startX + idx * stepX + 100, startY - 750)); OdAnnotationBorderStylePtr bstylePtr3 = OdAnnotationBorderStyle::createObject(); bstylePtr3->setWidth(2.0); bstylePtr3->setStyle(Border::Style::kSolid); line3->setLineStyle(bstylePtr3); line3->setColor(ODRGB(255, 140, 0)); line3->setLineIntent(LineOptions::kLineDimension); line3->setCaptionPosition(LineOptions::kInline); line3->setCaption(L"Line caption"); line3->setEndings(LineEnding::kOpenArrow, LineEnding::kClosedArrow); line3->setLeaderLinesSize(50); line3->setLeaderLinesExtSize(10); pPage1->addLineAnnotation(line3, OdRect(startX + idx * stepX, startX + idx * stepX + 100, startY - 750, startY - 700)); ++idx; OdLineAnnotationPtr line4 = OdLineAnnotation::createObject(); line4->setPoints(OdGePoint2d(startX + idx * stepX, startY - 700), OdGePoint2d(startX + idx * stepX + 100, startY - 750)); OdAnnotationBorderStylePtr bstylePtr4 = OdAnnotationBorderStyle::createObject(); bstylePtr4->setWidth(2.0); bstylePtr4->setStyle(Border::Style::kSolid); line4->setLineStyle(bstylePtr4); line4->setColor(ODRGB(0, 0, 255)); line4->setCaptionPosition(LineOptions::kTop); line4->setCaption(L"Line caption"); line4->setCaptionOffset(OdGePoint2d(30, 50)); pPage1->addLineAnnotation(line4, OdRect(startX + idx * stepX, startX + idx * stepX + 100, startY - 750, startY - 700)); } //XML data can be obtained from an HTML / Rich text editor by wrapping this code in // // // and // //In addition, only the simplest tags are supported(< / br> is not supported, color can only // be specified as a string of the type color : #008800) const OdChar* xml_sample1 = L"" L"" L"

" L"Explore the capabilities of XFA Rich Text rendering in PDF. " L"It includes underlining, " L"italic, and " L"colored bold text." L"

" L"

" L"Spacing can be preserved using and " L"strikeout is also supported." L"

" L"

" L"Created by ODA Open Design Alliance" L"

" L""; const OdChar* xml_sample2 = L"" L"" L"

" L"Name Score Grade" L"

" L"

" L"Alice 92 A" L"

" L"

" L"Bob 84 B" L"

" L"

" L"This layout uses xfa-spacerun and fixed-width logic." L"

" L""; const OdChar* xml_sample3 = L"" L"" L"

" L"Red text, " L"green text, and " L"blue text are fully supported." L"

" L"

" L"Preserve spacing with multiple spaces." L"

" L"

" L"Rendered by ODA Open Design Alliance" L"

" L""; const OdChar* xml_sample4 = L"" L"" L"

" L"Item Qty Price" L"

" L"

" L"Apple 2 $3.00" L"

" L"

" L"Banana 5 $2.50" L"

" L""; const OdChar* xml_sample5 = L"" L"" L"

" L"You can embed hyperlinks " L"directly in your rich text. These links will appear in blue " L"and may be underlined." L"

" L"

" L"Color and weight can emphasize parts " L"of the content. Use this to draw attention or organize information visually." L"

" L"

" L"Provided by ODA Open Design Alliance" L"

" L""; const OdChar* xml_sample6 = L"" L"" L"

" L"XFA Rich Text Showcase" L"

" L"

" L"This sample demonstrates bold, " L"italic, " L"underlined, and " L"colored text styles." L"

" L"

" L"Published by ODA Open Design Alliance" L"

" L""; const OdChar * xml_samples[] = { xml_sample1, xml_sample2, xml_sample3, xml_sample4, xml_sample5, xml_sample6, }; // Rich text OdPagePtr pPage2 = OdPage::createObject(); pPage2->setFormat(Page::kA3); pPage2->setOrientation(Page::kLandscape); pDoc->addPage(pPage2); OdUInt32 i = 0; for (OdUInt32 x = 50; x < 840; x += 350) for (OdUInt32 y = 50; y < 548; y += 250) { OdRect f_rect(x, x + 300, y, y + 200); OdTextFieldPtr rt_text_field = OdTextField::createObject(); OdString sample_rt_text_field_name = OdString().format(L"ButtonText_%i_%i", x, y); rt_text_field->setMultiline(true); rt_text_field->setTextJustification(Text::kLeft); rt_text_field->setFont(Text::StandardFontsType::kHelvetica); rt_text_field->setFontSize(12); rt_text_field->setName(sample_rt_text_field_name); rt_text_field->setRichText(xml_samples[i++]); pPage2->addTextField(rt_text_field, f_rect); } pPublisher->exportPdf(pDoc, sOutPdf); return ::eOk; }