Printing a ReportPro 2.17 report to a file from a VO 2.8SP3 app.

Public support forum for peer to peer support with related to the Visual Objects and Vulcan.NET products
Post Reply
Anonymous

Printing a ReportPro 2.17 report to a file from a VO 2.8SP3 app.

Post by Anonymous »

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?
User avatar
lumberjack
Posts: 723
Joined: Fri Sep 25, 2015 3:11 pm

Printing a ReportPro 2.17 report to a file from a VO 2.8SP3 app.

Post by lumberjack »

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

Code: Select all

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,
BiggyRat

Printing a ReportPro 2.17 report to a file from a VO 2.8SP3 app.

Post by BiggyRat »

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.
User avatar
lumberjack
Posts: 723
Joined: Fri Sep 25, 2015 3:11 pm

Printing a ReportPro 2.17 report to a file from a VO 2.8SP3 app.

Post by lumberjack »

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...

Code: Select all

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:

Code: Select all

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?
User avatar
lumberjack
Posts: 723
Joined: Fri Sep 25, 2015 3:11 pm

Printing a ReportPro 2.17 report to a file from a VO 2.8SP3 app.

Post by lumberjack »

Here is the code I believe you need to adapt to your :PrintPreview call:

Code: Select all

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!
BiggyRat

Printing a ReportPro 2.17 report to a file from a VO 2.8SP3 app.

Post by BiggyRat »

Yes, I think that may do it Johan. Thank you very much for your help.
User avatar
lumberjack
Posts: 723
Joined: Fri Sep 25, 2015 3:11 pm

Printing a ReportPro 2.17 report to a file from a VO 2.8SP3 app.

Post by lumberjack »

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?
ic2
Posts: 1798
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Printing a ReportPro 2.17 report to a file from a VO 2.8SP3 app.

Post by ic2 »

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
BiggyRat

Printing a ReportPro 2.17 report to a file from a VO 2.8SP3 app.

Post by BiggyRat »

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.
ic2
Posts: 1798
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Printing a ReportPro 2.17 report to a file from a VO 2.8SP3 app.

Post by ic2 »

Hello Jeff,

Just mailed it.

Dick
Post Reply