B4J Question HTMLeditor print with colors

ThRuST

Well-Known Member
Licensed User
Longtime User
Hi! When sending the HTMLeditor content to a webview for printing the generated PDF doesn't have colors.
See the example PDF file.

I'm using this code
code:
WebView1.LoadHtml (HTMLeditor.HtmlText)
PrintWebView(WebView1)

print:
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

TestScript
script:
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
  border: 1px solid black;
  border-collapse: collapse;
}

th:nth-child(even),td:nth-child(even) {
  background-color: #D6EEEE;
}
</style>
</head>
<body>

<h2>Striped Table</h2>
<p>For zebra-striped tables, use the nth-child() selector and add a background-color to all even (or odd) table rows:</p>

<table style="width:100%">
  <tr>
    <th>MON</th>
    <th>TUE</th>
    <th>WED</th>
    <th>THU</th>
    <th>FRI</th>
    <th>SAT</th>
    <th>SUN</th>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
  </tr>
</table>

</body>
</html>

1658156748632.png


1658156695302.png



Original
1658156504141.png

Output
1658156463163.png


Solution?
 

Attachments

  • test2.pdf
    164.2 KB · Views: 194
Last edited:

ThRuST

Well-Known Member
Licensed User
Longtime User
@Erel Will do that. Noticed there's a bunch of drivers to choose from in vmWare workstation 16 when running in this case MacOS El capitan.
A virtual printer must be activated in preferences and also added to the virtual machine settings. Then turn on the real printer and add it through
USB in vmware and it will show up in MacOS system preferences/printers. There's many drivers to choose from so it has to be explored.
If anyone know of a good driver that solves the greyscale issue then please leave your comment.
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
btw I should test this using pictures and various colored fonts and save to a PDF. Might be related to tables only this has to be explored further.
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
After some investigations I want to share this discovery.
Makes me wonder if HTMLeditor control has a method to enable background colors for HTML content before it is sent to the printer?
Anyone?


1658401812038.png


Google Chrome/Settings/Print/more options/Background colors
1658402078089.png
 
Upvote 0
Top