ReportPro 2 PDF Export

This forum is meant for questions and discussions about the X# language and tools
Post Reply
hilberg.it
Posts: 75
Joined: Sun Sep 20, 2020 7:25 am
Location: Germany

ReportPro 2 PDF Export

Post by hilberg.it »

Hi,

I know this or similar questions have been asked a lot here. But I couldn't find anything that serves my needs.
What I want to achieve is, to print a ReportPro 2.x document straight to pdf. No Preview Dialog, just set the filename in code and create the pdf file.

That would be just right:

Code: Select all

LOCAL oReport AS RpReport
LOCAL cCaption, cMessage AS STRING

oReport := RpReport{SELF, "C:RP2SAMPLESBIT.RPT"}
IF oReport:IsValid
  cCaption            := "My App Name"
  cMessage            := "Export to PDF in progress..."
  oReport:PrintExport(cCaption, cMessage, #RP_PDF, "myfile.pdf")
ENDIF
oReport:Close()
But I am using RpPrinter in my code:

Code: Select all

Local oReport as RpPrinter
oReport := RpPrinter { oOwner, self }
IF oReport:IsValid
   oReport:Print("Report", "PRINT.PRN", "Print", "Printing...", FALSE, FALSE)
ENDIF
[*]
[*]Some answers are very promising, but I think I am missing something. I am using RpPrinter and not RpReport. Can I convert or migrate?
[*]I tried using a PDFPrinter like Free PDF Printer. But can I set the filename without the Print Dialog? And I must admit, I would prefer a solution without external dependency.
[*]Should I switch to ReportPro3? Does this help with anything? Is there a migration guide, or is migrating quite easy?


I think if someone could point me to the point of how to achieve 1) that would be best.

Thank you very much.
FFF
Posts: 1578
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

ReportPro 2 PDF Export

Post by FFF »

Not sure if i get you right, but i use your #1 in my code and it simply works.
EDIT: one difference, i use
LOCAL oReport AS RpReportRDD // NOT RpReport...

AFAIS, as long as you have an existing rpt file to access, nothing more is needed.
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
ic2
Posts: 1856
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

ReportPro 2 PDF Export

Post by ic2 »

Hello,

Probably I miss the point, but if you have already established that

Code: Select all

oReport:PrintExport(cCaption, cMessage, #RP_PDF, "myfile.pdf")
works, why don't you just use that?

I use it too and it works...


Dick
hilberg.it
Posts: 75
Joined: Sun Sep 20, 2020 7:25 am
Location: Germany

ReportPro 2 PDF Export

Post by hilberg.it »

Hi,
i use your #1 in my code and it simply works.
yes #1 code works. But in my actual app I am using #2 code snippet. This uses RpPrinter instead of RpReport. And this class doesn't have a method PrintExport AFAIK. I want to use PrintExport from #2 code approach. If I try, the function call is just skipped without any pdf beeing created. Maybe it is simple, I don't know.
AFAIS, as long as you have an existing rpt file to access, nothing more is needed.
I don't have an existing RPT file. I create Report by code. Can I convert RpPrinter approach to RpReport approach? Or are this very different things?
How can I create an pdf file from #2 code snippet?
FFF
Posts: 1578
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

ReportPro 2 PDF Export

Post by FFF »

I don't have the source, but RPPrinter inherits PTRDevice - and this HAS a PrintExport Method.
If you tried this and it compiles, i'd suspect you miss some setting in your RPPrinter initializing
BTW, your #2 sample code shows only :Print ;-)
Did you build a simple sample app to check? If so, show it here for the wise to be able to help you.
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
hilberg.it
Posts: 75
Joined: Sun Sep 20, 2020 7:25 am
Location: Germany

ReportPro 2 PDF Export

Post by hilberg.it »

Thanks,

here is a sample project attached.
Please take a look at HelpAbout.prg pshPrint() Method. Also ar_Drucken.prg CTOR. These are the methods I was talking about. In the mini app navigate to Help > About > Print.
You need to include the RP2 DLLs in the Debug Folder in order to make it work.
RP2_TestProject.zip
(4.19 MiB) Downloaded 94 times
User avatar
Chris
Posts: 4878
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

ReportPro 2 PDF Export

Post by Chris »

Hi,

The PrintExport() method of PtrDevice has (for some reason...) the parameters defined in a different order:

Code: Select all

METHOD PrintExport (xExport AS SYMBOL, cFile AS STRING, cCaption AS STRING, cMessage AS STRING) AS LOGIC
so you'd need to call it with

Code: Select all

oReport:PrintExport(#RP_PDF, "myfile.pdf", "Report", "Ausdruck")
and this should do the job. But just gave it a try and seems it doesn't work for some reason...I will have a look into it, but please also give it a try yourself, maybe I did something wrong in my quick attempt.

.
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
hilberg.it
Posts: 75
Joined: Sun Sep 20, 2020 7:25 am
Location: Germany

ReportPro 2 PDF Export

Post by hilberg.it »

The PrintExport() method of PtrDevice has (for some reason...) the parameters defined in a different order
Nice catch! For me this is working.
Thanks a lot!
User avatar
Chris
Posts: 4878
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

ReportPro 2 PDF Export

Post by Chris »

Oh very nice! Will not touch it then :)

.
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
Post Reply