Xojo Conferences

Platforms to show: All Mac Windows Linux Cross-Platform

/DynaPDF/Display Form Fields
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/Display Form Fields
This example is the version from Sun, 16th Feb 2013.
Project "Display Form Fields.rbp"
Filetype text
Filetype icc
End FileTypes
MenuBar MenuBar1
MenuItem UntitledMenu1 = ""
MenuItem FileMenu = "&File"
MenuItem FileQuit = "Quit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu0 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
EventHandler Sub Open() dim pdf as new MyDynapdfMBS dim d as new date dim f as integer // Error messages and warnings are passed to the callback function. pdf.SetLicenseKey "Lite" // For this example you can use a Lite, Pro or Enterprise License dim file as FolderItem = SpecialFolder.Desktop.Child("A-1.pdf") call pdf.CreateNewPDF(nil) call pdf.OpenImportFile(file) call pdf.ImportPDFFile( 1, 1.0, 1.0) // check what fields are there and show in listbox: dim list as listbox = MainWindow.List dim PageDic as new Dictionary dim PageCount as integer = pdf.GetPageCount for PageIndex as integer = 1 to PageCount dim page as new Page page.Page = PageIndex PageDic.Value(PageIndex) = page List.addFolder str(pageIndex) List.RowTag(List.LastIndex) = page next dim lostFields as new page dim FieldCount as integer = pdf.GetFieldCount-1 for FieldIndex as integer = 0 to FieldCount dim field as new Field field.index = FieldIndex field.Info = pdf.GetFieldex(FieldIndex) field.name = pdf.GetFieldName(FieldIndex) field.type = pdf.GetFieldType(FieldIndex) dim PageNum as integer = field.Info.PageNum if PageNum>0 then dim page as page = PageDic.Value(PageNum) page.Fields.Append field else lostFields.Fields.Append field end if field.ExpValCount = pdf.GetFieldExpValCount(FieldIndex) field.ExpValue = pdf.GetFieldExpValue(FieldIndex) for i as integer = 0 to field.ExpValCount-1 next next List.addFolder "Fields without page" List.RowTag(List.LastIndex) = lostFields call pdf.CloseFile End EventHandler
End Class
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
Class MainWindow Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
EventHandler Sub ExpandRow(row As Integer) dim v as Variant = me.RowTag(row) if v isa page then dim p as page = v for each f as field in p.Fields me.AddFolder str(f.index) me.Cell(me.LastIndex,1) = f.name me.RowTag(me.LastIndex) = f next elseif v isa Field then dim f as Field = v me.AddRow "Name", f.name dim ts as string Select case f.type case DynaPDFMBS.kftButton ts = " Button" case DynaPDFMBS.kftCheckBox ts = " CheckBox" case DynaPDFMBS.kftComboBox ts = " ComboBox" case DynaPDFMBS.kftGroup ts = " Group" case DynaPDFMBS.kftListBox ts = " ListBox" case DynaPDFMBS.kftRadioBtn ts = " RadioButton" case DynaPDFMBS.kftSignature ts = " Signature" case DynaPDFMBS.kftText ts = " Text" end Select me.AddRow "Type", str(f.type)+ts me.AddRow "Index", str(f.index) me.AddRow "Deleted", str(f.info.Deleted) me.AddRow "BBox", str(f.info.BBox.Left)+" "+str(f.info.BBox.Top)+" to "+str(f.info.BBox.Right)+" "+str(f.info.BBox.Bottom) me.AddRow "GroupType", str(f.info.GroupType) me.AddRow "Checked;", str(f.info.Checked) me.AddRow "CheckBoxChar", str(f.info.CheckBoxChar) me.AddRow "Default Value", str(f.info.DefValue) me.AddRow "ExpValCount", str(f.info.ExpValCount) me.AddRow "ExpValue", str(f.info.ExpValue) me.AddRow "KidCount", str(f.info.KidCount) me.AddRow "UniqueName", str(f.info.UniqueName) me.AddRow "ToolTip", str(f.info.ToolTip) me.AddRow "Value", str(f.info.Value) me.AddRow "ExpValue", str(f.ExpValue) for i as integer = 0 to f.Info.KidCount-1 me.AddFolder "Child "+str(i) me.RowTag(me.LastIndex) = f.Info.Kids(i) next end if End EventHandler
End Control
End Class
Class Page
Property Fields() As Field
Property Page As Integer
End Class
Class Field
Property ExpValCount As Integer
Property ExpValue As string
Property Info As DynaPDFFieldExMBS
Property index As integer
Property name As string
Property type As Integer
End Class
End Project

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS DynaPDF Plugin.

MBS Xojo Plugins