Platforms to show: All Mac Windows Linux Cross-Platform

/DynaPDF/Create PDF with Circle Text
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/Create PDF with Circle Text
This example is the version from Wed, 14th Sep 2021.
Project "Create PDF with Circle Text.xojo_binary_project"
Filetype text
End FileTypes
MenuBar MenuBar1
MenuItem UntitledMenu1 = ""
MenuItem FileMenu = "&File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu5 = ""
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu0 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "Clear"
MenuItem UntitledMenu4 = ""
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = ""
End MenuBar
Class App Inherits Application
EventHandler Sub Open() dim pdf as new MyDynapdfMBS dim f as FolderItem = SpecialFolder.Desktop.Child("Create PDF with Circle Text.pdf") // create new PDF call pdf.CreateNewPDF f pdf.SetLicenseKey "Starter" // For this example you can use a Starter, Lite, Pro or Enterprise License // new page call pdf.Append Const pi = 3.1415926535897932384626433832795 Call pdf.SetFontEx("Arial", pdf.kfsRegular, 12.0, True, pdf.kcpUnicode) dim txt as string = "This text flows around a circle... " dim len as integer = len(txt) dim width as double = pdf.GetTextWidth(txt) // circumference = d * pi or 2 * r * pi dim r as double = width / pi * 0.5 // we need two rotations // at -90 degree the first character should have rotation of 0 degree // and the text should go in a circle. // so we calculate first the destination position for a character and // then we rotate it there in place dim m as new DynapdfMatrixMBS dim alpha, w, si, co, x, y as double dim a as double = -90.0 / 180.0 * pi dim g as double = 0.0 dim character as string = left(txt,1) w = pdf.GetTextWidth(character) // We change the rotating angle, so we rotate character in the center // We subtract it back later with WriteAngleText() g = w / r * 0.5 a = a + g for i as integer = 1 to len // calculate length of character character = mid(txt,i,1) w = pdf.GetTextWidth(character) si = sin(a) co = cos(a) // we rotate the coordinate system at point 250, 590... m.a = co m.b = si m.c = -si m.d = co m.x = 250.0 m.y = 590.0 x = -r y = 0.0 m.Transform(x, y) alpha = ((a-g) * 180.0 / pi) + 90.0 call pdf.WriteAngleText(character, alpha, x, y, 0.0, 0.0) a = a - w / r // Radians next // finish page call pdf.EndPage // Close file call pdf.CloseFile // open PDF f.Launch 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: 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.

💬 Ask a question or report a problem
The biggest plugin in space...

Start Chat