Hello,
I want to merge a lot of PDF files - so PDFsharp seems perfect and I like powershell so I gave it a try!
I included the latest dll via
Code:
Add-Type -Path Y:\path\PDFsharp-MigraDocFoundation-Assemblies-1_32\GDI+\PdfSharp.dll
Later on I used it in a function (so all variables are set - checked via ISE debugging):
Code:
$output = New-Object PdfSharp.Pdf.PdfDocument
$PdfReader = [PdfSharp.Pdf.IO.PdfReader]
$PdfDocumentOpenMode = [PdfSharp.Pdf.IO.PdfDocumentOpenMode]
$input = New-Object PdfSharp.Pdf.PdfDocument
$tf = ($proposal+"*")
Get-ChildItem -path $path_a -include $tf |
foreach-object `
{
echo ("Abstract read..."+$_.fullname)
$input = $PdfReader::Open($_.fullname, $PdfDocumentOpenMode::Import) <= exception thrown here
$input.Pages | %{$output.AddPage($_)}
}
I get the following exception (sorry that it is german but I think you get the idea):
Code:
Ausnahme beim Aufrufen von "Open" mit 2 Argument(en): "Fehler bei der Anforderung des Berechtigungstyps "System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"."
Bei proposal.ps1:25 Zeichen:34
+ $input = $PdfReader::Open <<<< ($_.fullname, $PdfDocumentOpenMode::Import)
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
What is the issue with this? Also tried it without the openmode, didn't work either.
Any help would be appreciated,
Alex