Question for users in FastReport / Pregunta para usuarios en

Post Reply
User avatar
cnavarro
Posts: 6557
Joined: Wed Feb 15, 2012 8:25 pm
Location: España
Been thanked: 3 times

Question for users in FastReport / Pregunta para usuarios en

Post 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.
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
hua
Posts: 1075
Joined: Fri Oct 28, 2005 2:27 am
Has thanked: 1 time
Been thanked: 1 time

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

Post 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


  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
User avatar
cnavarro
Posts: 6557
Joined: Wed Feb 15, 2012 8:25 pm
Location: España
Been thanked: 3 times

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

Post 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.
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
hua
Posts: 1075
Joined: Fri Oct 28, 2005 2:27 am
Has thanked: 1 time
Been thanked: 1 time

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

Post by hua »

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
User avatar
cnavarro
Posts: 6557
Joined: Wed Feb 15, 2012 8:25 pm
Location: España
Been thanked: 3 times

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

Post 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
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
hua
Posts: 1075
Joined: Fri Oct 28, 2005 2:27 am
Has thanked: 1 time
Been thanked: 1 time

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

Post 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
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
User avatar
cnavarro
Posts: 6557
Joined: Wed Feb 15, 2012 8:25 pm
Location: España
Been thanked: 3 times

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

Post by cnavarro »

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
hua
Posts: 1075
Joined: Fri Oct 28, 2005 2:27 am
Has thanked: 1 time
Been thanked: 1 time

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

Post by hua »

You're welcome :)
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
User avatar
cnavarro
Posts: 6557
Joined: Wed Feb 15, 2012 8:25 pm
Location: España
Been thanked: 3 times

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

Post 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?
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
hua
Posts: 1075
Joined: Fri Oct 28, 2005 2:27 am
Has thanked: 1 time
Been thanked: 1 time

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

Post 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.
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
User avatar
cnavarro
Posts: 6557
Joined: Wed Feb 15, 2012 8:25 pm
Location: España
Been thanked: 3 times

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

Post 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
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
Otto
Posts: 6403
Joined: Fri Oct 07, 2005 7:07 pm
Has thanked: 21 times
Been thanked: 2 times
Contact:

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

Post by Otto »

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
********************************************************************
hua
Posts: 1075
Joined: Fri Oct 28, 2005 2:27 am
Has thanked: 1 time
Been thanked: 1 time

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

Post by hua »

You're welcome Otto.
Glad to be of help :)
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
Post Reply