Platforms to show: All Mac Windows Linux Cross-Platform

/DynaPDF/Show ColorSpaces

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/Show ColorSpaces

This example is the version from Wed, 12th Jan 2016.

Project "Show ColorSpaces.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
EventHandler Sub Open() dim f as FolderItem = GetOpenFolderItem(MyFileTypes.All) if f=nil then quit end if dim p as new MyDynapdfMBS p.SetLicenseKey "Pro" // For this example you can use a Pro or Enterprise License call p.CreateNewPDF // Skip anything that is not required call p.SetImportFlags p.kifContentOnly+p.kifImportAsPage // From which PDF file do you want to extract the images? call p.OpenImportFile(f, p.kptOpen, "") // Import file call p.ImportPDFFile(1, 1.0, 1.0) p End EventHandler
End Class
Class Window1 Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
Control List2 Inherits Listbox
ControlInstance List2 Inherits Listbox
End Control
Control Label1 Inherits Label
ControlInstance Label1 Inherits Label
End Control
Control PageLabel Inherits Label
ControlInstance PageLabel Inherits Label
End Control
Control PageSlider Inherits Slider
ControlInstance PageSlider Inherits Slider
EventHandler Sub ValueChanged() PageLabel.text = str(me.Value) ShowColorSpaces me.value End EventHandler
End Control
Sub ListColorSpaces(ColorSpaces() as DynaPDFColorSpaceMBS, list as listbox) for each c as DynaPDFColorSpaceMBS in ColorSpaces dim name as string = if name = "" then select case c.type case pdf.kesDeviceN // for deviceN we show color names dim colorands() as String dim u as integer = c.ColorantsCount - 1 for i as integer = 0 to u colorands.Append c.Colorants(i) next name = "DeviceN with "+Join(colorands, ", ") end Select end if list.AddRow str(c.Index), name, c.TypeString next End Sub
Sub Run(d as DynaPDFMBS) pdf = d list.DeleteAllRows dim c() as DynaPDFColorSpaceMBS = pdf.GetDocumentColorSpaces ListColorSpaces c, list PageSlider.Maximum = pdf.GetPageCount ShowColorSpaces 1 End Sub
Sub ShowColorSpaces(Page as Integer) list2.DeleteAllRows if pdf.EditPage(page) then dim c() as DynaPDFColorSpaceMBS = pdf.GetPageColorSpaces ListColorSpaces c, list2 call pdf.EndPage end if End Sub
Property pdf As DynapdfMBS
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
Filetype application/pdf
Filetype application/ai
End MyFileTypes
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...