Pretty printing library

agraham

Expert
Licensed User
Longtime User
Does there exist a horizonzal scrollbar, for example if there is an image in the file wider than the RichTextBox.Width ?
Yes. There is a ScrollBars property which defaults to Both. However it works in conjunction with a WordWrap property whose default is true which suppresses the horizontal scrollbar. You could get at these with the Door library but as I am messing with the source to get a dummy library I'll include these in a new version so you can play with them.
 

agraham

Expert
Licensed User
Longtime User
Version 1.7 with a dummy library for the device posted in first post. The device library uses a multiline Textboax as a placeholder for the RichTextBox and some of the common control properties work like Top, Left, Scrollbars etc. Most of the other properties are dummies. Let me know of any problems.
 

Georg

Member
Licensed User
Longtime User
RTF Table

Hi,

is there also a chance to addtext a Table? It would be great.
 

Georg

Member
Licensed User
Longtime User
Tables in RTF

Hi,

I know anthing about the RTF code, but how can i put the code in the RTF
that doesn't work

s = rtb.Rtf & "\trowd\trgaph70\\trleft-108\trbrdrt\brdrs\brdrw10 \trbrdrl\brdrs\brdrw10 \trbrdrb\brdrs\brdrw10 \trbrdrr\brdrs\brdrw10 \clbrdrt\brdrw15\brdrs\clbrdrl\brdrw15\brdrs\clbrdrb\brdrw15\brdrs\clbrdrr\brdrw15\brdrs \cellx1982\clbrdrt\brdrw15\brdrs\clbrdrl\brdrw15\brdrs\clbrdrb\brdrw15\brdrs\clbrdrr\brdrw15\brdrs \cellx3311\pard\intbl\b Das ist die Tabelle\cell Erste Zeile\cell\row\intbl Spalte1\cell Spalte 2\cell\row\pard\b0\"

rtb.Rtf = rtb.Rtf & s

was only an idea sorry.

is there an other way?
 

agraham

Expert
Licensed User
Longtime User
s = rtb.Rtf & "\trowd\trgaph70\\trleft-108\trbrdrt\brdrs\brdrw10 \trbrdrl\brdrs\brdrw10 \trbrdrb\brdrs\brdrw10 \trbrdrr\brdrs\brdrw10 \clbrdrt\brdrw15\brdrs\clbrdrl\brdrw15\brdrs\clbrdrb\brdrw15\brdrs\clbrdrr\brdrw15\brdrs \cellx1982\clbrdrt\brdrw15\brdrs\clbrdrl\brdrw15\brdrs\clbrdrb\brdrw15\brdrs\clbrdrr\brdrw15\brdrs \cellx3311\pard\intbl\b Das ist die Tabelle\cell Erste Zeile\cell\row\intbl Spalte1\cell Spalte 2\cell\row\pard\b0\"

rtb.Rtf = rtb.Rtf & s
One of those rtb.Rtf references is not needed!. If that doesn't work I don't know of another way, that is what I would have tried.
 

agraham

Expert
Licensed User
Longtime User
I hadn't seen that before. I have downloaded and looked at the source and the main thing it does is implement a serial port as the SerialPort class was not available in .NET when that was written.

The printing side is very trivial and just sends a stream of characters to the serial port with no formatting at all. The printer is assumed to be a very simple fixed font ASCII printer.

The whole library does little more that you can do by sending strings to the Serial library in Basic4ppc and hoping there is a printer on the other end so I am afraid I don't think it does anything to help.
 

JOTHA

Well-Known Member
Licensed User
Longtime User
Print lines?

Hi agraham,

you did a very nice job and I think it was a lot of work! :sign0188:

Thank you for sharing your DLL.
On the desktop it works very good.

I know, that is not possible to print tables (I have seen this question in this thread), but is it possible to print "lines"?

In another IDE it was possible with:
B4X:
PrinterCE.DrawWidth = 0.025
PrinterCE.DrawLine 10, 5.4, 18.5, 5.4

Maybe there is a solution?
 

JOTHA

Well-Known Member
Licensed User
Longtime User
Hi agraham,

thank you for your fast reply.

Sorry but you cannot do any graphics drawing with it, only print text and pictures.

My idea was to "simulate" a table with drawing lines around the text ...

O.K. - this shouldn´t be.

Anyway, you did a great job! :)

Do you think (in the future) it will be possible to make printouts via Pocket-PC and mobile printers (Bluetooth, WLAN, etc.)? :confused:
 

agraham

Expert
Licensed User
Longtime User
Do you think (in the future) it will be possible to make printouts via Pocket-PC and mobile printers (Bluetooth, WLAN, etc.)? :confused:
Not easily unless you can find a Bluetooth printer that presents itself as a serial Port when you could use the Serial2 or SerialEx libraries to talk to it. There appears to be be no provision in Windows Mobile for printing (although I guess this could change in the future) so I think each printer needs a custom driver and apps that want to use the printer need to understand how to access this driver.

I don't know a lot about this so if anyone has an idea of how printing could be implemented I'd be happy to learn about it.
 

JOTHA

Well-Known Member
Licensed User
Longtime User
different Alignments in the same line?

Hi agraham,

I tried to have in one line different alignments with this code:
B4X:
rtb.FontSize = 12
rtb.AddText("Firma"&Tab &Tab &Tab &Tab)
rtb.AddText("Telefon:")
rtb.Alignment = 1 'right
rtb.AddText("07171 - XX XX")
... but it didn´t work.

The result should be like that:

Firma​
Telefon:​
07171 - XX XX​

"Firma" should be align left​
07171 - XX XX should be align right​

Is this possible in another way?

Thank you in advance!
 
Last edited:

JOTHA

Well-Known Member
Licensed User
Longtime User
Hi agraham,
... you will just have to play with the options and see what works and what doesn't.
I "played" with your DLL and made a lot of experiments. Here are some results:

1) It is not possible to have different alignments in one line. If someone tries to have different alignments, the "last" command will be performed for the whole line.

2) Because it is not possible to have a table in the printout, I made a model which looks like a table (if someone wants to use it):
B4X:
'------------------------------------------------------
'Tabelle für den Ankauf
   rtb.FontSize =12
   rtb.Underline = True
   rtb.BackColor = Rgb (192,192,192)
   rtb.AddText("| Nr." &Tab &"| Gewicht" &Tab &Tab &"| Karat" &Tab &"| Gegenstand" &Tab &Tab &Tab &"| Euro                                                          " &CRLF)
   rtb.Underline = False
'------------------------------------------------------
'Nr. 1
    rtb.Underline = True
   If mZusammenfassung.lvTabelle.CellGet("Euro", 0) <> "0,00" Then
   rtb.AddText ("| "&mZusammenfassung.lvTabelle.CellGet("Nr", 0)&"" &Tab)
    End If
'Gewicht 1
   If mZusammenfassung.lvTabelle.CellGet("Euro", 0) <> "0,00" Then
   rtb.AddText ("| "&mZusammenfassung.lvTabelle.CellGet("Gewicht", 0)&" gr" &Tab &Tab)
    End If
'Karat 1
   If mZusammenfassung.lvTabelle.CellGet("Euro", 0) <> "0,00" Then
   rtb.AddText ("| "&mZusammenfassung.lvTabelle.CellGet("Karat", 0)&" ct" &Tab)
    End If
'Gegenstand 1
   If mZusammenfassung.lvTabelle.CellGet("Euro", 0) <> "0,00" Then
   rtb.AddText ("| "&mZusammenfassung.lvTabelle.CellGet("Nr", 0)&" Gegenstand" &Tab &Tab)
    End If
'Euro 1
   If mZusammenfassung.lvTabelle.CellGet("Euro", 0) <> "0,00" Then
   rtb.AddText ("| "&mZusammenfassung.lvTabelle.CellGet("Euro", 0)&" €                                                                                       "&CRLF)
    End If
'------------------------------------------------------
'Nr. 2
   If mZusammenfassung.lvTabelle.CellGet("Euro", 1) <> "0,00" Then
   rtb.AddText ("| "&mZusammenfassung.lvTabelle.CellGet("Nr", 1)&"" &Tab)
    End If
'Gewicht 2
   If mZusammenfassung.lvTabelle.CellGet("Euro", 1) <> "0,00" Then
   rtb.AddText ("| "&mZusammenfassung.lvTabelle.CellGet("Gewicht", 1)&" gr" &Tab &Tab)
    End If
'Karat 2
   If mZusammenfassung.lvTabelle.CellGet("Euro", 1) <> "0,00" Then
   rtb.AddText ("| "&mZusammenfassung.lvTabelle.CellGet("Karat", 1)&" ct" &Tab)
    End If
'Gegenstand 2
   If mZusammenfassung.lvTabelle.CellGet("Euro", 1) <> "0,00" Then
   rtb.AddText ("| "&mZusammenfassung.lvTabelle.CellGet("Nr", 1)&" Gegenstand" &Tab &Tab)
    End If
'Euro 2
   If mZusammenfassung.lvTabelle.CellGet("Euro", 1) <> "0,00" Then
   rtb.AddText ("| "&mZusammenfassung.lvTabelle.CellGet("Euro", 1)&" €                                                          "&CRLF)
    End If
'------------------------------------------------------
.
.
... and so on ...
The data comes out of a Table. I used a "ListView-Table", if you want to use a normal Table you have not to write ".CellGet" - instead you have to write ".Cell".

If someone has questions about the "simulated Table" please post them.

Thank you agraham for your help and your DLL. :)
 
Top