PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Editing a PDFSharp cretaed PDF
https://forum.pdfsharp.net/viewtopic.php?f=2&t=1645
Page 1 of 1

Author:  vaughnis [ Wed May 04, 2011 9:06 pm ]
Post subject:  Editing a PDFSharp cretaed PDF

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

Author:  Thomas Hoevel [ Thu May 05, 2011 7:03 am ]
Post subject:  Re: Editing a PDFSharp cretaed PDF

Hi!

Do you open the document with the Modify flag?

Author:  vaughnis [ Tue May 10, 2011 5:56 pm ]
Post subject:  Re: Editing a PDFSharp cretaed PDF

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

Author:  vaughnis [ Tue May 10, 2011 6:28 pm ]
Post subject:  Re: Editing a PDFSharp cretaed PDF

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.'

Author:  Thomas Hoevel [ Wed May 11, 2011 10:13 am ]
Post subject:  Re: Editing a PDFSharp cretaed PDF

Ignore that message - comes in DEBUG build only.

Author:  vaughnis [ Mon Jun 06, 2011 8:17 pm ]
Post subject:  Re: Editing a PDFSharp cretaed PDF

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?

Author:  Thomas Hoevel [ Tue Jun 07, 2011 7:19 am ]
Post subject:  Re: Editing a PDFSharp cretaed PDF

Use a RELEASE build of the DLLs or remove the Debug.Assert.

Author:  vaughnis [ Tue Jun 07, 2011 4:59 pm ]
Post subject:  Re: Editing a PDFSharp cretaed PDF

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.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/