my pdf application discoveries

From trying to make a PDF report I saw that the webinar as Marcia gave it is not up to date or the best choice to proceed with.
She describes using $pdf->… which is not the best thing to do I think.

I have some generated code here


function inicializa()
{
  global $nm_saida,
  $rec, $nmgp_chave, $nmgp_opcao, $nmgp_ordem, $nmgp_chave_det,
  $nmgp_quant_linhas, $nmgp_quant_colunas, $nmgp_url_saida, $nmgp_parms;
//
  $this->nm_data = new nm_data("nl");
  include_once("../_lib/lib/php/nm_font_tcpdf.php");
  $this->default_font = 'Times';
  $this->default_font_sr  = '';
  $this->default_style    = '';
  $this->default_style_sr = 'B';
  $Tp_papel = "A4";
  $old_dir = getcwd();
  $File_font_ttf     = "";
  $temp_font_ttf     = "";
  $this->Font_ttf    = false;
  $this->Font_ttf_sr = false;
  if (empty($this->default_font) && isset($arr_font_tcpdf[$this->Ini->str_lang]))
  {
      $this->default_font = $arr_font_tcpdf[$this->Ini->str_lang];
  }
  elseif (empty($this->default_font))
  {
      $this->default_font = "Times";
  }
  if (empty($this->default_font_sr) && isset($arr_font_tcpdf[$this->Ini->str_lang]))
  {
      $this->default_font_sr = $arr_font_tcpdf[$this->Ini->str_lang];
  }
  elseif (empty($this->default_font_sr))
  {
      $this->default_font_sr = "Times";
  }
  $_SESSION['scriptcase']['pdfreport_PS_RUG_DSS_HDR']['default_font'] = $this->default_font;
  chdir($this->Ini->path_third . "/tcpdf/");
  include_once("tcpdf.php");
  chdir($old_dir);
  $this->Pdf = new TCPDF('P', 'cm', $Tp_papel, true, 'UTF-8', false);
  $this->Pdf->setPrintHeader(false);
  $this->Pdf->setPrintFooter(false);
  if (!empty($File_font_ttf))
  {
      $this->Pdf->addTTFfont($File_font_ttf, "", "", 32, $_SESSION['scriptcase']['dir_temp'] . "/");
  }
  $this->Pdf->SetDisplayMode('real');
  $this->aba_iframe = false;

So in order to use a pdf for yourself it is better to use $this->Pdf instead of a new $pdf. Then the settings as you have filled in will then also be taken into account.
There is code being generated for another font but sadly enough that is not within the settings somewhere (: see the piece if (!empty($File_font_ttf))

Also why the pdf_scale function only uses Helvetica font is vague to me as well. There is no setting for that. So to me it appears that the pdf report is not yet fully developed. Of course this is just for developers so it is no big deal and can be ignored…


292|  function Pdf_scale()
293|  {
294|    $NM_cont  = 0;
295|    $NM_num_h = 0;
296|    $NM_num_v = 0;
297|    $this->Pdf->SetFont('Helvetica', '', 6);
298|    $this->Pdf->SetLineWidth(0.04);
299|    $this->Pdf->SetAutoPageBreak(false);

Anyway it is worth digging into it.
I guess when you use your own $pdf = new TCPDF(‘P’, ‘cm’, ‘A4’, true, ‘UTF-8’, false); you may be better of but you would miss the settings in your application then. Setting default font and background and so on would then be totally useless…

Enough info for your own experiments. Check your generated code and you can learn a lot on how to finetune your pdf to your own liking using the settings as well as basis…

Yet another discovery. Using TCPDF you get a hidden link in the lower left corner that links to http://www.tcpdf.org
In order to remove that either change the tcpdf code. Find the following code in tcpdf.php it is under: public function __construct


                $this->tcpdflink = true;

and just change true to false…

My request to scriptcase is that when the class is overloaded please set this to false as default.
My second request is to update tcpdf to the latest version… Version 6.0.063 there is already a 6.2.012

Well for most functions you can find an sc_pdf_… function that is fine. For the ones you dont find one just use $this->Pdf->… the function from tcpdf…

VERY annoying is the following. If you have the following code in the Code section of a pdf application then this doesnt work!!

sc_select(dataset, “select field from table where nr=10”);

This code does NOT get changed to scriptcase code…
In fact sc_lookup also doesnt get changed to scriptcase php code… No does apparently any other sc_ function…

That is in my view a BAD design fault. I would have added that too so that you have more freedom in generating the pdf file.
In to get a result from a subtable in my pdf I need to send the result already as parameter, I would have done the query itself in the Code section of the pdf…
So assuming OnRecord works and it delivers a record it would be needlessly hard to make a custom pdf. I would need to do all the sc_select in the OnRecord and fill the variables in a list and pick them out in the pdf part…
Ok that goes like in Marcia’s webinar. But allowing sc_ functions to be called in the Code section is the smarter idea. You can then put the logic in the pdf section instead of knowing it before hand…
Its a weird construction if you ask me… and improcing it by allowing sc_* functions (thus parsing it) would be a better more consistent solution IMHO.

No wonder that weird construction with the pdf is chosen, that is the only other way to resolve it (besides getting the database values with without directly using sc_ functions).

There is more that should be support… In my code section of a pdf I can not do this code:

sc_pdf_write(129,11,{arr_hdr[‘KEY’]});
The error I get is that there is a ( whcih is not expected.
The generated source code shows in that area:
$this->pdf->Write(129,11,{arr_hdr[‘KEY’]});

Hence my conclusion is that sc_pdf functions do get translated to $this->pdf but that variables do not (and functions also dont).
Here is a lot of toom for some serious improvement!!

Hello,

I’m checking this issue for you!

You can test it out very quickly, just write a small piece of code in the Code section of a pdf application with an sc_lookup and generate it. Then check the generated source code…

It is 2019 and I tried to do some lookup and it does not work at all.
Has this been finally fixed ???