Platforms to show: All Mac Windows Linux Cross-Platform
Last modified Wed, 25th Aug 2026.
You find this example project in your MBS Xojo Plugin download as a Xojo project file within the examples folder: /DynaPDF/SVG Viewer
Download this example: SVG Viewer.zip
Project "SVG Viewer.xojo_binary_project"
Class App Inherits DesktopApplication
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
EventHandler Sub DocumentCreated()
Load
End EventHandler
EventHandler Sub DocumentOpened(item As FolderItem)
Render item
End EventHandler
Function FileOpen() As Boolean
Load
Return True
End Function
Sub Load()
Var f As FolderItem = GetOpenFolderItem(FileTypeGroup1.SVG)
If f <> Nil Then
OpenDocument f
End If
End Sub
Sub Render(Item as FolderItem)
Var pdf As New DynaPDFMBS
Call pdf.CreateNewPDF
Var svg As DynaPDFSVGMBS = pdf.LoadSVG(item)
If svg <> Nil Then
// you can check for symbols to loop over all images in the SVG
Var count As Integer = svg.SymbolCount
If count = 0 Then
MessageBox "Failed to load SVG file."
else
// we query size of main item
Var width, height As Double
If svg.Size(width, height) Then
MessageBox width.ToString+" x "+height.ToString
Call pdf.Append
// now we make a page in the right size and place the SVG image
Call pdf.SetPageWidth(width)
Call pdf.SetPageHeight(height)
Call pdf.InsertSVG(svg, 0, 0, width, height)
call pdf.EndPage
// let's render it
Var PointWidth As Integer = width
Var PointHeight As Integer = height
If width < 500 Or height < 500 Then
// small ones get enlarged
PointWidth = PointWidth * 2
PointHeight = PointHeight * 2
End If
// we render a 200% for sharper view
Var pic As Picture = pdf.RenderPagePicture(1, PointWidth*2, PointHeight*2)
Var win As New ViewerWindow
win.Title = item.name
win.Width = PointWidth
win.Height = PointHeight
win.pic = pic
win.show
Return
End If
End If
end if
End Sub
End Class
Class ViewerWindow Inherits DesktopWindow
EventHandler Sub Paint(g As Graphics, areas() As Rect)
if pic <> nil then
g.DrawPicture pic, 0, 0, g.Width, g.Height, 0, 0, pic.Width, pic.Height
End If
End EventHandler
Property pic As Picture
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 WindowMenu = "Window"
MenuItem HelpMenu = "&Help"
End MenuBar
Sign
End Sign
FileTypeGroup1
Filetype SVG
End FileTypeGroup1
End Project
Download this example: SVG Viewer.zip
The items on this page are in the following plugins: MBS DynaPDF Plugin.