Platforms to show: All Mac Windows Linux Cross-Platform

/DynaPDF/OCG/OCG Test


You find this example project in your Plugins Download as a Xojo project file within the examples folder: /DynaPDF/OCG/OCG Test

This example is the version from Sat, 19th Jan 2018.

Project "OCG Test.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
EventHandler Sub CellAction(row As Integer, column As Integer) Update End EventHandler
EventHandler Sub Open() me.ColumnType(0) = me.TypeCheckbox End EventHandler
End Control
Control Output Inherits Canvas
ControlInstance Output Inherits Canvas
EventHandler Sub Paint(g As Graphics, areas() As REALbasic.Rect) if pic <> nil then g.DrawPicture pic, 0, 0, g.Width, g.Height, 0, 0, pic.Width, pic.Height end if End EventHandler
End Control
EventHandler Sub Open() file = findFIle("test.pdf") if file = nil then file = GetOpenFolderItem("") end if ReadInfo update 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 ReadInfo() p = new MyDynaPDFMBS p.SetLicenseKey "Pro" // For this example you can use Pro or Enterprise License call p.CreateNewPDF(nil) // Skip anything that is not required call p.SetImportFlags p.kifImportAll+p.kifImportAsPage // From which PDF file do you want to extract the images? call p.OpenImportFile(file, p.kptOpen, "") // import pages call p.ImportPDFFile(1, 1.0, 1.0) call p.CloseImportFile // lookup all links dim u as integer = p.GetOCGCount - 1 Title = str(p.GetOCGCount)+" OCGs" for i as integer = 0 to u dim b as DynaPDFOCGMBS = p.GetOCG(i) List.AddRow b.Name List.RowTag(List.LastIndex) = i next End Sub
Sub Update() dim u as integer = List.ListCount-1 for i as integer = 0 to u dim on as Boolean = List.CellCheck(i,0) dim h as integer = list.RowTag(i) call p.SetOCGState h, on, false next #if RBVersion > 2013 then if self.BackingScaleFactorMBS > 1 then // Mac retina pic = p.RenderPagePicture(1, output.Width*2, output.Height*2) else // normal pic = p.RenderPagePicture(1, output.Width, output.Height) end if #else pic = p.RenderPagePicture(1, output.Width, output.Height) #endif output.Invalidate End Sub
Property file As FolderItem
Property p As MyDynaPDFMBS
Property pic As Picture
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
SetRetina
End SetRetina
End Project

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


The biggest plugin in space...