I do the following on my scanner with automatic document feeder (ADF):
- Scan odd pages from 1st to last, store as first pdf file
- Flip the stack of pages and scan even pages from last to 2nd, store as second pdf file
- Merge both files with a little PowerShell script that uses the PDFSharp library (the binaries need to be copied side-by-side with the PowerShell script)
Here's my script - a little rough - but work's for me. I hope it can help.
# Not entirely my code, this is based on Mike Pfeiffer - http://mikepfeiffer.net/2010/03/how-to-merge-pdf-files-using-powershell-and-pdfsharp/
# Requires PDFSharp assembly libraries http://sourceforge.net/projects/pdfsharp/
# You need to load the assembly before you can use the function
#
# Usage:
# Merge-PDF -firstPdfPath 1.pdf -secondPdfPath 2.pdf -targetPdfPath merged.pdf
[CmdletBinding()]
param
(
$firstPdfPath,
$secondPdfPath,
$targetPdfPath
)
begin {
$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition
Add-Type -Path .\PdfSharp.dll
}
process {
$output = New-Object PdfSharp.Pdf.PdfDocument
$PdfReader = [PdfSharp.Pdf.IO.PdfReader]
$PdfDocumentOpenMode = [PdfSharp.Pdf.IO.PdfDocumentOpenMode]
$firstPdfPath = Join-Path $PSScriptRoot $firstPdfPath
$secondPdfPath = Join-Path $PSScriptRoot $secondPdfPath
$targetPdfPath = Join-Path $PSScriptRoot $targetPdfPath
$firstPdf = New-Object PdfSharp.Pdf.PdfDocument
$firstPdf = $PdfReader::Open($firstPdfPath, $PdfDocumentOpenMode::Import)
$secondPdf = New-Object PdfSharp.Pdf.PdfDocument
$secondPdf = $PdfReader::Open($secondPdfPath, $PdfDocumentOpenMode::Import)
$secondIndex = $secondPdf.Pages.Count-1
foreach($page in $firstPdf.Pages) {
$output.AddPage($page)
if ($secondIndex -ge 0) {
$output.AddPage($secondPdf.Pages[$secondIndex--])
}
}
$output.Save($targetPdfPath)
}
end {
}