B4J Question Jfx8print webview with arabic letters

le_toubib

Active Member
Licensed User
Longtime User
Hi all , I'm trying to print a webview to Microsoft print to pdf using built in jfx8print, and it works fine except that the arabic letters are printed in reverse ??? the html file shows normally on browser and also print to pdf normally from browser ... this also happens with HP printer , arabic letters reversed if printed with jfx8print ..
p.s : same file is printed normally using printhtml.exe .... example :
HTML:
<HTML>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<META HTTP-EQUIV="Content-language" CONTENT="ar">
<BODY>
    <style Type="text/css" media="print"> @media screen, print
{ .box{ border:1pt solid transparent;  border-radius:20px;  position:absolute;  top:0; width:19.3cm;  height:28.2cm; }
section{position:relative;} .hr { background-color: white; height: 1px; border: 0;}}</style>
<div class='box'><br>   <h1><div dir="rtl" ></div><span style="text-decoration: underline; text-align: right">نص عربي</span></div></h1>
this shows : يبرع صن
is there a way to fix that?
 
Last edited:

MegatenFreak

Active Member
Licensed User
Hi.
1. The first thing I'd like to mention is this: when you attempt to print the contents, choose "A4" as the output format. In my case, when I chose other formats, the title's letters printed backwards (I use Farsi text, but it's the same concept!) See if that works.
2. I use the following method to print the contents of a webview. See how this one works:

B4X:
Sub PrintWebView(w As WebView)
    Dim PJ As PrinterJob = PrinterJob_Static.CreatePrinterJob
    PJ.ShowPageSetupDialog(Null)
    PJ.ShowPrintDialog(Null)
    Dim WVJO As JavaObject = w
    WVJO.RunMethodJO("getEngine",Null).RunMethod("print",Array(PJ.GetObject))
    PJ.EndJob
End Sub
 
Upvote 0

le_toubib

Active Member
Licensed User
Longtime User
Thank you for your reply , I appreciate ur help
I m using the exact same method , with A4 portrait pagelayout , but the results differs from printer to printer , arabic letters sometimes reversed , sometimes not ..
Incidentally , how do u shrink contents to fit A4 sized webview ???
Thanks again
 
Upvote 0

MegatenFreak

Active Member
Licensed User
I know, it's annoying how right-to-left language output is sometimes messed up like that for no logical reason.
When I load my own html (usually tables of data) into the webview, it fits the page automatically.
But when there is an image I need printed, I use the node's Snapshot:

B4X:
Dim str As String = "<html><head></head><body><img src=""" & File.GetUri(File.DirApp, "/temp/chart.png") & """></body></html>"
Dim w As WebView
w.Initialize("")
w.LoadHtml(str)
PrintWebView(w)

So far I haven't had scaling problems, but to make things more convenient, I've also added the option to open the created HTML with Microsoft Word, so my clients can print it from there. That way they can make any adjustments they want.
I hope you find a way to fix it.
 
Upvote 0
Top