EvotecIT / PSWritePDF

PowerShell Module to create, edit, split, merge PDF files on Windows / Linux and MacOS
GNU Affero General Public License v3.0
190 stars 21 forks source link

Not working on Mac Powershell 7.0.3 #8

Closed tekmun closed 4 years ago

tekmun commented 4 years ago

Hi, I run this command on the latest Mac OS with the latest Powershell (just installed using brew) Merge-PDF -InputFile .\1.pdf -OutputFile .\output.pdf The command completed successfully but no output.pdf file is generated in local directory.

PrzemyslawKlys commented 4 years ago

Is it just a typo or you put 1 file into InputFile?

$FilePath1 = "$PSScriptRoot\Input\OutputDocument0.pdf"
$FilePath2 = "$PSScriptRoot\Input\OutputDocument1.pdf"

$OutputFile = "$PSScriptRoot\Output\OutputDocument.pdf" # Shouldn't exist / will be overwritten

Merge-PDF -InputFile $FilePath1, $FilePath2 -OutputFile $OutputFile
tekmun commented 4 years ago

Hi,

I have written a ps script. On PC, it works flawlessly. On Mac, it doesn't.

param( [Parameter(Mandatory=$true)] [int] $stoppage )

$outputfile = "$PSScriptRoot\40.Day.2020_English.pdf" $inputfiles = '' for ($page = 1; $page -le $stoppage; $page++) { if ($inputfiles -ne '') { $inputfiles += ',' } $inputfiles += "$PSScriptRoot\PDF\$page.pdf" } $command = "Merge-PDF -InputFile $inputfiles -OutputFile $outputfile" Invoke-Expression $command

PrzemyslawKlys commented 4 years ago

Can you copy/paste it properly into GitHub. But by the looks of it you're doing some funky stuff with it like using:

Can't you use a normal array without Invoke-Expression? That's asking for trouble. I'm pretty sure -InputFile thinks you're passing one file and not multiple files the way you do it.

tekmun commented 4 years ago

I found the issue. On Mac, the character used to separate directory is "/". On Windows, it is "\". What I have done is to use $IsMacOS function to replace "\" with "/".