Hello
This is the code that I have used to create a multi-page enriched pdf, with the BBCodeView1 and PDFjetPDF libraries
btnUpdate_Click
Try
BBCodeView1.LazyLoading=False
Dim Lineas_texto As String =File.ReadString(File.DirAssets,"declaración responsable del cliente en check_in (vf)_esp_txt.txt") & CRLF & CRLF & CRLF
TextArea1.Text=""
TextArea1.Text=Lineas_texto
AddViews(TextArea1.Text)
BBCodeView1.Text = TextArea1.Text
Dim imagen As B4XBitmap = BBCodeView1.ForegroundImageView.GetBitmap
Dim Out As OutputStream
Out = File.OpenOutput(File.DirApp, "pagina1.png", False)
imagen.WriteToStream(Out, 100, "PNG")
Out.Close
BBCodeView1.Views.Clear
BBCodeView1.LazyLoading=False
Dim Lineas_texto As String =File.ReadString(File.DirAssets,"bienvenido_restohoteles_esp_txt.txt") & CRLF & CRLF & CRLF
TextArea1.Text=""
TextArea1.Text=Lineas_texto
AddViews(TextArea1.Text)
BBCodeView1.Text = TextArea1.Text
Dim imagen1 As B4XBitmap = BBCodeView1.ForegroundImageView.GetBitmap
Dim Out As OutputStream
Out = File.OpenOutput(File.DirApp, "pagina2.png", False)
imagen1.WriteToStream(Out, 100, "PNG")
Out.Close
BBCodeView1.Views.Clear
BBCodeView1.LazyLoading=False
Dim Lineas_texto As String =File.ReadString(File.DirAssets,"policia_esp_txt.txt") & CRLF & CRLF & CRLF
TextArea1.Text=""
TextArea1.Text=Lineas_texto
AddViews(TextArea1.Text)
BBCodeView1.Text = TextArea1.Text
Dim imagen As B4XBitmap = BBCodeView1.ForegroundImageView.GetBitmap
Dim Out As OutputStream
Out = File.OpenOutput(File.DirApp, "Pagina3.png", False)
imagen.WriteToStream(Out, 100, "PNG")
Out.Close
' *************************** crear pdf
Dim PDFjetPDF1 As PDFjetPDF=CreateBasePDFDocument
Dim PDFPage As PDFjetPage
PDFPage.Initialize(PDFjetPDF1, PDFjetConstants1.PageSize.A4_PORTRAIT)
Dim PDFFont1 As PDFjetFont
PDFFont1.Initialize(PDFjetPDF1, PDFjetConstants1.CoreFont.HELVETICA)
Dim Image1 As PDFjetImage
Image1.Initialize(PDFjetPDF1, File.OpenInput(File.DirApp, "pagina1.png"), PDFjetConstants1.ImageType.PNG)
Image1.ScaleBy(0.6)
Dim Image2 As PDFjetImage
Image2.Initialize(PDFjetPDF1, File.OpenInput(File.DirApp, "pagina2.png"), PDFjetConstants1.ImageType.png)
Image2.ScaleBy(0.6)
Dim Image3 As PDFjetImage
Image3.Initialize(PDFjetPDF1, File.OpenInput(File.DirApp, "pagina3.png"), PDFjetConstants1.ImageType.png)
Image3.ScaleBy(0.6)
Image1.SetPosition(20, 20)
Image1.DrawOn(PDFPage)
Dim PDFPage2 As PDFjetPage
PDFPage2.Initialize(PDFjetPDF1, PDFjetConstants1.PageSize.A4_PORTRAIT)
Image2.SetPosition(20, 20)
Image2.DrawOn(PDFPage2)
Dim PDFPage3 As PDFjetPage
PDFPage3.Initialize(PDFjetPDF1, PDFjetConstants1.PageSize.A4_PORTRAIT)
Image3.SetPosition(20, 20)
Image3.DrawOn(PDFPage3)
PDFjetPDF1.Close
Catch
TextEngine.TagParser.ErrorString.Append(CRLF).Append(LastException.Message)
Log(LastException)
End Try
If TextEngine.TagParser.ErrorString.Length > 0 Then
xui.MsgboxAsync(TextEngine.TagParser.ErrorString, "Error")
End If
end sub
Sub CreateBasePDFDocument As PDFjetPDF
Dim PDFDestination As OutputStream
PDFDestination=File.OpenOutput(File.DirApp, "paginas.pdf", False)
PDFjetPDF1.Initialize("PDFjetPDF1", PDFDestination)
PDFjetPDF1.SetAuthor("Martin Pearman")
PDFjetPDF1.SetSubject("jPDFjet Examples")
'PDFjetPDF1.SetTitle(ExampleChooser.Value)
Return PDFjetPDF1
End Sub
Sub PDFjetPDF1_CloseComplete(Success As Boolean)
If Success Then
'JFX1.ShowExternalDocument(File.GetUri(LastSelectedDir, ExampleChooser.Value&".pdf"))
Else
Log("An error has occurred and creation of the PDF document has failed")
End If
End Sub