PDF File not being created
Posted: Sat Dec 14, 2019 2:13 am
Hi, I've created a report, it prints to screen, printer and I can save manually to a file, but I cannot automate it, despite being able to do exactly what I want in the last program I wrote. I cannot see where I'm going wrong. Here's the code, and a screenshot of the variables output:
METHOD OKButton( ) CLASS EditInvoice
Local oReport as RpReport
Local cFileName, cWorkDir,cMessage, cStr as String
Local nInv, cCaption
nInv := self:Server:FIELDGET(#INVNO)
If gTermDays == 0
gDueDate := FT_LDay(Today())
else
gDueDate := Today() + gTermDays
end if
// Bill To fields
self:Server:FIELDPUT(#MAILADD1, AllTrim(self:oDCMAILADD1:CurrentText))
self:Server:FIELDPUT(#MAILADD2, AllTrim(self:oDCMAILADD2:CurrentText))
self:Server:FIELDPUT(#MAILSUBURB, AllTrim(self:oDCMAILSUBURB:CurrentText))
self:Server:FIELDPUT(#MAILPCODE, AllTrim(self:oDCMAILPCODE:CurrentText))
self:Server:FIELDPUT(#MAILSTATE, AllTrim(self:oDCMAILSTATE:CurrentText))
self:Server:FIELDPUT(#CLNAME, AllTrim(self:oDCCLNAME:CurrentText))
self:Server:FIELDPUT(#INVDATE, self:oDCInvDateDTP:SelectedDate)
self:Server:FIELDPUT(#INVDUE, self:oDCDateTimePicker1:SelectedDate)
self:Server:FIELDPUT(#CLIENTREF, self:oDCCLIENTREF:CurrentText)
// Line 1
self:Server:FIELDPUT(#ITEM1, AllTrim(self:oDCComboBoxEx1:CurrentItem))
self:Server:FIELDPUT(#TAXTYPE1, iif(IsNil(self:oDCComboBoxEx11:VALUE), "", self:oDCComboBoxEx11:VALUE))
self:Server:FIELDPUT(#ACC1, AllTrim(self:oDCComboBoxEx21:CurrentItem))
self:Server:FIELDPUT(#UNITPR1, self:oDCUNITPR1:VALUE)
self:Server:FIELDPUT(#QTY1, self:oDCQTY1:VALUE)
self:Server:FIELDPUT(#GST1, self:oDCSingleLineEdit37:VALUE)
self:Server:FIELDPUT(#TOTPR1, self:oDCTOTPR1:VALUE)
self:Server:FIELDPUT(#LINE1, self:oDCLINE1:CurrentText)
self:Server:Commit()
// Line 2
self:Server:FIELDPUT(#ITEM2, self:oDCComboBoxEx2:CurrentItem)
self:Server:FIELDPUT(#TAXTYPE2, iif(IsNil(self:oDCComboBoxEx12:VALUE), "", self:oDCComboBoxEx12:VALUE))
self:Server:FIELDPUT(#ACC2, self:oDCComboBoxEx22:CurrentItem)
self:Server:FIELDPUT(#UNITPR2, self:oDCUNITPR2:VALUE)
self:Server:FIELDPUT(#QTY2, self:oDCQTY2:VALUE)
self:Server:FIELDPUT(#GST2, self:oDCSingleLineEdit38:VALUE)
self:Server:FIELDPUT(#TOTPR2, self:oDCTOTPR2:VALUE)
self:Server:FIELDPUT(#LINE2, self:oDCLINE2:CurrentText)
self:Server:Commit()
// Line 3
self:Server:FIELDPUT(#ITEM3, self:oDCComboBoxEx3:CurrentItem)
self:Server:FIELDPUT(#TAXTYPE3, iif(IsNil(self:oDCComboBoxEx13:VALUE), "", self:oDCComboBoxEx13:VALUE))
self:Server:FIELDPUT(#ACC3, self:oDCComboBoxEx23:CurrentItem)
self:Server:FIELDPUT(#UNITPR3, self:oDCUNITPR3:VALUE)
self:Server:FIELDPUT(#QTY3, self:oDCQTY3:VALUE)
self:Server:FIELDPUT(#GST3, self:oDCSingleLineEdit39:VALUE)
self:Server:FIELDPUT(#TOTPR3, self:oDCTOTPR3:VALUE)
self:Server:FIELDPUT(#LINE3, self:oDCLINE3:CurrentText)
self:Server:Commit()
// Line 4
self:Server:FIELDPUT(#ITEM4, self:oDCComboBoxEx4:CurrentItem)
self:Server:FIELDPUT(#TAXTYPE4, iif(IsNil(self:oDCComboBoxEx14:VALUE), "", self:oDCComboBoxEx14:VALUE))
self:Server:FIELDPUT(#ACC4, self:oDCComboBoxEx24:CurrentItem)
self:Server:FIELDPUT(#UNITPR4, self:oDCUNITPR4:VALUE)
self:Server:FIELDPUT(#QTY4, self:oDCQTY4:VALUE)
self:Server:FIELDPUT(#GST4, self:oDCSingleLineEdit40:VALUE)
self:Server:FIELDPUT(#TOTPR4, self:oDCTOTPR4:VALUE)
self:Server:FIELDPUT(#LINE4, self:oDCLINE4:CurrentText)
self:Server:Commit()
// Line 5
self:Server:FIELDPUT(#ITEM5, self:oDCComboBoxEx5:CurrentItem)
self:Server:FIELDPUT(#TAXTYPE5, iif(IsNil(self:oDCComboBoxEx15:VALUE), "", self:oDCComboBoxEx15:VALUE))
self:Server:FIELDPUT(#ACC5, self:oDCComboBoxEx25:CurrentItem)
self:Server:FIELDPUT(#UNITPR5, self:oDCUNITPR5:VALUE)
self:Server:FIELDPUT(#QTY5, self:oDCQTY5:VALUE)
self:Server:FIELDPUT(#GST5, self:oDCSingleLineEdit41:VALUE)
self:Server:FIELDPUT(#TOTPR5, self:oDCTOTPR5:VALUE)
self:Server:FIELDPUT(#LINE5, self:oDCLINE5:CurrentText)
self:Server:Commit()
// Line 6
self:Server:FIELDPUT(#ITEM6, self:oDCComboBoxEx6:CurrentItem)
self:Server:FIELDPUT(#TAXTYPE6, iif(IsNil(self:oDCComboBoxEx16:VALUE), "", self:oDCComboBoxEx16:VALUE))
self:Server:FIELDPUT(#ACC6, self:oDCComboBoxEx26:CurrentItem)
self:Server:FIELDPUT(#UNITPR6, self:oDCUNITPR6:VALUE)
self:Server:FIELDPUT(#QTY6, self:oDCQTY6:VALUE)
self:Server:FIELDPUT(#GST6, self:oDCSingleLineEdit42:VALUE)
self:Server:FIELDPUT(#TOTPR6, self:oDCTOTPR6:VALUE)
self:Server:FIELDPUT(#LINE6, self:oDCLINE6:CurrentText)
self:Server:Commit()
// Line 7
self:Server:FIELDPUT(#ITEM7, self:oDCComboBoxEx7:CurrentItem)
self:Server:FIELDPUT(#TAXTYPE7, iif(IsNil(self:oDCComboBoxEx17:VALUE), "", self:oDCComboBoxEx17:VALUE))
self:Server:FIELDPUT(#ACC7, self:oDCComboBoxEx27:CurrentItem)
self:Server:FIELDPUT(#UNITPR7, self:oDCUNITPR7:VALUE)
self:Server:FIELDPUT(#QTY7, self:oDCQTY7:VALUE)
self:Server:FIELDPUT(#GST7, self:oDCSingleLineEdit43:VALUE)
self:Server:FIELDPUT(#TOTPR7, self:oDCTOTPR7:VALUE)
self:Server:FIELDPUT(#LINE7, self:oDCLINE7:CurrentText)
self:Server:Commit()
// Line 8
self:Server:FIELDPUT(#ITEM8, self:oDCComboBoxEx8:CurrentItem)
self:Server:FIELDPUT(#TAXTYPE8, iif(IsNil(self:oDCComboBoxEx18:VALUE), "", self:oDCComboBoxEx18:VALUE))
self:Server:FIELDPUT(#ACC8, self:oDCComboBoxEx28:CurrentItem)
self:Server:FIELDPUT(#UNITPR8, self:oDCUNITPR8:VALUE)
self:Server:FIELDPUT(#QTY8, self:oDCQTY8:VALUE)
self:Server:FIELDPUT(#GST8, self:oDCSingleLineEdit44:VALUE)
self:Server:FIELDPUT(#TOTPR8, self:oDCTOTPR8:VALUE)
self:Server:FIELDPUT(#LINE8, self:oDCLINE8:CurrentText)
self:Server:Commit()
// Line 9
self:Server:FIELDPUT(#ITEM9, self:oDCComboBoxEx9:CurrentItem)
self:Server:FIELDPUT(#TAXTYPE9, iif(IsNil(self:oDCComboBoxEx19:VALUE), "", self:oDCComboBoxEx19:VALUE))
self:Server:FIELDPUT(#ACC9, self:oDCComboBoxEx29:CurrentItem)
self:Server:FIELDPUT(#UNITPR9, self:oDCUNITPR9:VALUE)
self:Server:FIELDPUT(#QTY9, self:oDCQTY9:VALUE)
self:Server:FIELDPUT(#GST9, self:oDCSingleLineEdit45:VALUE)
self:Server:FIELDPUT(#TOTPR9, self:oDCTOTPR9:VALUE)
self:Server:FIELDPUT(#LINE9, self:oDCLINE9:CurrentText)
// Line 10
self:Server:FIELDPUT(#ITEM10, self:oDCComboBoxEx10:CurrentItem)
self:Server:FIELDPUT(#TAXTYPE10, iif(IsNil(self:oDCComboBoxEx20:VALUE), "", self:oDCComboBoxEx20:VALUE))
self:Server:FIELDPUT(#ACC10, self:oDCComboBoxEx30:CurrentItem)
self:Server:FIELDPUT(#UNITPR10, self:oDCUNITPR10:VALUE)
self:Server:FIELDPUT(#QTY10, self:oDCQTY10:VALUE)
self:Server:FIELDPUT(#GST10, self:oDCSingleLineEdit46:VALUE)
self:Server:FIELDPUT(#TOTPR10, self:oDCTOTPR10:VALUE)
self:Server:FIELDPUT(#LINE10, self:oDCLINE10:CurrentText)
self:Server:Commit()
cWorkDir := WorkDir() + "Invoices"
self:Server:Seek(nInv)
cFileName := ""
cFileName := cWorkDir + "Invoice "+ PadL(AllTrim(self:Server:FIELDGET(#INVNO)), 8, "0") + " from " + ProperA(AllTrim(gCompanyName)) + ".pdf"
cFileName := "'" + cFileName + "'"
cMessage := "Please Wait..."
cCaption := "Test"
oReport := RpReport{self, "LAINVOICE.RPT"}
oReport:SeekExpression := AllTrim(nInv)
oReport:SetVariableValue("gInvNo", AllTrim(nInv) )
oReport:SetVariableValue("gAdd1", gAdd1)
oReport:SetVariableValue("gAdd2", gAdd2)
oReport:SetVariableValue("gABN", StrTran(gABN, "-", " "))
oReport:SetVariableValue("gSuburb", gSuburb)
oReport:SetVariableValue("gState", gState)
oReport:SetVariableValue("gPCode", gPCode)
oReport:SetVariableValue("gEmail", gEmail)
oReport:SetVariableValue("gTermDays", gTermDays)
oReport:SetVariableValue("gEOMPlusDay", gEOMPlusDay)
oReport:SetVariableValue("cPhone", "Phone: " + AllTrim(gPhone))
oReport:SetVariableValue("cEmail", "Email: " + AllTrim(gEmail))
cStr := "Date Due: " + iif( gTermDays > 0, DToC(Today()+gTermDays), DToC(FT_LDay(Today()) + gEOMPlusDay))
oReport:SetVariableValue("gEOMStr", cStr)
oReport:PrintExport(cCaption ,cMessage, #RP_PDF, cFileName)
? "cCaption = " + cCaption
? "cMessage = " + cMessage
? "cFileName = " + cFileName
oReport:Close()
self:EndWindow()
RETURN nil
In the screenshot above, I've tried the file name (cFileName) with and without the ' at either end. No difference.
Any ideas please?
METHOD OKButton( ) CLASS EditInvoice
Local oReport as RpReport
Local cFileName, cWorkDir,cMessage, cStr as String
Local nInv, cCaption
nInv := self:Server:FIELDGET(#INVNO)
If gTermDays == 0
gDueDate := FT_LDay(Today())
else
gDueDate := Today() + gTermDays
end if
// Bill To fields
self:Server:FIELDPUT(#MAILADD1, AllTrim(self:oDCMAILADD1:CurrentText))
self:Server:FIELDPUT(#MAILADD2, AllTrim(self:oDCMAILADD2:CurrentText))
self:Server:FIELDPUT(#MAILSUBURB, AllTrim(self:oDCMAILSUBURB:CurrentText))
self:Server:FIELDPUT(#MAILPCODE, AllTrim(self:oDCMAILPCODE:CurrentText))
self:Server:FIELDPUT(#MAILSTATE, AllTrim(self:oDCMAILSTATE:CurrentText))
self:Server:FIELDPUT(#CLNAME, AllTrim(self:oDCCLNAME:CurrentText))
self:Server:FIELDPUT(#INVDATE, self:oDCInvDateDTP:SelectedDate)
self:Server:FIELDPUT(#INVDUE, self:oDCDateTimePicker1:SelectedDate)
self:Server:FIELDPUT(#CLIENTREF, self:oDCCLIENTREF:CurrentText)
// Line 1
self:Server:FIELDPUT(#ITEM1, AllTrim(self:oDCComboBoxEx1:CurrentItem))
self:Server:FIELDPUT(#TAXTYPE1, iif(IsNil(self:oDCComboBoxEx11:VALUE), "", self:oDCComboBoxEx11:VALUE))
self:Server:FIELDPUT(#ACC1, AllTrim(self:oDCComboBoxEx21:CurrentItem))
self:Server:FIELDPUT(#UNITPR1, self:oDCUNITPR1:VALUE)
self:Server:FIELDPUT(#QTY1, self:oDCQTY1:VALUE)
self:Server:FIELDPUT(#GST1, self:oDCSingleLineEdit37:VALUE)
self:Server:FIELDPUT(#TOTPR1, self:oDCTOTPR1:VALUE)
self:Server:FIELDPUT(#LINE1, self:oDCLINE1:CurrentText)
self:Server:Commit()
// Line 2
self:Server:FIELDPUT(#ITEM2, self:oDCComboBoxEx2:CurrentItem)
self:Server:FIELDPUT(#TAXTYPE2, iif(IsNil(self:oDCComboBoxEx12:VALUE), "", self:oDCComboBoxEx12:VALUE))
self:Server:FIELDPUT(#ACC2, self:oDCComboBoxEx22:CurrentItem)
self:Server:FIELDPUT(#UNITPR2, self:oDCUNITPR2:VALUE)
self:Server:FIELDPUT(#QTY2, self:oDCQTY2:VALUE)
self:Server:FIELDPUT(#GST2, self:oDCSingleLineEdit38:VALUE)
self:Server:FIELDPUT(#TOTPR2, self:oDCTOTPR2:VALUE)
self:Server:FIELDPUT(#LINE2, self:oDCLINE2:CurrentText)
self:Server:Commit()
// Line 3
self:Server:FIELDPUT(#ITEM3, self:oDCComboBoxEx3:CurrentItem)
self:Server:FIELDPUT(#TAXTYPE3, iif(IsNil(self:oDCComboBoxEx13:VALUE), "", self:oDCComboBoxEx13:VALUE))
self:Server:FIELDPUT(#ACC3, self:oDCComboBoxEx23:CurrentItem)
self:Server:FIELDPUT(#UNITPR3, self:oDCUNITPR3:VALUE)
self:Server:FIELDPUT(#QTY3, self:oDCQTY3:VALUE)
self:Server:FIELDPUT(#GST3, self:oDCSingleLineEdit39:VALUE)
self:Server:FIELDPUT(#TOTPR3, self:oDCTOTPR3:VALUE)
self:Server:FIELDPUT(#LINE3, self:oDCLINE3:CurrentText)
self:Server:Commit()
// Line 4
self:Server:FIELDPUT(#ITEM4, self:oDCComboBoxEx4:CurrentItem)
self:Server:FIELDPUT(#TAXTYPE4, iif(IsNil(self:oDCComboBoxEx14:VALUE), "", self:oDCComboBoxEx14:VALUE))
self:Server:FIELDPUT(#ACC4, self:oDCComboBoxEx24:CurrentItem)
self:Server:FIELDPUT(#UNITPR4, self:oDCUNITPR4:VALUE)
self:Server:FIELDPUT(#QTY4, self:oDCQTY4:VALUE)
self:Server:FIELDPUT(#GST4, self:oDCSingleLineEdit40:VALUE)
self:Server:FIELDPUT(#TOTPR4, self:oDCTOTPR4:VALUE)
self:Server:FIELDPUT(#LINE4, self:oDCLINE4:CurrentText)
self:Server:Commit()
// Line 5
self:Server:FIELDPUT(#ITEM5, self:oDCComboBoxEx5:CurrentItem)
self:Server:FIELDPUT(#TAXTYPE5, iif(IsNil(self:oDCComboBoxEx15:VALUE), "", self:oDCComboBoxEx15:VALUE))
self:Server:FIELDPUT(#ACC5, self:oDCComboBoxEx25:CurrentItem)
self:Server:FIELDPUT(#UNITPR5, self:oDCUNITPR5:VALUE)
self:Server:FIELDPUT(#QTY5, self:oDCQTY5:VALUE)
self:Server:FIELDPUT(#GST5, self:oDCSingleLineEdit41:VALUE)
self:Server:FIELDPUT(#TOTPR5, self:oDCTOTPR5:VALUE)
self:Server:FIELDPUT(#LINE5, self:oDCLINE5:CurrentText)
self:Server:Commit()
// Line 6
self:Server:FIELDPUT(#ITEM6, self:oDCComboBoxEx6:CurrentItem)
self:Server:FIELDPUT(#TAXTYPE6, iif(IsNil(self:oDCComboBoxEx16:VALUE), "", self:oDCComboBoxEx16:VALUE))
self:Server:FIELDPUT(#ACC6, self:oDCComboBoxEx26:CurrentItem)
self:Server:FIELDPUT(#UNITPR6, self:oDCUNITPR6:VALUE)
self:Server:FIELDPUT(#QTY6, self:oDCQTY6:VALUE)
self:Server:FIELDPUT(#GST6, self:oDCSingleLineEdit42:VALUE)
self:Server:FIELDPUT(#TOTPR6, self:oDCTOTPR6:VALUE)
self:Server:FIELDPUT(#LINE6, self:oDCLINE6:CurrentText)
self:Server:Commit()
// Line 7
self:Server:FIELDPUT(#ITEM7, self:oDCComboBoxEx7:CurrentItem)
self:Server:FIELDPUT(#TAXTYPE7, iif(IsNil(self:oDCComboBoxEx17:VALUE), "", self:oDCComboBoxEx17:VALUE))
self:Server:FIELDPUT(#ACC7, self:oDCComboBoxEx27:CurrentItem)
self:Server:FIELDPUT(#UNITPR7, self:oDCUNITPR7:VALUE)
self:Server:FIELDPUT(#QTY7, self:oDCQTY7:VALUE)
self:Server:FIELDPUT(#GST7, self:oDCSingleLineEdit43:VALUE)
self:Server:FIELDPUT(#TOTPR7, self:oDCTOTPR7:VALUE)
self:Server:FIELDPUT(#LINE7, self:oDCLINE7:CurrentText)
self:Server:Commit()
// Line 8
self:Server:FIELDPUT(#ITEM8, self:oDCComboBoxEx8:CurrentItem)
self:Server:FIELDPUT(#TAXTYPE8, iif(IsNil(self:oDCComboBoxEx18:VALUE), "", self:oDCComboBoxEx18:VALUE))
self:Server:FIELDPUT(#ACC8, self:oDCComboBoxEx28:CurrentItem)
self:Server:FIELDPUT(#UNITPR8, self:oDCUNITPR8:VALUE)
self:Server:FIELDPUT(#QTY8, self:oDCQTY8:VALUE)
self:Server:FIELDPUT(#GST8, self:oDCSingleLineEdit44:VALUE)
self:Server:FIELDPUT(#TOTPR8, self:oDCTOTPR8:VALUE)
self:Server:FIELDPUT(#LINE8, self:oDCLINE8:CurrentText)
self:Server:Commit()
// Line 9
self:Server:FIELDPUT(#ITEM9, self:oDCComboBoxEx9:CurrentItem)
self:Server:FIELDPUT(#TAXTYPE9, iif(IsNil(self:oDCComboBoxEx19:VALUE), "", self:oDCComboBoxEx19:VALUE))
self:Server:FIELDPUT(#ACC9, self:oDCComboBoxEx29:CurrentItem)
self:Server:FIELDPUT(#UNITPR9, self:oDCUNITPR9:VALUE)
self:Server:FIELDPUT(#QTY9, self:oDCQTY9:VALUE)
self:Server:FIELDPUT(#GST9, self:oDCSingleLineEdit45:VALUE)
self:Server:FIELDPUT(#TOTPR9, self:oDCTOTPR9:VALUE)
self:Server:FIELDPUT(#LINE9, self:oDCLINE9:CurrentText)
// Line 10
self:Server:FIELDPUT(#ITEM10, self:oDCComboBoxEx10:CurrentItem)
self:Server:FIELDPUT(#TAXTYPE10, iif(IsNil(self:oDCComboBoxEx20:VALUE), "", self:oDCComboBoxEx20:VALUE))
self:Server:FIELDPUT(#ACC10, self:oDCComboBoxEx30:CurrentItem)
self:Server:FIELDPUT(#UNITPR10, self:oDCUNITPR10:VALUE)
self:Server:FIELDPUT(#QTY10, self:oDCQTY10:VALUE)
self:Server:FIELDPUT(#GST10, self:oDCSingleLineEdit46:VALUE)
self:Server:FIELDPUT(#TOTPR10, self:oDCTOTPR10:VALUE)
self:Server:FIELDPUT(#LINE10, self:oDCLINE10:CurrentText)
self:Server:Commit()
cWorkDir := WorkDir() + "Invoices"
self:Server:Seek(nInv)
cFileName := ""
cFileName := cWorkDir + "Invoice "+ PadL(AllTrim(self:Server:FIELDGET(#INVNO)), 8, "0") + " from " + ProperA(AllTrim(gCompanyName)) + ".pdf"
cFileName := "'" + cFileName + "'"
cMessage := "Please Wait..."
cCaption := "Test"
oReport := RpReport{self, "LAINVOICE.RPT"}
oReport:SeekExpression := AllTrim(nInv)
oReport:SetVariableValue("gInvNo", AllTrim(nInv) )
oReport:SetVariableValue("gAdd1", gAdd1)
oReport:SetVariableValue("gAdd2", gAdd2)
oReport:SetVariableValue("gABN", StrTran(gABN, "-", " "))
oReport:SetVariableValue("gSuburb", gSuburb)
oReport:SetVariableValue("gState", gState)
oReport:SetVariableValue("gPCode", gPCode)
oReport:SetVariableValue("gEmail", gEmail)
oReport:SetVariableValue("gTermDays", gTermDays)
oReport:SetVariableValue("gEOMPlusDay", gEOMPlusDay)
oReport:SetVariableValue("cPhone", "Phone: " + AllTrim(gPhone))
oReport:SetVariableValue("cEmail", "Email: " + AllTrim(gEmail))
cStr := "Date Due: " + iif( gTermDays > 0, DToC(Today()+gTermDays), DToC(FT_LDay(Today()) + gEOMPlusDay))
oReport:SetVariableValue("gEOMStr", cStr)
oReport:PrintExport(cCaption ,cMessage, #RP_PDF, cFileName)
? "cCaption = " + cCaption
? "cMessage = " + cMessage
? "cFileName = " + cFileName
oReport:Close()
self:EndWindow()
RETURN nil
In the screenshot above, I've tried the file name (cFileName) with and without the ' at either end. No difference.
Any ideas please?