FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index Utilities / Utilidades Question for users in FastReport / Pregunta para usuarios en
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Question for users in FastReport / Pregunta para usuarios en
Posted: Sat Oct 19, 2019 09:07 AM

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.

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: Question for users in FastReport / Pregunta para usuarios en
Posted: Mon Oct 21, 2019 03:39 AM
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 (fw): Select all Collapse
聽 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()
FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Question for users in FastReport / Pregunta para usuarios en
Posted: Mon Oct 21, 2019 01:26 PM

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.

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: Question for users in FastReport / Pregunta para usuarios en
Posted: Mon Oct 21, 2019 03:43 PM

Yes. The above snippet is my template for exporting to pdf silently.
I've never done so for HTML

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Question for users in FastReport / Pregunta para usuarios en
Posted: Mon Oct 21, 2019 03:54 PM
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
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: Question for users in FastReport / Pregunta para usuarios en
Posted: Tue Oct 22, 2019 05:08 AM
>> 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
FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Question for users in FastReport / Pregunta para usuarios en
Posted: Tue Oct 22, 2019 07:45 AM

Hua,
Now i understand the process
Thank you

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: Question for users in FastReport / Pregunta para usuarios en
Posted: Tue Oct 22, 2019 06:12 PM

You're welcome :)

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Question for users in FastReport / Pregunta para usuarios en
Posted: Tue Oct 22, 2019 07:27 PM
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?
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: Question for users in FastReport / Pregunta para usuarios en
Posted: Wed Oct 23, 2019 04:04 AM

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.

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Question for users in FastReport / Pregunta para usuarios en
Posted: Wed Oct 23, 2019 11:13 AM
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
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Re: Question for users in FastReport / Pregunta para usuarios en
Posted: Wed May 18, 2022 08:21 AM

Hello HUA,
Thank you. Your code is working fine for me.

Best regards,
Otto

Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: Question for users in FastReport / Pregunta para usuarios en
Posted: Thu May 19, 2022 04:02 AM

You're welcome Otto.
Glad to be of help :)

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour

Continue the discussion