Platforms to show: All Mac Windows Linux Cross-Platform

/DynaPDF/Wiki to PDF/Create PDF
Function:
Required plugins for this example: MBS DynaPDF Plugin, MBS DataTypes Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /DynaPDF/Wiki to PDF/Create PDF
This example is the version from Sun, 23th Sep 2017.
Project "Create PDF.xojo_binary_project"
FileTypes
Filetype text
End FileTypes
MenuBar MenuBar1
MenuItem UntitledMenu1 = ""
MenuItem FileMenu = "&File"
MenuItem FileQuit = "Quit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu0 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
EventHandler Sub Open() // License code registration could be done here End EventHandler
Sub ReadFiles() dim folder as FolderItem = SpecialFolder.Desktop.Child("pdf files") dim c as integer = folder.count for i as integer = 1 to c dim file as FolderItem = folder.TrueItem(i) if file<>nil and right(file.name,4)=".pdf" then dim tname as string = left(file.name, len(file.name)-4)+".txt" dim tfile as FolderItem = file.parent.Child(tname) if tfile<>nil and tfile.Exists then dim t as TextInputStream = tfile.OpenAsTextFile if t = nil then t = tfile.OpenAsTextFile end if if t<>Nil then dim url as string = t.ReadLine(encodings.UTF8) urls.Append url files.Append file end if end if end if next End Sub
Sub ReadRedirects() // Read duplicates list to avoid duplicates in PDFs dim f as FolderItem = SpecialFolder.Desktop.Child("redirect") dim t as TextInputStream = f.OpenAsTextFile if t = nil then Return dim tab as string = encodings.ASCII.Chr(9) while not t.EOF dim line as string = t.ReadLine(encodings.ASCII) dim l as string = NthField(line, tab, 1) dim r as string = NthField(line, tab, 2) if len(r)>0 then redirectFrom.Append l redirectto.Append r end if wend End Sub
Sub SortFiles() // sort by URL urls.SortWith(files) // sort category pages to the front dim u as integer = UBound(urls) for i as integer = 0 to u const k = "http://docs.realsoftware.com/index.php/Category" if left(urls(i),len(k)) = k then dim url as string = urls(i) dim file as FolderItem = files(i) files.Remove i urls.Remove i files.Insert 0, file urls.Insert 0, url end if next // sort main page to the front for i as integer = 0 to u if urls(i) = "http://docs.realsoftware.com/index.php/UsersGuide:Main" then dim url as string = urls(i) dim file as FolderItem = files(i) files.Remove i urls.Remove i files.Insert 0, file urls.Insert 0, url exit end if next // sort main page to the front for i as integer = 0 to u if urls(i) = "http://docs.realsoftware.com/index.php/Main_Page" then dim url as string = urls(i) dim file as FolderItem = files(i) files.Remove i urls.Remove i files.Insert 0, file urls.Insert 0, url exit end if next End Sub
Property URLs() As string
Property files() As FolderItem
Property redirectFrom() As string
Property redirectTo() As string
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
Class Annot
Property BBOX As DynaPDFRectMBS
Property Page As Integer
Property URL As string
Property handle As Integer
End Class
End Project

See also:

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

Feedback: Report problem or ask question.

The biggest plugin in space...