custom word/pdf export

save, I am using the tinybutstrong external library to export a customized word file, but I am experiencing several problems with the code, my goal is to recall some fields of the records during the export in word on this customized word file, someone can give me a hand? or can you give me a code example pleasethis is my code which i entered in Page_Exporting

function Page_Exporting ()
{

   include_once ('tbs / tbs_class.php');
include_once ('tbs / tbs_plugin_opentbs.php');

$ TBS = new clsTinyButStrong;
$ TBS-> Plugin (TBS_INSTALL, OPENTBS_PLUGIN);

$ template = 'tbs / Delegation1.docx';
$ TBS-> LoadTemplate ($ template, OPENTBS_ALREADY_UTF8); // Also merge some [onload] automatic fields (depends of the type of document).
}

You need to use the Row_Export server event also, the argument $rs provides the data of each row to be exported.

I entered my code but it doesn’t work please could you give me a code example? I have a table with various fields and I would like to select only a few for later inserting them in this custom word filecodice:

function Row_Export($rs)
{

include_once('tbs/tbs_class.php');
include_once('tbs/tbs_plugin_opentbs.php');
$TBS = new clsTinyButStrong;
$TBS->Plugin(TBS_INSTALL, OPENTBS_PLUGIN);

$template = 'tbs/cliente.docx';
$TBS->LoadTemplate($template, OPENTBS_ALREADY_UTF8); // Also merge some [onload] automatic fields (depends of the type of document).

// Get a field value
// NOTE: Modify your SQL here, replace the table name, field name and the condition
$myField = ExecuteScalar("SELECT cliente FROM delege WHERE  InvNo = '".$rsold['InvoiceNo']."");

  $TBS->Show(OPENTBS_FILE, 'cliente.docx');
exit();
    //$this->ExportDoc->Text .= "my content"; // Build HTML with field value: $rs["MyField"] or $this->MyField->ViewValue
}

arbei wrote:

the argument > $rs > provides the data of each row to be exported

otto wrote:

$myField = ExecuteScalar(“SELECT cliente FROM delege WHERE InvNo = '”.> $rsold> [‘InvoiceNo’].“”);

yes I understand, but even recalling the value of my fields with $ rs the script doesn’t work, that is, it keeps exporting the default file I don’t know what I’m doing wrong, this is my code:

function Row_Export($rs)
{

include_once('tbs/tbs_class.php');
include_once('tbs/tbs_plugin_opentbs.php');
$TBS = new clsTinyButStrong;
$TBS->Plugin(TBS_INSTALL, OPENTBS_PLUGIN);

$template = 'tbs/cliente.docx';
$TBS->LoadTemplate($template, OPENTBS_ALREADY_UTF8); // Also merge some [onload] automatic fields (depends of the type of document).

$eponymo = ExecuteScalar("SELECT cliente FROM clienti WHERE cliente = ".$rs["cliente"]."");

$TBS->MergeField('cliente', $eponymo);

  $TBS->Show(OPENTBS_FILE, 'cliente.docx');
exit();
    
}

good evening, I am successfully using the TinyButStrong library and I am exporting a word model with the various parameters, then I would like the word file that is exported to be automatically converted, I wanted to use one of these two projects:https://github.com/ncjoes/office-converterhttps://github.com/smartinmedia/Net-Core-DocX-HTML-To-PDF-ConverterBut I really don’t know where to start, can someone help me? could you show me an example of code to integrate with what I have already written? many thanks in advancecode:

function Row_Export($rs)
{

include_once('tbs/tbs_class.php');
include_once('tbs/tbs_plugin_opentbs.php');
$TBS = new \clsTinyButStrong();
$TBS->Plugin(TBS_INSTALL, OPENTBS_PLUGIN);


$TBS->LoadTemplate('cliente.docx', OPENTBS_ALREADY_UTF8); // Also merge some [onload] automatic fields (depends of the type of document).

$eponymo = $rs["cliente"];

$TBS->MergeField('cliente', $eponymo);

$TBS->Show(OPENTBS_DOWNLOAD, 'cliente.docx');
}
  1. You still need Page_Exporting server event,
  2. Row_Export is fired for every row, you should not include scripts there, if you use exit() there, only one row is exported (i.e. it only works for the View page),
  3. You better include third party package by composer, see Composer Packages and use correct syntax for PHP namespace,
  4. Always enable Debug during development and check PHP errors in the log file.

hi,
do you think you can convert the word file that comes out in pdf?

I’m not sure what you meant by “convert the word file that comes out in pdf”, your code only tried to output a .docx file. It depends on what TinyButStrong can do, you better post to TinyButStrong’s forum.

practically I would like the docx model that I download to automatically convert to pdf