VeryPDF PDF Split-Merge SDK: Functions included in pdfpage.dll and VeryPDFSplitMergeCOM.exe

Below is a detailed explanation of each function and parameter in the provided code, including all Private Declare and wrapper functions. The functions are used to manipulate PDF files via the external DLL pdfpage.dll and VeryPDFSplitMergeCOM.exe COM interface.

https://www.verypdf.com/app/pdf-split-merge/

VeryPDF PDF Split-Merge SDK: Functions included in pdfpage.dll and VeryPDFSplitMergeCOM.exe


DLL Declarations (Private Declare) in pdfpage.dll

1. PDF_SetCode

Private Declare Sub PDF_SetCode Lib "pdfpage.dll" (ByVal strRegcode As String)
  • Purpose: Registers the library using a license key.
  • Parameter:
    • strRegcode: (String) The registration code or license key for enabling the full functionality of the DLL.

2. VeryAppendPDF

Private Declare Function VeryAppendPDF Lib "pdfpage.dll" (ByVal ptrExistingPDFName As String, ByVal ptrAppendPDF As String) As Long
  • Purpose: Appends one PDF file to the end of another.
  • Parameters:
    • ptrExistingPDFName: (String) The path to the existing base PDF file.
    • ptrAppendPDF: (String) The path to the PDF file to be appended.
  • Return: (Long) 0 indicates failure, non-zero indicates success.

3. VerySplitMergePDFEx

Private Declare Function VerySplitMergePDFEx Lib "pdfpage.dll" (ByVal lpInputPDF As String, ByVal lpPageRange As String, ByVal lpOutPDF As String) As Long
  • Purpose: Splits or merges pages from an input PDF based on a page range and saves the result as a new PDF.
  • Parameters:
    • lpInputPDF: (String) Path to the source PDF.
    • lpPageRange: (String) Page range string (e.g., "1,3,5-7").
    • lpOutPDF: (String) Path to the output PDF.
  • Return: (Long) Status code (non-zero for success).

4. VeryGetPDFFilePageCount

Private Declare Function VeryGetPDFFilePageCount Lib "pdfpage.dll" (ByVal lpInputPDF As String) As Long
  • Purpose: Returns the total number of pages in a PDF file.
  • Parameter:
    • lpInputPDF: (String) Path to the PDF file.
  • Return: (Long) Number of pages, or 0 on error.

5. VerySplitMergeSetParameter

Private Declare Function VerySplitMergeSetParameter Lib "pdfpage.dll" (ByVal key As String, ByVal value As String) As Long
  • Purpose: Sets additional parameters for the split/merge operation.
  • Parameters:
    • key: (String) The name of the setting (e.g., "Password").
    • value: (String) The value to assign to that setting.
  • Return: (Long) Status code (non-zero for success).

6. VerySplitMergePDF

Private Declare Function VerySplitMergePDF Lib "pdfpage.dll" (ByVal strCmd As String) As Long
  • Purpose: Performs PDF operations (split, merge, etc.) using a command string.
  • Parameter:
    • strCmd: (String) A command-line style string to control PDF operations.
  • Return: (Long) Status code (non-zero for success).

7. VeryGetPDFFilePageCountFast

Private Declare Function VeryGetPDFFilePageCountFast Lib "pdfpage.dll" (ByVal strInputFile As String) As Long
  • Purpose: Quickly retrieves the page count of a PDF (faster but may be less accurate).
  • Parameter:
    • strInputFile: (String) Path to the PDF file.
  • Return: (Long) Estimated number of pages.

8. PDF_MergePDFFiles

Private Declare Function PDF_MergePDFFiles Lib "pdfpage.dll" (ByVal strPDFFiles As String, ByVal strOutPDF As String) As Long
  • Purpose: Merges multiple PDF files into a single file.
  • Parameters:
    • strPDFFiles: (String) A string of PDF paths, separated by a delimiter (e.g., ";").
    • strOutPDF: (String) Path for the output merged PDF.
  • Return: (Long) Status code.

9. PDF_MergePDFFiles2

Private Declare Function PDF_MergePDFFiles2 Lib "pdfpage.dll" (ByVal strPDFFiles As String, ByVal strOutPDF As String, ByVal strCmd As String) As Long
  • Purpose: Merges PDF files with additional command options.
  • Parameters:
    • strPDFFiles: (String) List of input PDF files.
    • strOutPDF: (String) Output file path.
    • strCmd: (String) Additional command-line parameters for controlling merge behavior.
  • Return: (Long) Status code.

10. PDF_SetMode

Private Declare Sub PDF_SetMode Lib "pdfpage.dll" (ByVal nMode As Long)
  • Purpose: Sets the mode for the library (e.g., silent mode, debug mode).
  • Parameter:
    • nMode: (Long) Mode flag (exact values depend on the DLL documentation).

11. PDF_Open

Private Declare Function PDF_Open Lib "pdfpage.dll" (ByVal lpPDFName As String) As Long
  • Purpose: Opens a PDF file and returns a handle.
  • Parameter:
    • lpPDFName: (String) File path of the PDF to open.
  • Return: (Long) PDF handle, or 0 if it fails.

12. PDF_ExtractPages

Private Declare Function PDF_ExtractPages Lib "pdfpage.dll" (ByVal hPDF As Long, ByVal lpOutPDF As String, ByVal lpPageRange As String) As Long
  • Purpose: Extracts specific pages from an open PDF and saves them to a new file.
  • Parameters:
    • hPDF: (Long) PDF handle obtained from PDF_Open.
    • lpOutPDF: (String) Output file path.
    • lpPageRange: (String) Pages to extract (e.g., "2-4,6").
  • Return: (Long) Status code.

13. PDF_Close

Private Declare Sub PDF_Close Lib "pdfpage.dll" (ByVal hPDF As Long)
  • Purpose: Closes a previously opened PDF file.
  • Parameter:
    • hPDF: (Long) PDF handle returned by PDF_Open.

Wrapper Functions (Public Function and Public Sub)

These wrappers expose the DLL functions through public interfaces, allowing easier use within a VB application.

  • com_ prefix indicates "common" or "component" function wrapper.
  • All parameters and return types match the original DLL functions.
  • Most wrappers just forward the call and return the result.

Example:

Public Function com_VeryAppendPDF(ByVal ptrExistingPDFName As String, ByVal ptrAppendPDF As String) As Long
    com_VeryAppendPDF = VeryAppendPDF(ptrExistingPDFName, ptrAppendPDF)
End Function

This means that calling com_VeryAppendPDF(...) is the same as calling VeryAppendPDF(...) directly but offers modularization or public accessibility in a component-based VB system.

COM Interface Function Documentation in VeryPDFSplitMergeCOM.exe

Library: VeryPDFSplitMergeCOM.exe
Underlying Engine: pdfpage.dll
Language: VB6 COM-compatible (usable in VB/VBA/C#/Delphi, etc.)


1. com_VeryAppendPDF

Public Function com_VeryAppendPDF(ByVal ptrExistingPDFName As String, ByVal ptrAppendPDF As String) As Long

Description:
Appends the contents of ptrAppendPDF to the end of ptrExistingPDFName.

Parameters:

  • ptrExistingPDFName: String — Full file path to the base PDF file.
  • ptrAppendPDF: String — Full file path to the PDF file to append.

Returns:

  • 0 on failure.
  • Non-zero on success.

2. com_VerySplitMergePDFEx

Public Function com_VerySplitMergePDFEx(ByVal lpInputPDF As String, ByVal lpPageRange As String, ByVal lpOutPDF As String) As Long

Description:
Creates a new PDF by extracting specific pages from lpInputPDF and writing them into lpOutPDF.

Parameters:

  • lpInputPDF: String — Full path to the source PDF file.
  • lpPageRange: String — Page range (e.g., "1-3,5").
  • lpOutPDF: String — Full path to the output PDF.

Returns:

  • 0 on failure.
  • Non-zero on success.

3. com_VeryGetPDFFilePageCount

Public Function com_VeryGetPDFFilePageCount(ByVal lpInputPDF As String) As Long

Description:
Returns the number of pages in the specified PDF.

Parameters:

  • lpInputPDF: String — Full path to the PDF file.

Returns:

  • 0 on error.
  • Number of pages on success.

4. com_VerySplitMergeSetParameter

Public Function com_VerySplitMergeSetParameter(ByVal key As String, ByVal value As String) As Long

Description:
Sets configuration parameters (e.g., password, mode) for subsequent split/merge operations.

Parameters:

  • key: String — Parameter name (e.g., "Password", "OwnerPassword").
  • value: String — Corresponding value.

Returns:

  • 0 on failure.
  • Non-zero on success.

5. com_VerySplitMergePDF

Public Function com_VerySplitMergePDF(ByVal strCmd As String) As Long

Description:
Performs PDF split/merge based on a command-style string.

Parameters:

  • strCmd: String — Command-style parameters (e.g., "-split input.pdf output_%d.pdf").

Returns:

  • 0 on failure.
  • Non-zero on success.

6. com_PDF_MergePDFFiles

Public Function com_PDF_MergePDFFiles(ByVal strPDFFiles As String, ByVal strOutPDF As String) As Long

Description:
Merges multiple PDF files into a single output PDF.

Parameters:

  • strPDFFiles: String — Semicolon-delimited file paths (e.g., "a.pdf;b.pdf;c.pdf").
  • strOutPDF: String — Path to the output PDF file.

Returns:

  • 0 on failure.
  • Non-zero on success.

7. com_PDF_MergePDFFiles2

Public Function com_PDF_MergePDFFiles2(ByVal strPDFFiles As String, ByVal strOutPDF As String, ByVal strCmd As String) As Long

Description:
Merges PDF files with advanced options specified via strCmd.

Parameters:

  • strPDFFiles: String — List of input files (e.g., "1.pdf;2.pdf").
  • strOutPDF: String — Output PDF path.
  • strCmd: String — Additional options (e.g., "-no_bookmarks").

Returns:

  • 0 on failure.
  • Non-zero on success.

8. com_VeryGetPDFFilePageCountFast

Public Function com_VeryGetPDFFilePageCountFast(ByVal lpInputPDF As String) As Long

Description:
Returns the page count using a fast (but potentially less accurate) method.

Parameters:

  • lpInputPDF: String — Path to the PDF.

Returns:

  • Page count on success.
  • 0 on error.

9. com_PDF_SetCode

Public Sub com_PDF_SetCode(ByVal strRegcode As String)

Description:
Sets the registration/license code for PDF operations.

Parameters:

  • strRegcode: String — Product license or registration key.

Returns: None.


10. com_PDF_SetMode

Public Sub com_PDF_SetMode(ByVal nMode As Long)

Description:
Sets the working mode or feature level (e.g., debug, silent, etc.).

Parameters:

  • nMode: Long — Mode flag (defined by internal logic).

Returns: None.


11. com_PDF_Open

Function com_PDF_Open(ByVal lpPDFName As String) As Long

Description:
Opens a PDF file and returns a handle to it for further operations.

Parameters:

  • lpPDFName: String — Full path to the PDF.

Returns:

  • Handle (non-zero) on success.
  • 0 on failure.

12. com_PDF_ExtractPages

Function com_PDF_ExtractPages(ByVal hPDF As Long, ByVal lpOutPDF As String, ByVal lpPageRange As String) As Long

Description:
Extracts selected pages from an opened PDF handle and writes them to a new file.

Parameters:

  • hPDF: Long — Handle to the opened PDF.
  • lpOutPDF: String — Output file name.
  • lpPageRange: String — Page range (e.g., "1,3-5").

Returns:

  • 0 on failure.
  • Non-zero on success.

13. com_PDF_Close

Public Sub com_PDF_Close(ByVal hPDF As Long)

Description:
Closes the previously opened PDF file.

Parameters:

  • hPDF: Long — Handle to the PDF.

Returns: None.

Comprehensive VBScript Code Examples for PDF Processing with VeryPDFSplitMergeCOM

This section provides a curated collection of VBScript sample codes that demonstrate how to utilize the VeryPDFSplitMergeCOM component for advanced PDF manipulation tasks. These examples cover common operations such as:

  • Merging multiple PDF files into a single output document

  • Appending PDF pages to existing documents

  • Extracting specific page ranges from a PDF

  • Managing bookmarks and AcroForm retention settings

  • Integrating COM-based automation into Windows scripting environments

Each script serves as a practical use case to help developers understand how to automate PDF workflows using VeryPDF’s COM interface efficiently. Before running these samples, please ensure that the VeryPDFSplitMergeCOM.exe component is properly registered via install.vbs.

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' Please run install.vbs to register VeryPDFSplitMergeCOM.exe COM into your system first
'
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Set fso = CreateObject("Scripting.FileSystemObject") 
strFolder = fso.GetParentFolderName(wscript.ScriptFullName) 

strCoverPage = strFolder & "\example-fw9_1.pdf"
strReport = strFolder & "\testcmd.pdf"
strMergedReport = strFolder & "\_test_out.pdf"

Set VeryPDFSplitMergeCOM = CreateObject("VeryPDFSplitMergeCOM.com")
VeryPDFSplitMergeCOM.com_PDF_SetCode("XXXXXXXXXXXXXXXXXXXX")
iRet = VeryPDFSplitMergeCOM.com_VerySplitMergeSetParameter("RetainBookmarks", "off")
iRet = VeryPDFSplitMergeCOM.com_VerySplitMergeSetParameter("RetainAcroForms", "On")

fso.CopyFile strCoverPage, strMergedReport, True
MsgBox(strMergedReport & " is contain " & iPageCount & " pages.")
iRet = VeryPDFSplitMergeCOM.com_VeryAppendPDF(strMergedReport, strReport)
iRet = VeryPDFSplitMergeCOM.com_VeryAppendPDF(strMergedReport, strReport)
iRet = VeryPDFSplitMergeCOM.com_VeryAppendPDF(strMergedReport, strReport)
iPageCount = VeryPDFSplitMergeCOM.com_VeryGetPDFFilePageCount(strMergedReport)
MsgBox(strMergedReport & " is contain " & iPageCount & " pages.")





'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' Please run install.vbs to register VeryPDFSplitMergeCOM.exe COM into your system first
'
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Set fso = CreateObject("Scripting.FileSystemObject") 
strFolder = fso.GetParentFolderName(wscript.ScriptFullName) 

strPDFFiles = ""
strPDFFiles = strPDFFiles & strFolder & "\example-fw9_1.pdf"
strPDFFiles = strPDFFiles & "|" & strFolder & "\example-fw9_1.pdf"
strOutPDF = strFolder & "\_test_out.pdf"

Set VeryPDFSplitMergeCOM = CreateObject("VeryPDFSplitMergeCOM.com")
VeryPDFSplitMergeCOM.com_PDF_SetCode("XXXXXXXXXXXXXXXXXXXX")
iRet = VeryPDFSplitMergeCOM.com_VerySplitMergeSetParameter("RetainBookmarks", "off")
iRet = VeryPDFSplitMergeCOM.com_VerySplitMergeSetParameter("RetainAcroForms", "On")

iRet = VeryPDFSplitMergeCOM.com_PDF_MergePDFFiles(strPDFFiles, strOutPDF)
MsgBox("Finished the creation of output file.")



'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' Please run install.vbs to register VeryPDFSplitMergeCOM.exe COM into your system first
'
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Set fso = CreateObject("Scripting.FileSystemObject") 
strFolder = fso.GetParentFolderName(wscript.ScriptFullName) 

strCoverPage = strFolder & "\example-fw9_1.pdf"
strReport = strFolder & "\testcmd.pdf"
strMergedReport = strFolder & "\_test_out.pdf"

Set VeryPDFSplitMergeCOM = CreateObject("VeryPDFSplitMergeCOM.com")
VeryPDFSplitMergeCOM.com_PDF_SetCode("XXXXXXXXXXXXXXXXXXXX")
iRet = VeryPDFSplitMergeCOM.com_VerySplitMergeSetParameter("RetainBookmarks", "off")
iRet = VeryPDFSplitMergeCOM.com_VerySplitMergeSetParameter("RetainAcroForms", "On")

fso.CopyFile strCoverPage, strMergedReport, True
iRet = VeryPDFSplitMergeCOM.com_VeryAppendPDF(strMergedReport, strReport)
iPageCount = VeryPDFSplitMergeCOM.com_VeryGetPDFFilePageCount(strMergedReport)
MsgBox(strMergedReport & " is contain " & iPageCount & " pages.")

strExtractedReport = strFolder & "\_test_extraction_out.pdf"
strCmd = """" & strReport & ",2-5"" """ & strExtractedReport & """"
MsgBox(strCmd)

iRet = VeryPDFSplitMergeCOM.com_VerySplitMergePDF(strCmd)
iPageCount = VeryPDFSplitMergeCOM.com_VeryGetPDFFilePageCount(strExtractedReport)
MsgBox(strExtractedReport & " is contain " & iPageCount & " pages.")

Related Posts