PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Tue Jul 09, 2024 4:14 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Wed May 04, 2011 9:06 pm 
Offline

Joined: Fri Dec 18, 2009 2:17 pm
Posts: 5
Hi I am using PDFSharp v1.31 to create PDFs based on user input. This work well. Later in the process I need to open this PDF and add a Case Number. When I try to save the PDF after writing the case number I get the message: 'The document cannot be modified.'
Is it possible to alter a PDFSharp created docuemnt once it has been saved originally?

Thanks


Top
 Profile  
Reply with quote  
PostPosted: Thu May 05, 2011 7:03 am 
Offline
PDFsharp Guru
User avatar

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

Do you open the document with the Modify flag?

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Tue May 10, 2011 5:56 pm 
Offline

Joined: Fri Dec 18, 2009 2:17 pm
Posts: 5
Sorry for the delay i've been out of touch for several days.
Ashamed to say I did not try opening with Modify flag. Will give it a try.

Thanks


Top
 Profile  
Reply with quote  
PostPosted: Tue May 10, 2011 6:28 pm 
Offline

Joined: Fri Dec 18, 2009 2:17 pm
Posts: 5
Opening with Modify flag does allow mw to edit the document. However, I now receive the message:
'Object type transformation must not be done with direct objects.'


Top
 Profile  
Reply with quote  
PostPosted: Wed May 11, 2011 10:13 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
Ignore that message - comes in DEBUG build only.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Mon Jun 06, 2011 8:17 pm 
Offline

Joined: Fri Dec 18, 2009 2:17 pm
Posts: 5
I have been ignoring this on my development pc without an issue. However I just deployed the site to our test web server and it appears that the page is hanging up where it opens the previously created pdf and writes a case number in the pdf document. The code follows:

FinalDoc = PdfSharp.Pdf.IO.PdfReader.Open(ConfigurationManager.AppSettings("UploadTemp") & "\" & lcEFileRec.FileName, PdfSharp.Pdf.IO.PdfDocumentOpenMode.Modify)

page = FinalDoc.Pages(0)

gfx = XGraphics.FromPdfPage(page)

gfx.DrawString(lcCase.CaseNumber, fontTextBold, XBrushes.Black, New XRect(360, 115, page.Width.Point, page.Height.Point), XStringFormats.TopLeft)

FinalDoc.Save(ConfigurationManager.AppSettings("UploadTemp") & "\" & lcEFileRec.FileName)


If I comment out the line:
gfx.DrawString(lcCase.CaseNumber, fontTextBold, XBrushes.Black, New XRect(360, 115, page.Width.Point, page.Height.Point), XStringFormats.TopLeft)
it works.

Any ideas?


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 07, 2011 7:19 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
Use a RELEASE build of the DLLs or remove the Debug.Assert.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 07, 2011 4:59 pm 
Offline

Joined: Fri Dec 18, 2009 2:17 pm
Posts: 5
Thought that I was using the release build. I have many lines of code like the one causing problems on another page and it works fine. The only difference is that one creates a new docuument the other opens an existing document(the one previously created) to add something to it.

Maybe I'm confused by using the Release Build. When I build my project I have Release specifed on the compile tab of the project properties window.


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 32 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