B4A Library Printing and Pdf creation

Status
Not open for further replies.

JNG

Member
Licensed User
Hi!

I am try to use this library but unable to point out the problem
B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim pdf As PdfDocument
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Dim Htmlfile As String = GenerateHtml
    pdf.Initialize
    pdf.StartPage(595, 842) 'A4 size
    '    pdf.Canvas.DrawLine(2, 2, 593 , 840, Colors.Blue, 4)
    pdf.Canvas.DrawText(Htmlfile, 100, 100, Typeface.DEFAULT_BOLD, 30 / GetDeviceLayoutValues.Scale , Colors.Black, "CENTER")
    pdf.FinishPage
    Dim out As OutputStream = File.OpenOutput(File.DirRootExternal, "Test1.pdf", False)
    pdf.WriteToStream(out)
    out.Close
    pdf.Close
End Sub

Sub Activity_Resume
   
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub GenerateHtml
    Dim stylelayout As String  =  $ "table{width: 100%; border-color: #000000;     border = 1;}" _
& " caption { display: table-caption; height:50px; }" _
& " th {border-width: 1px;            border-color:      #000000;font-size:16px; height:40px;} " _
& " td {border-width: 1px;  border-color:      #000000;font-size:16px; height:40px; }" _
& " a { text-decoration:none; color: #000;}"$
Dim caption As String = "Testing PDF"
    Dim Hstr As String = $"
<tr>
<th></th>
<th>9am</th>
<th>10am</th>
<th>11am</th>
<th>12am</th>
</tr>
<tr>
<th>Monday</th>
<td colspan="2">Geography</td>
<td>Math</td>
<td>Art</td>
</tr>
<tr>
<td>Name</td>
<th colspan="2">Gym</th>
<th>Home Ec</th>
</tr>
<tr>
<th>Tuesday</th>
<td colspan="2">Value</td>
<td>Address Ec</td>
</tr>"$


    Dim HtmlStr As String =  $"<!DOCTYPE html>
    <html><meta charset="utf-8">
    <body>
    <style type='text/css'>${stylelayout}</style> _
           
            <caption>${caption}</caption>
            <table>
            ${Hstr}
       
            </table>
            <img src="smiley.gif" alt="Smiley face" height="42" width="42">
    </body>
    </html>"$
    Log(HtmlStr)
    Return(HtmlStr)
   
   
End Sub
. Code attached.

Pl let me know where I am going wrong

regards
jng
 

Mikel Huerta

Member
Licensed User
Excuse me @Erel, wish version of PDF library are you using ? i am using PDF library version 0.25 .. and , if not are the same , where can i found the newst one ?

Thanks you.
 

BarryW

Active Member
Licensed User
Longtime User
how to call this library?

 

JOTHA

Well-Known Member
Licensed User
Longtime User
Hi Erel,

great Lib! Thank you for your excellent work again!

Whats the advantage over PDFWriter?
 

SAMER ISSA

Member
Licensed User
Longtime User
Thank you for replay KMatle ...
but have you an example please !
I was work with DonManfred library (pdf.jar) it have wordwrap but without (Aligns type) like "CENTER" "RIGHT" "LEFT"
and (printing.jar) library have Aligns type but without wrap text
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…