HCS Consulting Group.
We make Complex Systems simple

Merge PDF documents in MS-Access (including x64 bit version)

By Albert D. Kallal
October 12, 2021

PDF merge for Access.

Quick start for those in a hurry:

Working sample: Download link: Click here-->>Pmerge.zip

PLEASE note: remember, after you download, make sure you un-block the content before un-zipping,

else this will NOT work.

Eg: right click on zip file - choose properties.

(if you don't un-block before you unzip, then sample will not work!)

How to use?

Sample form included looks like this:

So, just launch the sample, and start merging PDF's.

VBA code to merge PDF files is:

Sub TestMerge1()

Dim MyPdf As Object
Set MyPdf = CreateObjectNET("Pmerge.dll", "Pmerge.Pmerge")

MyPdf.Add CurrentProject.Path & "\a.pdf"
MyPdf.Add CurrentProject.Path & "\b.pdf"


' set output file to merge above list to
MyPdf.OutPutDoc = CurrentProject.Path & "\ab.pdf"

MyPdf.Merge ' merge the files

Debug.Print "done"

End Sub

So above would merge a.pdf + b.pdf into ab.pdf (and above code assumes in same folder as your Access accDB running application.

Additional features:

Adding page numbers:

You can have merge add page numbers to output file  (left, center, right)

 MyPdf.CreatePageNumbers = True
 ' and justify (position) choices are:

 MyPdf.Justify = "Left"
 MyPdf.Justify = "Center"   (default)
 MyPdf.Justify = "Right"
 

This will output a page number on bottom of PDF like this:

Above also shows use of Text option

Adding Text to PDF pages :

You can add a small text message to each page (as in above picture), like this:

 MyPdf.CustomText = txtFooting
 MyPdf.CustomTextJustify = "Left"    (default)
 MyPdf.CustomTextJustify = "Center"
 MyPdf.CustomTextJustify = "Right"

 

Default is left, and again same as page number. If you try to place both page number, and text in the same location, then both will display beside each other.

Merge page ranges: comming soon!

Files required and deployment:

There is no "install" of the required files, but you must include these files

nloader.dll      -- required for office x32 version

nloader64.dll  -- required for office x64 version

pmerge.dll     -- required

this pmerge system was written in .net, and uses the iTextSharp library.

Using in your existing application:

Simply copy (cut + paste) or import the one standard code module into your application:

(NetLoader module)

Make sure the 3 .dll's in the SAME folder location as your accDB file.

That's it

 

Home