PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Fri Jul 05, 2024 7:28 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Mon Mar 31, 2008 1:31 pm 
Offline

Joined: Mon Mar 31, 2008 1:26 pm
Posts: 1
Hi all,

Ive been writing a vb.net plugin that processes two xml files and outputs two pdfs along with two updated xmls. Everything works well until I save the second generated pdf to a memorystream in order to convert it to base64 to insert into the second updated xml.

The error raised is: "The dictionary already has a stream."

BTW: The first pdf is pdfSharp only, the second is a MigraDoc document.

Has anyone seen this error before? Any ideas on a way around?

TIA.


Top
 Profile  
Reply with quote  
PostPosted: Thu Oct 22, 2009 8:37 am 
Offline

Joined: Wed Oct 07, 2009 7:17 am
Posts: 5
I am getting the same error - Anyone have any idea how to resolve this


Top
 Profile  
Reply with quote  
PostPosted: Thu Oct 22, 2009 8:45 am 
Offline

Joined: Wed Oct 07, 2009 7:17 am
Posts: 5
Resolved this - Caused by not creating a new occurrence of the class for each document


Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 31, 2011 4:45 pm 
Offline

Joined: Mon Jan 24, 2011 11:46 am
Posts: 5
Adria,

I know this was a long time ago but do you remember what class you need to create a new isntance of?

I'd like to create a Migradoc, add pages and then do two steps:
1) save it to a memory stream (for embedding in to another file)
2) save it to a file.

I get the dictionary error if I use the same pdf object for both. I'd like to do this to save cpu cycles in creating two identical documents!

Matt


Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 31, 2011 5:28 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
Performance will be better if step 2 uses the memory stream created in step 1 to create the file.

See also here:
viewtopic.php?p=4107#p4107

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Tue Feb 01, 2011 10:03 am 
Offline

Joined: Mon Jan 24, 2011 11:46 am
Posts: 5
Thanks Thomas.

I probably over simplified my problem. In between step 1 and 2 I want to add a watermark to the report. In the end I figured I could save v1 to a memory stream. Use pdfReader to re-load the doc from the same memory stream, then add the watermark and do the save v2 (to a file).

BTW for anyone looking the vb.net code to save the memory stream to a file is:
Code:
'tempstr1 is the result of saving the pdf to a memory stream
            Dim writeStream As FileStream
            Try
                writeStream = New FileStream("c:\testBinary.pdf", FileMode.Create)
                Dim writeBinay As New BinaryWriter(writeStream)
                tempstr1.Position = 0
                writeBinay.Write(tempstr1.ToArray())
                writeBinay.Close()
            Catch ex As Exception
                MsgBox(ex.ToString)
            End Try


Matt


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: Google [Bot] and 52 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