Question for users in FastReport / Pregunta para usuarios en

Post Reply
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

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.
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
hua
Posts: 861
Joined: Fri Oct 28, 2005 2:27 am

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

  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.03
xHarbour 1.2.1 (Rev 6406) + BCC
Harbour 3.1 (Rev 17062) + BCC
Harbour 3.2.0dev (r1904111533) + BCC
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

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.
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
hua
Posts: 861
Joined: Fri Oct 28, 2005 2:27 am

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.03
xHarbour 1.2.1 (Rev 6406) + BCC
Harbour 3.1 (Rev 17062) + BCC
Harbour 3.2.0dev (r1904111533) + BCC
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

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
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
hua
Posts: 861
Joined: Fri Oct 28, 2005 2:27 am

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.03
xHarbour 1.2.1 (Rev 6406) + BCC
Harbour 3.1 (Rev 17062) + BCC
Harbour 3.2.0dev (r1904111533) + BCC
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

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

Post by cnavarro »

Hua,
Now i understand the process
Thank you
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
hua
Posts: 861
Joined: Fri Oct 28, 2005 2:27 am

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

Post by hua »

You're welcome :)
FWH 11.08/FWH 19.03
xHarbour 1.2.1 (Rev 6406) + BCC
Harbour 3.1 (Rev 17062) + BCC
Harbour 3.2.0dev (r1904111533) + BCC
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

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?
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
hua
Posts: 861
Joined: Fri Oct 28, 2005 2:27 am

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.03
xHarbour 1.2.1 (Rev 6406) + BCC
Harbour 3.1 (Rev 17062) + BCC
Harbour 3.2.0dev (r1904111533) + BCC
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

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
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
Post Reply