MDMerge

<< Click to Display Table of Contents >>

Navigation:  Programming Mechworks PDM > DBWCommandShell > Commands Reference > NeutralFormat >

MDMerge

Description

It merges multiple PDF files into a single multi-page PDF.

Syntax

call DBWShell("MDMerge inputPDForTXT [,pageOptions] outputPDF appendFlag [bookmarkCode]")

Parameters

inputPDForTXT

The PDF to be merged into the outputPDF
Bulk input
It is possible to use a .txt file as inputPDForTXT for merging several PDF files into one PDF file.
The text file must contain the filenames of the PDF files that need to be merged, one filename per line.

pageOptions

Optional. A string specifying the page range to be outputted into the merged PDF file – the syntax is explained with samples in the following table:

value

description

example

2

Merge page number 2

inputPDForTXT = "C:\\in.pdf*2"

2*7

Merge pages 2 and 7

inputPDForTXT = "C:\\in.pdf*2*7"

1-9

Merge pages 1 through 9

inputPDForTXT = "C:\\in.pdf*1-9"

9-1

Merge pages 1 through 9 in reverse order

inputPDForTXT = "C:\\in.pdf*9-1"

8-

Merge pages from 8 to the last page

inputPDForTXT = "C:\\in.pdf*8-"

-8

Merge pages from page 1 to the page 8

inputPDForTXT = "C:\\in.pdf*-8"

outputPDF

The resulting merged PDF file

appendFlag

0: create new
1: append to existing

bookmarkCode

Optional.

value

description

1

Use short filename as bookmarks

2

Use full filename as bookmarks

3

Use short filename without suffix as bookmarks

4

Read bookmarks and filenames from txt file; the txt file format is as follows:
Bookmark→<Bookmark #1>
<PDF file #1>
Bookmark→<Bookmark #2>
<PDF file #2>
Bookmark→<Bookmark #3>
<PDF file #3>

Examples

Inline command

sub main

 DBWInit(TRUE)
 DBWShell("MDMerge C:\PdfInput1.PDF,1 C:\PdfMerge.PDF 0")
 DBWShell("MDMerge C:\PdfInput2.PDF C:\PdfMerge.PDF 1")
end sub

Bulk input

Bulkmerge.txt:

E:\test\PDF\0000434_00.SLDDRW.3.PDF*1

E:\test\PDF\0061002354.SLDDRW.00.PDF*2
E:\test\PDF\01825-0806-0003-S01.SLDDRW.1.PDF
empty line

The script will be written as follows:

sub main

 DBWInit(TRUE)
 DBWShell("MDMerge C:\bulkmerge.txt C:\PdfMerge.PDF 0")
end sub

It is possible to merge hundreds of PDF files into one PDF file easily with this method.

Bookmarks

Bookmark.txt:

Bookmark->0000434_00.SLDDRW

E:\test\PDF\0000434_00.SLDDRW.3.PDF
Bookmark->0061002354.SLDDRW
E:\test\PDF\0061002354.SLDDRW.00.PDF
Bookmark->01825-0806-0003-S01.SLDDRW
E:\test\PDF\01825-0806-0003-S01.SLDDRW.1.PDF
empty line

The script will be written as follows:

sub main

 DBWInit(TRUE)
 DBWShell("MDMerge C:\Bookmark.txt C:\PdfMerge.PDF 0 4")
end sub

Auto-creation of bookmarks

Bookmark.txt:

E:\test\PDF\0000434_00.SLDDRW.3.PDF

E:\test\PDF\0061002354.SLDDRW.00.PDF
E:\test\PDF\01825-0806-0003-S01.SLDDRW.1.PDF
empty line

The script will be written as follows:

sub main

        DBWInit(TRUE)
        DBWShell("MDMerge C:\Bookmark.txt C:\PdfMerge.PDF 0 1")
end sub