Platforms to show: All Mac Windows Linux Cross-Platform

/DynaPDF/Raster/PDF Benchmark

Required plugins for this example: MBS MacCG Plugin, MBS DynaPDF Plugin, MBS MacCF Plugin

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

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

Project "PDF Benchmark.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
EventHandler Sub NewDocument() dim file as FolderItem = GetOpenFolderItem(FileTypes1.Pdf) if file<>nil then OpenDocument file end if End EventHandler
EventHandler Sub OpenDocument(item As FolderItem) PDFWindow.render item End EventHandler
End Class
Class PDFWindow Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
Sub render(item as FolderItem) List.AddRow item.Name dim PageCount as integer dim w as integer = 600 dim h as integer = 800 dim pic as new Picture(w,h,32) dim dpdf as new MyDynaPDFMBS call dpdf.CreateNewPDF(nil) dim t1 as integer = ticks #if TargetMacOS then // requires MBS MacCG Plugin dim pdf as CGPDFDocumentMBS = item.OpenAsCGPDFDocumentMBS if pdf<>Nil then dim g as Graphics = pic.Graphics PageCount = pdf.PageCount for PageIndex as integer = 1 to PageCount dim r as CGRectMBS = CGMakeRectMBS(0,0,w,h) g.ForeColor = &cFFFFFF g.FillRect 0,0,w,h g.DrawCGPDFDocumentMBS(pdf, r, PageIndex) next t1 = ticks - t1 else t1 = 0 MsgBox "Not a PDF file?"+EndOfLine+EndOfLine+item.NativePath Return end if list.Cell(List.LastIndex,3) = format(t1/60.0,"0.0")+" seconds" #endif dim t2 as integer = ticks call dpdf.OpenImportFile(item, 0, "") call dpdf.SetImportFlags(dpdf.kifImportAsPage) call dpdf.ImportPDFFile(1,1.0,1.0) dim r as new DynaPDFRasterizerMBS(dpdf, pic) dim options as new DynaPDFRasterImageMBS options.InitWhite = true for PageIndex as integer = 1 to PageCount dim page as DynaPDFPageMBS = dpdf.GetPage(PageIndex) call r.RenderPage(page, options) next r = nil dpdf = nil t2 = ticks - t2 list.Cell(List.LastIndex,2) = format(t2/60.0,"0.0")+" seconds" list.Cell(List.LastIndex,1) = str(PageCount) End Sub
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
End FileTypes1
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...