Platforms to show: All Mac Windows Linux Cross-Platform

/DynaPDF/DynaPDF PDF Viewer
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /DynaPDF/DynaPDF PDF Viewer
This example is the version from Fri, 4th May 2023.
Project "DynaPDF PDF Viewer.xojo_binary_project"
Class App Inherits DesktopApplication
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
EventHandler Sub DocumentCreated() Dim f As FolderItem #If DebugBuild Then f = SpecialFolder.Desktop.Child("test.pdf") if f.Exists then OpenDocument f return end if #endif Dim o As New OpenFileDialog o.Filter = FileTypeGroup1.Pdf f = o.ShowModal If f <> Nil Then OpenDocument f End If End EventHandler
EventHandler Sub DocumentOpened(item As FolderItem) Try Dim pdf As New DynaPDFMBS pdf.SetLicenseKey "Pro" // For this example you can use a Pro or Enterprise License InitColorManagement pdf Call pdf.CreateNewPDF(Nil) If pdf.OpenImportFile(item) >= 0 Then Dim n As Integer = pdf.ImportPDFFile(1) dim w as new MainWindow w.Load item, pdf end if Catch r As RuntimeException MessageBox "Failed to load PDF."+EndOfLine+EndOfLine+r.Message End Try End EventHandler
EventHandler Sub Opening() End EventHandler
Function FileOpen() As Boolean Dim o As New OpenFileDialog o.Filter = FileTypeGroup1.Pdf dim f as FolderItem = o.ShowModal if f <> nil then OpenDocument f end if Return True End Function
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 InitColorManagement(PDF as DynaPDFMBS) // init color management, if you have the profile files Dim profiles As New DynaPDFColorProfilesMBS // we use some generic profiles here in case none are in the PDF Dim CMYK_Profile_File As FolderItem = findFile("Generic CMYK Profile.icc") Dim RGB_Profile_File As FolderItem = findFile("Generic RGB Profile.icc") Dim Gray_Profile_File As FolderItem = findFile("Generic Gray Profile.icc") Profiles.DefInCMYK = CMYK_Profile_File Profiles.DefInGray = Gray_Profile_File Profiles.DefInRGB = RGB_Profile_File Profiles.DeviceProfile = Nil // CMYK_Profile_File Profiles.SoftProof = Nil // for me seems better with kcsDeviceRGB here and DeviceProfile nil!? // better than kcsDeviceCMYK and passing CMYK profile for device profile. If pdf.InitColorManagement(profiles, pdf.kcsDeviceRGB, pdf.kicmBPCompensation) Then // okay End If End Sub
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileOpen = "Open..."
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
MenuItem HelpMenu = "&Help"
End MenuBar
Filetype application/pdf
End FileTypeGroup1
End Project

See also:

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

💬 Ask a question or report a problem
The biggest plugin in space...

Start Chat