| PDFsharp & MigraDoc Forum https://forum.pdfsharp.net/ |
|
| Powershell issue https://forum.pdfsharp.net/viewtopic.php?f=2&t=2159 |
Page 1 of 1 |
| Author: | raven1103 [ Thu Oct 04, 2012 3:31 pm ] |
| Post subject: | Powershell issue |
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 |
|
| Author: | Thomas Hoevel [ Thu Oct 04, 2012 4:15 pm ] |
| Post subject: | Re: Powershell issue |
Hi! Have you tried running the PowerShell script as Administrator? Is the PDF document on a network drive? See also here: http://dotnetzip.codeplex.com/discussions/233140 |
|
| Author: | raven1103 [ Fri Oct 05, 2012 8:20 am ] |
| Post subject: | Re: Powershell issue |
Hi Thomas, found a solution also working as normal user: set execution policy to bypass and installed PowerShell V3 - works like a charm! My remaining issue is to supress the messages when I use Code: $input.Pages | %{$output.AddPage($_)} then I get Code: Key Value --- ----- /Parent 3 0 R /Type /Page /MediaBox [0 0 595.28 841.89] /Resources 4 0 R /Contents 7 0 R Any ideas on this? Btw, great job! Regards, Alex |
|
| Author: | Thomas Hoevel [ Mon Oct 08, 2012 7:41 am ] |
| Post subject: | Re: Powershell issue |
raven1103 wrote: My remaining issue is to supress the messages Messages? Which messages?
|
|
| Author: | raven1103 [ Mon Oct 08, 2012 6:58 pm ] |
| Post subject: | Re: Powershell issue |
After the mentioned code line I get the ouput (Key/Value) on the screen - seems to me like debug/info messages Anyway, the PDF is comined ok - would just be nice to get rid of them for better overview. Regards, Alex |
|
| Author: | Thomas Hoevel [ Tue Oct 09, 2012 8:30 am ] |
| Post subject: | Re: Powershell issue |
raven1103 wrote: seems to me like debug/info messages The Release build of the assemblies should not produce any debug messages.
|
|
| Page 1 of 1 | All times are UTC |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|