Welcome, Guest
Username: Password: Remember me
Visual Objects

Please use this forum to post questions about Visual Objects and Vulcan.NET
  • Page:
  • 1

TOPIC:

Printing a ReportPro 2.17 report to a file from a VO 2.8SP3 app. 06 Apr 2019 10:34 #8219

  • BiggyRat
  • BiggyRat's Avatar
  • Topic Author



Hi. As the subjects says, that's what I'm trying to acheive using THIS code...

Method PrintInvoice Class JobInfo
local oDB as DBServer
Local CCode, cName, cPrint2Filename, cCaption, cMessage, cJobName, nJobNUmber //as string
Local oReport as RpReport
nJobNUmber := self:oSFJobInfo_DETAIL:JOBNUMBER
cName := self:CLNAME
self:Hide()
oDB := self:oSFJobInfo_DETAIL:Server
oDB:Commit()
cJobName := "Current Jobs Listing"
cPrint2Filename := "Invoice Number " + self:oSFJobInfo_DETAIL:JOBNUMBER + " For " + Proper(cName) + ".pdf" <== This is what I want the report (Invoice in this case) to be called. Not the PDF extension.
cCaption := cAppVersion + " - Report Preview"
cMessage := "Printing in progress..."
oReport := RpReport{ self, "JobNumber.rpt"}
IF oReport:IsValid
oDB:SetOrder("JobNumber", "Details")
oDB:GoTop()
oDB:Seek(nJobNUmber)
CCode := oDB:FIELDGET(#CLCode)
oDB:Close()

oDB := CLIENT{self}
oDB:Seek( AllTrim(CCode))

cName := oDB:FIELDGET(#ClName)
oDB:Close()
oReport:SetVariableValue("ClientHeading", "TAX Invoice " + nJobNUmber)
oReport:SetVariableValue("CCode", AllTrim(CCode))
oReport:SetVariableValue("CName", AllTrim(cName) )
oReport:SetVariableValue("IsFin", .F.)
oReport:PrintPreview(cJobName,cPrint2Filename,cCaption,cMessage,,SW_SHOWMAXIMIZED)
self:Pointer := Pointer{ POINTERARROW }
ENDIF
oDB:Close()
oReport:Close()
self:Show(SHOWCENTERED)
Return nil


The <== are comments to help you understand what I'm doing

Any ideas please?

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

Last edit: by BiggyRat.

Printing a ReportPro 2.17 report to a file from a VO 2.8SP3 app. 06 Apr 2019 10:59 #8221

  • lumberjack
  • lumberjack's Avatar


  • Posts: 720
  • Hi Jeff,

    BiggyRat wrote: Hi. As the subjects says, that's what I'm trying to acheive using THIS code...

    Method PrintInvoice Class JobInfo
    	local oDB  as DBServer
    	Local CCode, cName, cPrint2Filename, cCaption, 
    		cMessage, cJobName, nJobNUmber //as string
    	Local oReport as RpReport  
    
    	nJobNUmber := self:oSFJobInfo_DETAIL:JOBNUMBER
    	cName := self:CLNAME
    	self:Hide()
    	oDB := self:oSFJobInfo_DETAIL:Server
    	oDB:Commit()
    	cJobName 		:= "Current Jobs Listing"
    	cPrint2Filename	:= "Invoice Number " + self:oSFJobInfo_DETAIL:JOBNUMBER + ;
    						" For " + Proper(cName) + ".pdf"  // <==
    
    	cCaption		:= cAppVersion + " - Report Preview"
    	cMessage		:= "Printing in progress..."
    	oReport := RpReport{ self, "JobNumber.rpt"} 
    	IF oReport:IsValid
    		oDB:SetOrder("JobNumber", "Details")
    		oDB:GoTop() 
    		oDB:Seek(nJobNUmber)
    		CCode := oDB:FIELDGET(#CLCode)
    		oDB:Close()
    
    		oDB := CLIENT{self}
    		oDB:Seek( AllTrim(CCode)) 
    
    		cName := oDB:FIELDGET(#ClName)
    		oDB:Close()  
    		oReport:SetVariableValue("ClientHeading", "TAX Invoice " + nJobNUmber)   
    		oReport:SetVariableValue("CCode", AllTrim(CCode))   
    		oReport:SetVariableValue("CName", AllTrim(cName) ) 
    		oReport:SetVariableValue("IsFin", .F.) 
    		oReport:PrintPreview(cJobName,cPrint2Filename,;
    					cCaption,cMessage,,SW_SHOWMAXIMIZED)
    		self:Pointer := Pointer{ POINTERARROW }
    	ENDIF
    	oDB:Close()
    	oReport:Close() 
    	self:Show(SHOWCENTERED)
    Return nil 

    The <== This is what I want the report (Invoice in this case) to be called. Not the PDF extension to help you understand what I'm doing
    Any ideas please?

    As stated previously, yes have ideas, but why don't you achieve this?
    ?Compiler error => Show us the compiler error
    ?What does it actually show
    Regards,
    ______________________
    Johan Nel
    Boshof, South Africa

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

    Last edit: by lumberjack.

    Printing a ReportPro 2.17 report to a file from a VO 2.8SP3 app. 06 Apr 2019 11:30 #8223

    • BiggyRat
    • BiggyRat's Avatar
    • Topic Author



    I think we have a language issue here Johan, sorry. There is no compiler error. I want to know how to write the produced invoice to a file names as I specified.

    As stated previously, yes have ideas, but why don't you achieve this?
    Makes no sense to.me at all I'm.afraid.

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

    Last edit: by BiggyRat.

    Printing a ReportPro 2.17 report to a file from a VO 2.8SP3 app. 06 Apr 2019 12:24 #8224

    • lumberjack
    • lumberjack's Avatar


  • Posts: 720
  • Hi Jeff,
    Ok I do understand your problem, you don't want to show the preview, you want to print immediately to file...

    BiggyRat wrote: Hi. As the subjects says, that's what I'm trying to acheive using THIS code...

    oReport:PrintPreview(cJobName,cPrint2Filename,;
    			cCaption,cMessage,,SW_SHOWMAXIMIZED)
    Here is the basics of how I use Report Pro to write output to a TextFile in a data-driven environment, am sure you should be able to do the same to a PDF dumping the PDF stream:
    CLASS DDE_RepPro INHERIT Dict
    	PROTECT ptrPrintFile AS PTR
    	METHOD Exec(cStream) CLASS DDE_Report
    		SELF:ptrPrintFile := FCreate2(cOutput, FC_NORMAL)
    		FClose(SELF:ptrPrintFile)
    		SELF:ptrPrintFile := FOpen2(cOutput, FO_READWRITE + FO_EXCLUSIVE)
    		IF SELF:ptrPrintFile # F_ERROR
    			FSeek(ptrPrintFile, 0, iif(lAppend, FS_END, FS_SET))
    			FWrite(SELF:ptrPrintFile, cStream)
    			FClose(SELF:ptrPrintFile)
    		ENDIF
    	RETURN SELF
    Is that answering your question?
    ______________________
    Johan Nel
    Boshof, South Africa

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

    Printing a ReportPro 2.17 report to a file from a VO 2.8SP3 app. 06 Apr 2019 12:35 #8225

    • lumberjack
    • lumberjack's Avatar


  • Posts: 720
  • Here is the code I believe you need to adapt to your :PrintPreview call:
    IF symAction = #PREVIEW
    	SELF:oPrinter:PrintPreview( SELF:cReportTitle, ;
    		SELF:cReportTitle + ".PRN", SELF:cReportTitle, "Printing...")
    ELSE
    	SELF:oPrinter:Print( SELF:cReportTitle, ;
    		SELF:cReportTitle + ".PRN", SELF:cReportTitle, "Printing...",FALSE,FALSE)
    ENDIF
    Good luck!
    ______________________
    Johan Nel
    Boshof, South Africa

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

    Printing a ReportPro 2.17 report to a file from a VO 2.8SP3 app. 06 Apr 2019 12:45 #8226

    • BiggyRat
    • BiggyRat's Avatar
    • Topic Author



    Yes, I think that may do it Johan. Thank you very much for your help.

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

    Printing a ReportPro 2.17 report to a file from a VO 2.8SP3 app. 06 Apr 2019 13:09 #8228

    • lumberjack
    • lumberjack's Avatar


  • Posts: 720
  • Hi Jeff,
    The RPViewer can be setup to have a printer for printing, which is just a printing device, e.g. PdfCreator. You just need to hook onto that, I just took it a bit further, strip the "Text" out a RP report and dump it to a textfile, or you can also dump it in a HTML file with references to the Graphics parts sitting on a shared webserver. There are plenty of options.

    In .net, you can hook a RP .rpt file and use the .net PrintPreview class to simulate exactly the way ReportPro works. Done it, it is just not user friendly. I should maybe look at creating a Designer UI around my code as alternative to RP... Any volunteers to assist?
    ______________________
    Johan Nel
    Boshof, South Africa

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

    Printing a ReportPro 2.17 report to a file from a VO 2.8SP3 app. 06 Apr 2019 16:04 #8233

    • ic2
    • ic2's Avatar


  • Posts: 1608
  • Hello Jeff,

    I think you simple mean this:


    CASE oPRT:nDestination==3 // print to file
    DO CASE
    CASE oPRT:cKindOfFile=="1" // ASCII
    oReport:PrintExport(cCaption,cMessage,#RP_ASCII,oPRT:ToFileFS:FullPath)
    CASE oPRT:cKindOfFile=="2" // HTML
    oReport:PrintExport(cCaption,cMessage,#RP_HTML,oPRT:ToFileFS:FullPath)
    CASE oPRT:cKindOfFile=="3" // WORD95
    oReport:PrintExport(cCaption,cMessage,#RP_RTF_WORD95,oPRT:ToFileFS:FullPath)
    CASE oPRT:cKindOfFile=="4" // WORD97
    oReport:PrintExport(cCaption,cMessage,#RP_RTF_WORD97,oPRT:ToFileFS:FullPath)
    CASE oPRT:cKindOfFile=="5" // EXCEL
    oReport:PrintExport(cCaption,cMessage,#RP_EXCEL,oPRT:ToFileFS:FullPath)
    CASE oPRT:cKindOfFile=="6" // pdf
    oReport:PrintExport(cCaption,cMessage,#RP_PDF,oPRT:ToFileFS:FullPath)
    CASE oPRT:cKindOfFile=="7" // email
    oReport:PrintExport(cCaption,cMessage,#RP_PDF,oPRT:ToFileFS:FullPath)

    I can mail you the whole method I use if you like.

    For PDF prints make sure you include a RpWin.ini file in the program directory with a section like below as e.g. without embedded fonts a non standard font won't display and with embedded fonts (value = 1) your PDF files are much larger.

    Dick

    [PDFOutPut]
    Title=Title
    Subject=Subject
    Author=Author
    Keywords=Keywords
    Creator=Application
    Compressed=1
    EmbedFonts=1

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

    Printing a ReportPro 2.17 report to a file from a VO 2.8SP3 app. 07 Apr 2019 03:04 #8250

    • BiggyRat
    • BiggyRat's Avatar
    • Topic Author



    That would be awesome Dick thank you very much. I'll go with what you've posted here to start, but if I could see the whole method, that would no doubt help me a lot more. Thank you again.

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

    Printing a ReportPro 2.17 report to a file from a VO 2.8SP3 app. 08 Apr 2019 23:17 #8306

    • ic2
    • ic2's Avatar


  • Posts: 1608
  • Hello Jeff,

    Just mailed it.

    Dick

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

    • Page:
    • 1