Example: /DynaPDF/Raster/Batch Convert PDF to JPG

Online Documentation   -   Statistics   -   FAQ   -   Plugin Parts (All, Dependencies)   -   Class hierarchy

New in Version 22.2 22.3 22.4 22.5 23.0 23.1 23.2 23.3 23.4 23.5 24.0 24.1

The list of the   topics,   classes,   interfaces,   controls,   modules,   global methods by category,   global methods by name,   screenshots,   licenses   and   examples.

Platforms to show: All Mac Windows Linux Cross-Platform

/DynaPDF/Raster/Batch Convert PDF to JPG


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/Raster/Batch Convert PDF to JPG

This example is the version from Sun, 17th Mar 2012.

Project "Batch Convert PDF to JPG.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
EventHandler Sub Open() dim folder as FolderItem = SpecialFolder.Desktop.Child("testpdfs") if folder.Exists = false then MsgBox "Please change path to your own PDF folder." end if dim c as integer = folder.count for i as integer = 1 to c dim item as FolderItem = folder.TrueItem(i) if item<>Nil and right(item.name,4)=".pdf" then dim pdf as new MyDynaPDFMBS call pdf.CreateNewPDF(nil) call pdf.SetImportFlags(pdf.kifImportAsPage) call pdf.OpenImportFile(item, 0, "") call pdf.ImportPDFFile(1,1.0,1.0) dim pc as integer = pdf.GetPageCount for pi as integer = 1 to pc System.DebugLog item.name // query size of imported page dim rect as DynaPDFRectMBS = pdf.GetInBBox(pi, pdf.kpbCropBox) if rect = nil then // use media box if there is no crop box rect = pdf.GetInBBox(pi, pdf.kpbMediaBox) end if dim w,h as integer if rect.Bottom>rect.Top then h = rect.Bottom - rect.Top else h = rect.top - rect.Bottom end if if rect.Right>rect.Left then w = rect.Right - rect.Left else w = rect.Left - rect.Right end if // render page as picture dim pic as Picture = pdf.RenderPagePicture(pi, w, h) dim name as string = ReplaceAll(item.name, ".pdf", "") dim output as FolderItem = SpecialFolder.Desktop.Child(name+str(pi)+".jpg") if pic<>Nil then // older REAL Studio versions output.SaveAsJPEG pic // newer REAL Studio versions 'pic.Save(output, pic.SaveAsJPEG) output.Launch(True) end if next end if next quit End EventHandler
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
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

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


💬 Ask a question or report a problem