I have just started testing xojo for one of my case…
I have loader a html page into the htmlviewer control using loadurl
and calling the print method… it just show me oleexception.
Exception, (failed on “ExecWB”).
ole exception -2147352567
didnt find any help…
i tried loading via both file:/// and http://localhost method and also same issue…
if using try catch method , the error is suppressed but noting is happening
Did you print something (with other software) before this attempt (after booting this morning) ?
Did you try to print to pdf from the htmlviewer ?
Yes i printed with one note and chrome…
Did you try to print to pdf from the htmlviewer ?
No… i just tried htmlviewer1.loadurl(http://localhost/xxx.html) and the next line is htmlviewer1.print method. It is displaying html correctly but failing at print method
I added Me.PRINT in the DocumentComplete Event (macOS Monterey / Xojo 21r2.1) and I get the Print window. I was able to print to pdf (and since I do not have a printer availabe/selected/default), I cannot print (the button is grey).
Yes, I understand, you run Windows (but no Windows for me on M1 MacBook Pro nor one handly).
Have you read (see) that note:
Printing works only for content loaded from a file.
My test store an html file to disk, then load that into the HTMLViewer…
Nota: the background colors are not printed (bgcolor=yellow for example) / No “Print Background” CheckBox found in the Print Dialog.
For Windows I have:
Var ff as FolderItem, tmpof as TextOutputStream
ff = new FolderItem ("temp.html", FolderItem.PathModes.Native)
tmpof = TextOutputStream.Create (ff)
tmpof.Write (htmlStr)
tmpof.Close ()
PrintViewer.LoadPage (ff)
Then I have a button which just has PrinterViewer.Print ()
. You’ll need to figure out where you want the temp file to be created. The html in question is already in htmlStr
.
I don’t have a Windows system so I can’t tell if this works or not.
I used on my MacBook Pro M1 Monterey:
// Ask the user for the associated data folder location
Data_FI = Source_FI.Child(Source_FI.Name + " - Data")
If Data_FI = Nil Or Not Data_FI.Exists Then
MsgBox "Une erreur s’est produite" + EndOfLine + EndOfLine +_
"Problèmes avec la référence du dossier “images”."
Return
End If
// Renders the document
wRender.HTMLViewer1.grantAccessToFolder(Data_FI)
wRender.HTMLViewer1.LoadPage(TA.Text, Data_FI)
TA.Text holds a computed and valid html file.
Source_FI is a Reference of a Source Folder where the data is taken to create the html file (stored in another folder inside the Source Folder, suffixed " - Data").
This is independent from the print to (paper as asked or pdf as I tested).
What version of xojo are you using?
What version of Windows are you using?
Are you using any 3rd party plugins?