I would like an example on how to make labels with Dyna Pdf with the possibility of going to the next line if the word is too long

You could use DynaPDFTableMBS class to make a table and output it to a page. That would break automatically if a row is too long.

Or use WriteFtext or WriteStyledText methods in DynaPDFMBS class passing a rectangle and if with is reached, it will start a new line.
You can use -1 for height and then use GetLastTextPosY to query where the text ended and position the next text below it.

1 Like

I rarely use DynaPDF… could you kindly send me an example to create four labels on one line with the possibility that if a word in the label is longer than the width of the label it automatically goes to the next line?

Like this?

code is here:

Dim pdf As New MyDynaPDFMBS

dim i as integer = 0
dim pageCount as integer = 0
dim rowNum as integer = 0

call pdf.CreateNewPDF
call pdf.SetPageCoords(pdf.kpcTopDown)

Dim tbl As DynaPDFTableMBS = pdf.CreateTable(3, 4, 500.0, 100.0)
call tbl.SetBorderWidth(-1, -1, 1.0, 1.0, 1.0, 1.0)
call tbl.SetGridWidth( 1.0, 1.0)

// -1.0 means use the default row height as specified in the CreateTable() call.
rowNum = tbl.AddRow(-1.0)

Call tbl.SetCellText rowNum, 0, pdf.ktaLeft, tbl.kcoTop, "Hello1"
Call tbl.SetCellText rowNum, 1, pdf.ktaLeft, tbl.kcoTop, "Hello2"
Call tbl.SetCellText rowNum, 2, pdf.ktaLeft, tbl.kcoTop, "Hello3 Just a test here with a very long line"
Call tbl.SetCellText rowNum, 3, pdf.ktaLeft, tbl.kcoTop, "Hello4"

// Draw the table now
Call pdf.Append
Call tbl.DrawTable(50.0, 50.0, 742.0)
Call pdf.EndPage

// A table stores errors and warnings in the error log
dim err as DynaPDFErrorMBS

pageCount = pdf.GetErrLogMessageCount
for i = 0 to pageCount-1
  err = pdf.GetErrLogMessage(i)
  MsgBox err.Message

// No fatal error occurred?
if pdf.HaveOpenDoc then
  // We write the output file into the current directory.
  // OK, now we can open the output file.
  dim f as FolderItem = SpecialFolder.Desktop.Child("Table Text.pdf")
  if not pdf.OpenOutputFile(f) then
    MsgBox "Failed to open output file!"
  end if
  call pdf.CloseFile
end if

that makes a table with 4 cells and they wrap automatically if needed.


I just read your note, thank you very much