Platforms to show: All Mac Windows Linux Cross-Platform
/DynaPDF/Raster/Create and Render PDF in console
Required plugins for this example: MBS DynaPDF Plugin, MBS Main Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /DynaPDF/Raster/Create and Render PDF in console
This example is the version from Wed, 14th Sep 2021.
Project "Create and Render PDF in console.xojo_binary_project"
Class App Inherits ConsoleApplication
EventHandler Function Run(args() as String) As Integer
dim pdf as new MyDynapdfMBS
dim d as new date
// load CharacterMaps if you want to correctly process asian fonts
'call pdf.SetCMapDir(SpecialFolder.Desktop.Child("CMap"), pdf.klcmRecursive)
pdf.SetLicenseKey "Pro" // For this example you can use a Pro or Enterprise License
call pdf.CreateNewPDF nil
call pdf.SetDocInfo pdf.kdiSubject, "My first Xojo output"
call pdf.SetDocInfo pdf.kdiProducer, "Xojo test application"
call pdf.SetDocInfo pdf.kdiTitle, "My first Xojo output"
// We want to use top-down coordinates
call pdf.SetPageCoords pdf.kpcTopDown
call pdf.Append
#if RBVersion > 2010.04 then // picture class is only available in RS 2010r4 and newer
dim pic as Picture = LogoMBS(500) // Needs Main Plugin
call pdf.InsertPicture(pic, 50, 200, 200, 200)
#endif
call pdf.SetFont "Times", pdf.kfsItalic, 40.0, true, pdf.kcpUnicode
call pdf.WriteFText pdf.ktaCenter, "My first Xojo output!"
call pdf.SetFont "Times", pdf.kfsItalic, 20.0, true, pdf.kcpUnicode
call pdf.WriteText 50.0, 180.0, "File created: " + d.LongDate
call pdf.EndPage
#if RBVersion > 2010.04 then
dim out as Picture = pdf.RenderPagePicture(1)
if out = nil then
print "Error: picture is nil."
Return 1
end if
dim outfile as FolderItem = SpecialFolder.Desktop.Child("Create and Render PDF in console.jpg")
out.Save(outfile, out.SaveAsJPEG)
#endif
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:
print str(ErrorCode)+": "+ErrorMessage
Return 0 // ignore
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.