Page 1 of 1

Question for users in FastReport / Pregunta para usuarios en

PostPosted: Sat Oct 19, 2019 9:07 am
by cnavarro
Is it possible to export a report from fastReport to Pdf or html, for example without opening the preview window ?, that is, programmatically.
What would be the script to be developed.

Es posible exportar un report de fastReport a Pdf o html, por ejemplo sin abrir la ventana de preview?, es decir, programaticamente.
Cual sería la secuencia de comandos que hay que desarrollar.

Re: Question for users in FastReport / Pregunta para usuarios en

PostPosted: Mon Oct 21, 2019 3:39 am
by hua
I roughly do it like this for pdf (I'm just showing parts which I think are relevant to keep the code simple).
The fastreport template remains the same whether it is used for printing or export to pdf

Code: Select all  Expand view

  local oFrPrn := frReportManager():new("frsysth.dll")
  oFrPrn:setWorkArea("payroll", select("payroll")) // must be before  :loadFromfile()
  oFrPrn:setWorkArea("staff", select("staff"))
  oFrPrn:SetResyncPair("payroll", "staff")
  oFrPRn:loadFromFile("payslip.fr3")

  oFrPrn:printOptions:SetShowDialog(.f.)
  oFrPrn:SetProperty("PDFExport", "ShowDialog", .f.)
  oFrPrn:SetProperty("PDFExport", "Compressed", .t.)
  oFrPrn:SetProperty("PDFExport", "EmbeddedFonts", .f.)
  oFrPrn:SetProperty("PDFExport", "OpenAfterExport", .f.)
  oFrPrn:SetProperty("PDFExport", "PrintOptimized", .t.)
  oFrPrn:SetProperty("PDFExport", "ShowProgress", .f.)
  oFrPrn:SetProperty("PDFExport", "Background", .t.)
  oFrPrn:SetProperty("PDFExport", "Title", "Payslip")
  oFrPrn:SetProperty("PDFExport", "Subject", "Period: "+dtoc((cDbf)->frange) + " - "+dtoc((cDbf)->trange) )
  oFrPrn:SetProperty("PDFExport", "Author", "Bill Gates")
  oFrPrn:SetProperty("PDFExport", "Creator", "Microsoft")
  oFrPrn:SetProperty("PDFExport", "OwnerPassword", "Mine!")
  oFrPrn:SetProperty("PDFExport", "DefaultPath", ud_outDir())
  oFrPrn:SetProperty("PDFExport", "OverWritePrompt", .f.)
  oFrPrn:SetProperty("PDFExport", "ProtectionFlags", "[ePrint, eCopy]")

  oFrPrn:SetProperty("PDFExport", "FileName", cPdf)
  if lEncrypt
     oFrPrn:SetProperty("PDFExport", "UserPassword", cUserPassword)
  endif
  oFrPrn:PrepareReport()
  oFrPrn:DoExport("PDFExport")

  oFrPrn:end()
 

Re: Question for users in FastReport / Pregunta para usuarios en

PostPosted: Mon Oct 21, 2019 1:26 pm
by cnavarro
Thank you
My question is: if you have a report (* .fr3, I think they are called), and you want to print it directly to pdf or html without previewing it, is it possible?
Sorry but I have never used FastReport except to perform some test.

Re: Question for users in FastReport / Pregunta para usuarios en

PostPosted: Mon Oct 21, 2019 3:43 pm
by hua
Yes. The above snippet is my template for exporting to pdf silently.
I've never done so for HTML

Re: Question for users in FastReport / Pregunta para usuarios en

PostPosted: Mon Oct 21, 2019 3:54 pm
by cnavarro
hua wrote:Yes. The above snippet is my template for exporting to pdf silently.
I've never done so for HTML


Then, in your sample, cPdf variable is the name of the file output in formtat pdf, no?
But, What is the original report file in your sample?
Thanks

Re: Question for users in FastReport / Pregunta para usuarios en

PostPosted: Tue Oct 22, 2019 5:08 am
by hua
>> Then, in your sample, cPdf variable is the name of the file output in format pdf, no?
Correct.

>> But, What is the original report file in your sample?
Oops. Snipped too much :)
I have edited the code to show the call to the fr3 file

Re: Question for users in FastReport / Pregunta para usuarios en

PostPosted: Tue Oct 22, 2019 7:45 am
by cnavarro
Hua,
Now i understand the process
Thank you

Re: Question for users in FastReport / Pregunta para usuarios en

PostPosted: Tue Oct 22, 2019 6:12 pm
by hua
You're welcome :)

Re: Question for users in FastReport / Pregunta para usuarios en

PostPosted: Tue Oct 22, 2019 7:27 pm
by cnavarro
Hua, please
What types of files can I find in FastReport and its meaning. In what order these files are generated from when the report is designed until it is printed.
What type of file is with a .frf extension and when is it generated?

Re: Question for users in FastReport / Pregunta para usuarios en

PostPosted: Wed Oct 23, 2019 4:04 am
by hua
I've never encountered frf before. After some googling it seems to be fastreport's older version of fr3 file.

I only use 2 types of file with the late Spirin Sergey's adaptation of fastreport, frsysth.dll and .fr3 files

I sometimes encounter .fp3. This file is created if during preview user go and click on the disk icon to save the generated report. This file can only be viewed using FastReport Viewer.

Re: Question for users in FastReport / Pregunta para usuarios en

PostPosted: Wed Oct 23, 2019 11:13 am
by cnavarro
hua wrote:I've never encountered frf before. After some googling it seems to be fastreport's older version of fr3 file.


Sure is what you say
Thanks again

Re: Question for users in FastReport / Pregunta para usuarios en

PostPosted: Wed May 18, 2022 8:21 am
by Otto
Hello HUA,
Thank you. Your code is working fine for me.

Best regards,
Otto

Re: Question for users in FastReport / Pregunta para usuarios en

PostPosted: Thu May 19, 2022 4:02 am
by hua
You're welcome Otto.
Glad to be of help :)