Platforms to show: All Mac Windows Linux Cross-Platform

/DynaPDF/Raster/Search and show PDF files


Required plugins for this example: MBS DynaPDF Plugin, MBS MacOSX Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /DynaPDF/Raster/Search and show PDF files

This example is the version from Thu, 31th Jul 2019.

Project "Search and show PDF files.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
EventHandler Sub Open() if TargetMachO then // ok else MsgBox "This example works only on Mac OS X as we use Spotlight to find PDF files." quit end if End EventHandler
End Class
Class MainWindow Inherits Window
Control Timer1 Inherits Timer
ControlInstance Timer1 Inherits Timer
EventHandler Sub Action() if pageCount<=PageIndex then // load next if UBound(files)<0 then Return dim n as integer = (UBound(files)+1)*rnd file = files(n) files.Remove n // close last pdf call pdf.CloseImportFile call pdf.FreePDF // clear memory, but keep object System.DebugLog "Load "+file.NativePath // create new one call pdf.CreateNewPDF(nil) call pdf.SetImportFlags(pdf.kifImportAsPage) call pdf.OpenImportFile(file, 0, "") PageCount = pdf.GetPageCount PageIndex = 0 end if // show all pages 'PageIndex = PageIndex + 1 // show one random page PageIndex = random.InRange(1, pageCount) pageCount = 0 // trigger load of next PDF on the next run // import only the page we need call pdf.Append call pdf.ImportPageEx(PageIndex, 1.0, 1.0) call pdf.EndPage // render page as picture dim t as integer = ticks dim pic as Picture = pdf.RenderPagePicture(pdf.GetPageCount) // new imported page is the newest page t = ticks - t if t>10 then System.DebugLog str(t)+" ticks for "+file.NativePath end if if pic = nil then System.DebugLog "no picture for "+file.NativePath else self.pic = pic end if End EventHandler
End Control
EventHandler Sub Close() if q<>nil then // need MacOSX Plugin for MDQuery. q.stop q=nil end if End EventHandler
EventHandler Sub Open() Random = new Random pdf = new MyDynaPDFMBS // Needs MBS MacOSX Plugin q=new MyQuery("kMDItemContentType=""com.adobe.pdf""") if q.Handle=0 then MsgBox "Failed to create query" else if q.Execute(q.kMDQueryWantsUpdates) then 'ok else MsgBox "Failed to run query" end if end if self.Maximize End EventHandler
EventHandler Sub Paint(g As Graphics, areas() As REALbasic.Rect) if pic <> nil then dim x as integer = (g.Width - pic.Width)*rnd dim y as integer = (g.Height - pic.Height)*rnd g.DrawPicture pic, x, y end if End EventHandler
Sub Add(path as string) if path = "" then Return dim file as FolderItem = GetFolderItem(Path, folderitem.PathTypeShell) files.Append file Title = str(UBound(files)+1)+" PDF files" Exception e End Sub
Property PageIndex As Integer
Property file As FolderItem
Property files() As FolderItem
Property pageCount As Integer
Property pdf As MyDynaPDFMBS
Property pic As Picture
Property q As MyQuery
Property random As Random
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 MyQuery Inherits MDQueryMBS
EventHandler Sub Progress(AddedItems() as MDItemMBS, ChangedItems() as MDItemMBS, RemovedItems() as MDItemMBS) for each it as MDItemMBS in AddedItems MainWindow.Add it.path next End EventHandler
EventHandler Sub Update(AddedItems() as MDItemMBS, ChangedItems() as MDItemMBS, RemovedItems() as MDItemMBS) for each it as MDItemMBS in AddedItems MainWindow.Add it.path next 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 Return 0 // ignore End EventHandler
Property IgnoreWarnings As Boolean
End Class
End Project

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


The biggest plugin in space...