Example: /DynaPDF/DynaPDF Merge 2 to 1

Online Documentation   -   Statistics   -   FAQ   -   Plugin Parts (All, Dependencies)   -   Class hierarchy

New in Version 22.2 22.3 22.4 22.5 23.0 23.1 23.2 23.3 23.4 23.5 24.0 24.1

The list of the   topics,   classes,   interfaces,   controls,   modules,   global methods by category,   global methods by name,   screenshots,   licenses   and   examples.

Platforms to show: All Mac Windows Linux Cross-Platform

/DynaPDF/DynaPDF Merge 2 to 1


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/DynaPDF Merge 2 to 1

This example is the version from Fri, 19th May 2022.

Project "DynaPDF Merge 2 to 1.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
EventHandler Sub Open() Dim f As FolderItem = findFile("dynapdf_help.pdf") Dim d As FolderItem = SpecialFolder.Desktop.Child("test.pdf") Process f, d d.Launch End EventHandler
Function FindFile(name as string) As FolderItem // Look for file in parent folders from executable on dim parent as FolderItem = app.ExecutableFile.Parent while parent<>Nil dim file as FolderItem = parent.Child(name) if file<>Nil and file.Exists then Return file end if parent = parent.Parent wend End Function
Sub Process(InputFile as FolderItem, OutputFile as FolderItem) Dim pdf As New DynapdfMBS pdf.SetLicenseKey "Pro" // For this example you can use a Pro or Enterprise License Call pdf.CreateNewPDF OutputFile Dim r As Integer = pdf.OpenImportFile(InputFile, pdf.kptOpen, "") If r < 0 Then MessageBox "Not a PDF file!?" Return End If // we merge 2 pages on one Dim c As Integer = pdf.GetInPageCount For i As Integer = 1 To c Step 2 If i = c Then // last page call pdf.ImportPDFPage(i) Else Dim template1 As Integer = pdf.ImportPage(i) Dim template2 As Integer = pdf.ImportPage(i+1) Dim template1width As Double = pdf.GetTemplWidth(template1) Dim template1height As Double = pdf.GetTemplHeight(template1) Dim template2width As Double = pdf.GetTemplWidth(template2) Dim template2height As Double = pdf.GetTemplHeight(template2) Dim PageWidth As Double = template1width + template2width Dim PageHeight As Double = Max(template1height, template2height) // make new page Call pdf.append // change page size Call pdf.SetPageWidth(PageWidth) Call pdf.SetPageHeight(PageHeight) // place on left Call pdf.PlaceTemplateEx(template1, 0, 0, template1width, template1height) // and on right Call pdf.PlaceTemplateEx(template2, template1width, 0, template2width, template2height) Call pdf.EndPage end if Next Call pdf.CloseFile End Sub
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
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"
End MenuBar
End Project

See also:

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


💬 Ask a question or report a problem