Platforms to show: All Mac Windows Linux Cross-Platform
Required plugins for this example: MBS DynaPDF Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /DynaPDF/Tables/Table Text
This example is the version from Wed, 14th Sep 2021.
Project "Table Text.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
EventHandler Sub Open()
Run
quit
End EventHandler
Sub Run()
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, 3, 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)
dim text as string = "The cell alignment can be set for text, images, and templates..."
call tbl.SetCellText rowNum, 0, pdf.ktaLeft, tbl.kcoTop, text
call tbl.SetCellText rowNum, 1, pdf.ktaCenter, tbl.kcoTop, text
call tbl.SetCellText rowNum, 2, pdf.ktaRight, tbl.kcoTop, text
rowNum = tbl.AddRow(-1.0)
call tbl.SetCellText rowNum, 0, pdf.ktaLeft, tbl.kcoCenter, text
call tbl.SetCellText rowNum, 1, pdf.ktaCenter, tbl.kcoCenter, text
call tbl.SetCellText rowNum, 2, pdf.ktaRight, tbl.kcoCenter, text
rowNum = tbl.AddRow(-1.0)
call tbl.SetCellText rowNum, 0, pdf.ktaLeft, tbl.kcoBottom, text
call tbl.SetCellText rowNum, 1, pdf.ktaCenter, tbl.kcoBottom, text
call tbl.SetCellText rowNum, 2, pdf.ktaRight, tbl.kcoBottom, text
// Draw the table now
call pdf.Append
call tbl.DrawTable(50.0, 50.0, 742.0)
while tbl.HaveMore
call pdf.EndPage
call pdf.Append
call tbl.DrawTable(50.0, 50.0, 742.0)
wend
call pdf.EndPage
// Let's change the cell orientation to see what happens...
call tbl.SetCellOrientation(-1, -1, 90)
call pdf.Append
call pdf.SetFont("Arial", pdf.kfsRegular, 12.0, true, pdf.kcpUnicode)
call pdf.WriteText(50.0, 50.0, "The same table but the cell orientation was changed to 90 degrees.")
call tbl.DrawTable(50.0, 65.0, 742.0)
while tbl.HaveMore
call pdf.EndPage
call pdf.Append
call tbl.DrawTable(50.0, 50.0, 737.0)
wend
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
next
// 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
f.launch
end if
End Sub
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
Class MyDynaPDFMBS Inherits DynaPDFMBS
EventHandler Function Error(ErrorCode as integer, ErrorMessage as string, ErrorType as integer) As integer
// output all messages on the console:
System.DebugLog str(ErrorCode)+": "+ErrorMessage
// and display dialog:
Dim d as New MessageDialog //declare the MessageDialog object
Dim b as MessageDialogButton //for handling the result
d.icon=MessageDialog.GraphicCaution //display warning icon
d.ActionButton.Caption="Continue"
d.CancelButton.Visible=True //show the Cancel button
// a warning or an error?
if BitAnd(ErrorType, me.kE_WARNING) = me.kE_WARNING then
// if user decided to ignore, we'll ignore
if IgnoreWarnings then Return 0
d.Message="A warning occurred while processing your PDF code."
// we add a third button to display all warnings
d.AlternateActionButton.Caption = "Ignore warnings"
d.AlternateActionButton.Visible = true
else
d.Message="An error occurred while processing your PDF code."
end if
d.Explanation = str(ErrorCode)+": "+ErrorMessage
b=d.ShowModal //display the dialog
Select Case b //determine which button was pressed.
Case d.ActionButton
Return 0 // ignore
Case d.AlternateActionButton
IgnoreWarnings = true
Return 0 // ignore
Case d.CancelButton
Return -1 // stop
End select
End EventHandler
Property IgnoreWarnings As Boolean
End Class
End Project
See also:
The items on this page are in the following plugins: MBS DynaPDF Plugin.