Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

ReportPro 2 PDF Export 08 Jun 2022 10:34 #22696

  • hilberg.it
  • hilberg.it's Avatar
  • Topic Author


  • Posts: 65
  • 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:
    LOCAL oReport AS RpReport
    LOCAL cCaption, cMessage AS STRING
    
    oReport := RpReport{SELF, "C:\RP2\SAMPLES\BIT.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:
    Local oReport as RpPrinter
    oReport := RpPrinter { oOwner, self }
    IF oReport:IsValid
       oReport:Print("Report", "PRINT.PRN", "Print", "Printing...", FALSE, FALSE)
    ENDIF
    1. Some answers are very promising, but I think I am missing something. I am using RpPrinter and not RpReport. Can I convert or migrate?
    2. 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.
    3. 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.

    Please Log in or Create an account to join the conversation.

    ReportPro 2 PDF Export 08 Jun 2022 11:02 #22699

    • FFF
    • FFF's Avatar


  • Posts: 1398
  • 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 (X# 2.14.0.4; Xide 1.33; W8.1/64 German)

    Please Log in or Create an account to join the conversation.

    Last edit: by FFF.

    ReportPro 2 PDF Export 08 Jun 2022 11:03 #22700

    • ic2
    • ic2's Avatar


  • Posts: 1608
  • Hello,

    Probably I miss the point, but if you have already established that
    oReport:PrintExport(cCaption, cMessage, #RP_PDF, "myfile.pdf")

    works, why don't you just use that?

    I use it too and it works...


    Dick

    Please Log in or Create an account to join the conversation.

    ReportPro 2 PDF Export 08 Jun 2022 11:19 #22702

    • hilberg.it
    • hilberg.it's Avatar
    • Topic Author


  • Posts: 65
  • 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?

    Please Log in or Create an account to join the conversation.

    ReportPro 2 PDF Export 08 Jun 2022 11:30 #22703

    • FFF
    • FFF's Avatar


  • Posts: 1398
  • 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 (X# 2.14.0.4; Xide 1.33; W8.1/64 German)

    Please Log in or Create an account to join the conversation.

    ReportPro 2 PDF Export 08 Jun 2022 11:44 #22704

    • hilberg.it
    • hilberg.it's Avatar
    • Topic Author


  • Posts: 65
  • 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.

    File Attachment:

    File Name: RP2_TestProject.zip
    File Size:4,289 KB
    Attachments:

    Please Log in or Create an account to join the conversation.

    Last edit: by hilberg.it.

    ReportPro 2 PDF Export 08 Jun 2022 17:37 #22716

    • Chris
    • Chris's Avatar


  • Posts: 3843
  • Hi,

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

    METHOD PrintExport (xExport AS SYMBOL, cFile AS STRING, cCaption AS STRING, cMessage AS STRING) AS LOGIC

    so you'd need to call it with

    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.

    .
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    Last edit: by Chris.

    ReportPro 2 PDF Export 08 Jun 2022 19:15 #22717

    • hilberg.it
    • hilberg.it's Avatar
    • Topic Author


  • Posts: 65
  • 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!

    Please Log in or Create an account to join the conversation.

    ReportPro 2 PDF Export 09 Jun 2022 08:39 #22718

    • Chris
    • Chris's Avatar


  • Posts: 3843
  • Oh very nice! Will not touch it then :)

    .
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    • Page:
    • 1