When I run this code I get an 'Unhandled Memory Exception' Error. But the pdfdocument.bmx in the samples folder runs fine. I just can't get my head around this :-(
Thanx for any help!
SuperStrict Import wx.wxPdfDocument Import wx.wxApp Import brl.filesystem Extern "win32" 'Function WinExec(lpCmdLine$z, nCmdShow) Function ShellExecuteA(hwnd:Int, op:Byte Ptr, file:Byte Ptr, param:Byte Ptr, dir:Byte Ptr, show:Int) End Extern ' run the test test() Function test() Local doc:wxPdfDocument = New wxPdfDocument.Create() doc.AddPage() doc.SetFont("Arial", "B", 24) doc.Cell(0, 20, "Testing Image drawing", 0, 0, wxPDF_ALIGN_CENTER) ' image width Local w:Double = 25 ' image file name Local sImg:String = "apple.gif" ' draw a testing rectangle - this works 'doc.Rect((doc.GetPageWidth() - w) / 2, doc.GetY() + 20, w, w) ' check if the file exists If Not FileExists(sImg) DebugLog "Can't find image file: " + sImg Else ' draw an image which is located in the same folder as this testing file ' this produces a 'Unhandled Memory Exception Error' in wxPDFdocument.bmx doc.Image(sImg, (doc.GetPageWidth() - w) / 2, doc.GetY() + 20, w) End If ' save the pdf file Local fn:String = "image-test.pdf" doc.SaveAsFile(fn) ' open the pdf file with the default reader ShellExecuteA(0, "open", "~q" + fn + "~q", "", Null, 1) End Function Function FileExists:Int(fn:String) If FileType(fn) = 1 Return True Return False End Function
Thanx for any help!