PC SOFT

PROFESSIONAL NEWSGROUPS
WINDEVWEBDEV and WINDEV Mobile

Home → WEBDEV 2024 → ERR_BAD_CONTEXT_INVALID
ERR_BAD_CONTEXT_INVALID
Started by Zach, Jun., 21 2013 8:16 PM - 3 replies
Posted on June, 21 2013 - 8:16 PM
I'm trying to print a pdf with the following code on a button click:
invoiceNum = ...
TABLE.COLUMN[TableSelect(TABLE,1)]
sFile = fWebDir() + "\" + DateSys() + TimeSys() + 1 + invoiceNum + ".pdf"
iDestination(iPDF, sFile)
iInitReportQuery(REPORT,invoiceNum)
iPrintReport(REPORT)

FileDisplay(sFile, "application/pdf", "Report " + invoiceNum + ".pdf")

It works for most items but generates a 54, ERR_BAD_CONTEXT_INVALID when I try to filedisplay the larger reports.
Posted on June, 22 2013 - 5:28 PM
Hi Zach

it MAY be that the report is not fully generated (external module doing
the work) at the time you do your filedisplay... Try to put a multitask
between the two, to check if that is the case....

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

New web site (EXPERIMENTAL) http://www.fabriceharari.eu
(More information on http://www.fabriceharari.com)


On 6/21/2013 12:16 PM, Zach wrote:
I'm trying to print a pdf with the following code on a button click:
invoiceNum = ...
TABLE.COLUMN[TableSelect(TABLE,1)]
sFile = fWebDir() + "\" + DateSys() + TimeSys() + 1 + invoiceNum +
".pdf" iDestination(iPDF, sFile)
iInitReportQuery(REPORT,invoiceNum)
iPrintReport(REPORT)

FileDisplay(sFile, "application/pdf", "Report " + invoiceNum + ".pdf")

It works for most items but generates a 54, ERR_BAD_CONTEXT_INVALID when
I try to filedisplay the larger reports.
Posted on June, 22 2013 - 5:51 PM
Is there any slight difference between your "normal" and "larger" reports ?
Posted on June, 24 2013 - 7:55 PM
you were right Fabrice, it was not fully generating the report.

The difference between smaller and larger reports was the smaller had 1 - 5 lines in the body and the larger had over 1000.
I narrowed down the cause in the report and it happened whenever there were enough lines to overflow into a second page. I fixed the problem by unselecting Breakable Block in the details of the block description.