B4J Question PDFJet - Problem

BeneBarros

Active Member
Licensed User
Longtime User
I have a problem with PDFJet.
put an image in the Column (0) and a text in the Column (2)
Column (2) has fixed width.
When I run "PDFTable.WrapAroundCellText" it generates images in Column (0) in the amount of lines created in column (2).

Annex example.

I have to fix this ???
 

Attachments

  • Test.jpg
    Test.jpg
    136.3 KB · Views: 179
  • TableTest.zip
    10.5 KB · Views: 166

Phayao

Active Member
Licensed User
Longtime User
Same problem here - but no answer from the forum about this.
My workaround is to put each picture in a separate row under the text. Not perfect but better than nothing.
If anyone has a better idea, I will appreciate also.
Thank you,

Chris
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
It seems when you have long text it splits the text and creates extra rows in the table.
I have it adding just one tick box per row, but it depends on knowing that (in your example) it creates 4 lines for the text.
I couldn't find a routine to tell how many lines it creates.
This was the relevant code I changed ( I added the image directly to the PDFTable)
B4X:
    txt = "A alface é uma das hortaliças mais comercializadas no Brasil. Produzida durante todo o ano, no campo ou em estufas, " & _
        "seu cultivo é prejudicado quando não é plantada a temperaturas apropriadas, com excesso de radiação solar, com chuvas prolongadas, " & _
        "que podem inibir seu crescimento e danificá-la. Para verificar o ambiente mais adequado de cultivo e As variedades mais indicadas"
      
    For R = 0 To 4
        Row.Initialize
        Dim PDFImage As PDFjetImage
        Dim Columns(3) As String
        Columns(0) = ""
        Columns(1) = Chr(R+65) & ")"
        Columns(2) = txt
        For c=0 To 2
            Column = Columns(c).Trim
            PDFCell.Initialize2(PDFFont1, Column)
            PDFCell.SetFgColor(PDFjetConstants1.Color.navy)
            Row.Add(PDFCell)
        Next
        TableData1.AddRow(Row)
'        Dim PDFImage As PDFjetImage
'        If R=1 Then
'            PDFImage.Initialize(PDFjetPDF1, File.OpenInput(File.DirTemp, "CkTrue.png"), PDFjetConstants1.ImageType.PNG)
'        Else
'            PDFImage.Initialize(PDFjetPDF1, File.OpenInput(File.DirTemp, "CkFalse.png"), PDFjetConstants1.ImageType.PNG)
'        End If
'        PDFImage.ScaleBy(0.25)
'        TableData1.GetRow(r).Get(0).SetImage(PDFImage)
    Next
    PDFTable.SetData(TableData1)
    PDFTable.SetCellBordersWidth(0.1)
    PDFTable.SetPosition(30, 100)
    PDFTable.AutoAdjustColumnWidths

    Dim wdt As Float = PDFTable.GetColumnWidth(0)
    wdt= wdt + PDFTable.GetColumnWidth(1)
    wdt = 260 - wdt
    PDFTable.SetColumnWidth(2,wdt)
    PDFTable.WrapAroundCellText
    For R = 0 To 4
        Dim PDFImage As PDFjetImage
        If R=1 Then
            PDFImage.Initialize(PDFjetPDF1, File.OpenInput(File.DirTemp, "CkTrue.png"), PDFjetConstants1.ImageType.PNG)
        Else
            PDFImage.Initialize(PDFjetPDF1, File.OpenInput(File.DirTemp, "CkFalse.png"), PDFjetConstants1.ImageType.PNG)
        End If
        PDFImage.ScaleBy(0.25)
        PDFTable.SetColumnWidth(0,PDFImage.GetWidth *1.5)
        PDFTable.GetRow(R*4).Get(0).SetImage(PDFImage)    ''' it's the * 4 part that gets it in right row
    Next
    PDFTable.DrawOn(PDFPage)
    DeleteTempFiles(ImageFiles)

    PDFjetPDF1.Close  
End Sub

Hope this gives you some help (not used PDFjet until this problem, so definitely not an expert on it)
 

Attachments

  • PDFjet.jpg
    PDFjet.jpg
    69.5 KB · Views: 174
Last edited:
Upvote 0
Top