Question for users in FastReport / Pregunta para usuarios en

Question for users in FastReport / Pregunta para usuarios en

Postby cnavarro » Sat Oct 19, 2019 9: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
User avatar
cnavarro
 
Posts: 6500
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

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

Postby hua » Mon Oct 21, 2019 3: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: 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()
 
Last edited by hua on Tue Oct 22, 2019 5:06 am, edited 1 time in total.
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1038
Joined: Fri Oct 28, 2005 2:27 am

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

Postby cnavarro » Mon Oct 21, 2019 1: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
User avatar
cnavarro
 
Posts: 6500
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

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

Postby hua » Mon Oct 21, 2019 3: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
hua
 
Posts: 1038
Joined: Fri Oct 28, 2005 2:27 am

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

Postby cnavarro » Mon Oct 21, 2019 3: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
User avatar
cnavarro
 
Posts: 6500
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

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

Postby hua » Tue Oct 22, 2019 5: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
hua
 
Posts: 1038
Joined: Fri Oct 28, 2005 2:27 am

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

Postby cnavarro » Tue Oct 22, 2019 7: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
User avatar
cnavarro
 
Posts: 6500
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

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

Postby hua » Tue Oct 22, 2019 6:12 pm

You're welcome :)
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1038
Joined: Fri Oct 28, 2005 2:27 am

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

Postby cnavarro » Tue Oct 22, 2019 7: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
User avatar
cnavarro
 
Posts: 6500
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

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

Postby hua » Wed Oct 23, 2019 4: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
hua
 
Posts: 1038
Joined: Fri Oct 28, 2005 2:27 am

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

Postby cnavarro » 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
User avatar
cnavarro
 
Posts: 6500
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

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

Postby Otto » Wed May 18, 2022 8:21 am

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

Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6005
Joined: Fri Oct 07, 2005 7:07 pm

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

Postby hua » Thu May 19, 2022 4:02 am

You're welcome Otto.
Glad to be of help :)
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1038
Joined: Fri Oct 28, 2005 2:27 am


Return to Utilities / Utilidades

Who is online

Users browsing this forum: No registered users and 24 guests