Platforms to show: All Mac Windows Linux Cross-Platform

/DynaPDF/Tables/Table Templates


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 Templates

This example is the version from Thu, 6th Apr 2016.

Project "Table Templates.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
EventHandler Sub Open() Run quit End EventHandler
Function FindFile(name as string) As FolderItem // Look for file in parent folders from executable on dim parent as FolderItem = app.ExecutableFile.Parent while parent<>Nil dim file as FolderItem = parent.Child(name) if file<>Nil and file.Exists then Return file end if parent = parent.Parent wend End Function
Sub Run() dim pdf as new MyDynaPDFMBS call pdf.SetPageCoords(pdf.kpcTopDown) call pdf.CreateNewPDF call pdf.SetImportFlags2(pdf.kif2UseProxy) // Reduce the memory usage dim importFile as FolderItem = findFile("dynapdf_help.pdf") dim outputFile as FolderItem = SpecialFolder.Desktop.Child("Table Templates.pdf") call pdf.OpenImportFile(importFile) dim pageCount as integer = pdf.GetInPageCount dim rowNum as integer = 0 dim tbl as DynaPDFTableMBS = pdf.CreateTable(pageCount / 4 + 1, 2, 512.12, 0.0) call tbl.SetBorderWidth(-1, -1, 1.0, 1.0, 1.0, 1.0) call tbl.SetCellPadding(-1, -1, 5.0, 5.0, 5.0, 5.0) call tbl.SetGridWidth(1.0, 1.0) call tbl.SetFlags(-1, -1, tbl.ktfScaleToRect) call pdf.SetPageFormat(pdf.kpfUS_Letter) for i as integer = 1 to pageCount dim tmpl as integer = pdf.ImportPage(i) if BitwiseAnd(i,1) = 1 then rowNum = tbl.AddRow(335.0) end if call tbl.SetCellTemplate(rowNum, bitwiseAnd((i-1), 1), true, tbl.kcoCenter, tbl.kcoCenter, tmpl, 0.0, 0.0) next // 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 // A table stores errors and warnings in the error log pageCount = pdf.GetErrLogMessageCount for i as integer = 0 to pagecount-1 dim err as DynaPDFErrorMBS = pdf.GetErrLogMessage(i) MsgBox err.Message next // No fatal error occurred? if pdf.HaveOpenDoc then // OK, now we can open the output file. if not pdf.OpenOutputFile(outputFile) then MsgBox "Failed to create PDF file." quit end if end if call pdf.CloseFile OutputFile.launch 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.


The biggest plugin in space...