PDFsharp & MigraDoc Forum

PDFsharp - A .NET library for processing PDF & MigraDoc - Creating documents on the fly
It is currently Tue Dec 09, 2025 8:49 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules

Also see our new Tailored Support & Services site.



Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Powershell issue
PostPosted: Thu Oct 04, 2012 3:31 pm 
Offline

Joined: Thu Oct 04, 2012 3:23 pm
Posts: 3
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


Top
 Profile  
Reply with quote  
 Post subject: Re: Powershell issue
PostPosted: Thu Oct 04, 2012 4:15 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3139
Location: Cologne, Germany
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

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject: Re: Powershell issue
PostPosted: Fri Oct 05, 2012 8:20 am 
Offline

Joined: Thu Oct 04, 2012 3:23 pm
Posts: 3
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


Top
 Profile  
Reply with quote  
 Post subject: Re: Powershell issue
PostPosted: Mon Oct 08, 2012 7:41 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3139
Location: Cologne, Germany
raven1103 wrote:
My remaining issue is to supress the messages
Messages? Which messages?

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject: Re: Powershell issue
PostPosted: Mon Oct 08, 2012 6:58 pm 
Offline

Joined: Thu Oct 04, 2012 3:23 pm
Posts: 3
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


Top
 Profile  
Reply with quote  
 Post subject: Re: Powershell issue
PostPosted: Tue Oct 09, 2012 8:30 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3139
Location: Cologne, Germany
raven1103 wrote:
seems to me like debug/info messages
The Release build of the assemblies should not produce any debug messages.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 239 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group