PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Fri Dec 15, 2017 8:23 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: AddPage Exception
PostPosted: Tue Nov 21, 2017 9:22 pm 
Offline

Joined: Tue Nov 21, 2017 8:56 pm
Posts: 2
Exception:The given key was not present in the dictionary.
StackTrace: at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at PdfSharp.Pdf.Advanced.PdfImportedObjectTable.get_Item(PdfObjectID externalID)
at PdfSharp.Pdf.PdfObject.FixUpObject(PdfImportedObjectTable iot, PdfDocument owner, PdfObject value)
at PdfSharp.Pdf.PdfObject.FixUpObject(PdfImportedObjectTable iot, PdfDocument owner, PdfObject value)
at PdfSharp.Pdf.PdfObject.ImportClosure(PdfImportedObjectTable importedObjectTable, PdfDocument owner, PdfObject externalObject)
at PdfSharp.Pdf.PdfPages.CloneElement(PdfPage page, PdfPage importPage, String key, Boolean deepcopy)
at PdfSharp.Pdf.PdfPages.ImportExternalPage(PdfPage importPage)
at PdfSharp.Pdf.PdfPages.Insert(Int32 index, PdfPage page)
at PdfSharp.Pdf.PdfPages.Add(PdfPage page)
at PdfSharp.Pdf.PdfDocument.AddPage(PdfPage page)
at Tickets.Module1.mergePDFS(IEnumerable`1 docs) in E:\Apps\PDF\Tickets\Tickets\Module1.vb:line 87
at Tickets.Module1.Main() in E:\Apps\PDF\Tickets\Tickets\Module1.vb:line 31
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)
at System.Activator.CreateInstance(ActivationContext activationContext)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

Code:


Function mergePDFS(docs As IEnumerable(Of String)) As PdfSharp.Pdf.PdfDocument


Dim merged As New PdfSharp.Pdf.PdfDocument
merged.Options.CompressContentStreams = True
merged.Options.NoCompression = False




For Each doc In docs.Distinct


Dim rdr = PdfSharp.Pdf.IO.PdfReader.Open(doc, PdfSharp.Pdf.IO.PdfDocumentOpenMode.Import)
For Each pg In rdr.Pages.Cast(Of PdfSharp.Pdf.PdfPage)().ToArray

merged.AddPage(pg)<-----Exception here
Next



Next


Return merged



End Function

<package id="PdfSharp" version="1.32.3057.0" targetFramework="net462" />


Top
 Profile  
Reply with quote  
 Post subject: Re: AddPage Exception
PostPosted: Wed Nov 22, 2017 8:51 am 
Offline
empira Employee
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 2740
Location: Cologne, Germany
Hi!

Does the issue also occur with the latest version of PDFsharp 1.50?

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject: Re: AddPage Exception
PostPosted: Wed Nov 22, 2017 1:02 pm 
Offline

Joined: Tue Nov 21, 2017 8:56 pm
Posts: 2
Actually. Found out the PDF generation was messed up. I did try the latest version and it said it couldn't read the file. Something about missing eostream or something. So it was a bad PDF. The signature image was placed twice instead of company logo at top and signature at bottom.


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

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 8 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:  
Powered by phpBB® Forum Software © phpBB Group