Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/DynaPDF/Raster/updatewindow event/Display PDF
Function:
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/updatewindow event/Display PDF
This example is the version from Sun, 17th Mar 2012.
Project "Display PDF.rbp"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
EventHandler Sub Open() dim f as FolderItem = SpecialFolder.Desktop.Child("test.pdf") if f = nil or f.Exists = false then MsgBox "Please use ""Create huge Test PDF"" example project to create the PDF file for testing." Return end if End EventHandler
End Class
Class Window1 Inherits Window
Control Thread1 Inherits Thread
ControlInstance Thread1 Inherits Thread
EventHandler Sub Run() dim pdf as new MyDynaPDFMBS dim file as FolderItem = SpecialFolder.Desktop.Child("test.pdf") call pdf.CreateNewPDF(nil) call pdf.OpenImportFile(file, 0, "") call pdf.SetImportFlags(pdf.kifImportAsPage) // important! It makes the rendering faster. // import the first page only call pdf.Append call pdf.ImportPageEx(1,1.0,1.0) call pdf.EndPage dim o as new MyDynaPDFRasterImageMBS o.DefScale = 2 o.NumAnnots = 0 o.UpdateOnPathCount = 10 o.UpdateOnImageCoverage = 0.01 o.Yield = true // give time to other threads dim page as DynaPDFPageMBS = pdf.GetPage(1) dim r as new DynaPDFRasterizerMBS(pdf, 1190, 1684) pic = r.pic if r.RenderPage(page, o) then // ok Backdrop = r.pic UpdateNow end if End EventHandler
End Control
Control Timer1 Inherits Timer
ControlInstance Timer1 Inherits Timer
EventHandler Sub Action() // we start the thread after a second, so you see the drawing better Thread1.run End EventHandler
End Control
EventHandler Sub Paint(g As Graphics) g.DrawPicture pic,0,0 End EventHandler
Property pic As Picture
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 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
Class MyDynaPDFRasterImageMBS Inherits DynaPDFRasterImageMBS
EventHandler Function UpdateWindow(r as DynaPDFRectMBS, pic as variant) As integer dim p as Picture = pic // so Real Studio clears picture cache and we see something! p.Graphics.pixel(0,0) = p.Graphics.pixel(0,0) // we draw only the changed part window1.Graphics.DrawPicture p, r.Left, r.top, r.Right, r.Bottom, r.Left, r.top, r.Right, r.Bottom window1.UpdateNow Exception // on any exception, cancel Return 1 End EventHandler
End Class
End Project

See also:

Feedback, Comments & Corrections

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




Links
MBS Xojo Plugins