I need to know the place inside iTextSharp where the exception is thrown. If 
possible use the CVS version.

Paulo 

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of David Saier
> Sent: Wednesday, July 12, 2006 5:19 PM
> To: Post all your questions about iText here
> Subject: Re: [iText-questions] Adding a signature to an 
> encryptedpdfdocument.
> 
> Thanks again for the reply. After making that change I am 
> getting a new exception:
>  
> System.InvalidCastException was unhandled
>   Message="Unable to cast object of type 
> 'iTextSharp.text.pdf.PdfNull' to type 
> 'iTextSharp.text.pdf.PdfIndirectReference'."
>   Source="iTextSharpSign"
>   StackTrace:
>        at iTextSharpSign.PDFSigner.Sign(String SigReason, 
> String SigContact, String SigLocation, Boolean visible) in 
> D:\Documents\PDFcreator\PDFcreator\iTextSharpSign\PDFSigner.cs
> :line 298
>        at iTextSharpSign.Form1.button1_Click(Object sender, 
> EventArgs e) in 
> D:\Documents\PDFcreator\PDFcreator\iTextSharpSign\Form1.cs:line 109
>        at System.Windows.Forms.Control.OnClick(EventArgs e)
>        at System.Windows.Forms.Button.OnClick(EventArgs e)
>        at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
>        at System.Windows.Forms.Control.WmMouseUp(Message& m, 
> MouseButtons button, Int32 clicks)
>        at System.Windows.Forms.Control.WndProc(Message& m)
>        at System.Windows.Forms.ButtonBase.WndProc(Message& m)
>        at System.Windows.Forms.Button.WndProc(Message& m)
>        at 
> System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
>        at 
> System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
>        at 
> System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr 
> hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
>        at 
> System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
>        at 
> System.Windows.Forms.Application.ComponentManager.System.Windo
> ws.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessage
> Loop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
>        at 
> System.Windows.Forms.Application.ThreadContext.RunMessageLoopI
> nner(Int32 reason, ApplicationContext context)
>        at 
> System.Windows.Forms.Application.ThreadContext.RunMessageLoop(
> Int32 reason, ApplicationContext context)
>        at System.Windows.Forms.Application.Run(Form mainForm)
>        at iTextSharpSign.Program.Main() in 
> D:\Documents\PDFcreator\PDFcreator\iTextSharpSign\Program.cs:line 17
>        at System.AppDomain.nExecuteAssembly(Assembly 
> assembly, String[] args)
>        at System.AppDomain.ExecuteAssembly(String 
> assemblyFile, Evidence assemblySecurity, String[] args)
>        at 
> Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
>        at 
> System.Threading.ThreadHelper.ThreadStart_Context(Object state)
>        at 
> System.Threading.ExecutionContext.Run(ExecutionContext 
> executionContext, ContextCallback callback, Object state)
>        at System.Threading.ThreadHelper.ThreadStart()
> Thank you,
> David
> 
> Paulo Soares <[EMAIL PROTECTED]> wrote:
> 
>       It's a porting bug. In PdfEncryption.cs replace:
>       
>       public PdfEncryption(PdfEncryption enc) : base() {
>       
>       with
>       
>       public PdfEncryption(PdfEncryption enc) : this() {
>       
>       Paulo 
>       
>       > -----Original Message-----
>       > From: [EMAIL PROTECTED] 
>       > [mailto:[EMAIL PROTECTED] On 
>       > Behalf Of David Saier
>       > Sent: Wednesday, July 12, 2006 3:03 PM
>       > To: Post all your questions about iText here
>       > Subject: Re: [iText-questions] Adding a signature to an 
>       > encrypted pdfdocument.
>       > 
>       > Hi,
>       > 
>       > Thanks for the reply, this is the stack trace I get from the 
>       > exception:
>       > System.NullReferenceException was unhandled
>       > Message="Object reference not set to an instance of 
> an object."
>       > Source="iTextSharpSign"
>       > StackTrace:
>       > at iTextSharpSign.PDFSigner.Sign(String SigReason, String 
>       > SigContact, String SigLocation, Boolean visible) in 
>       > D:\Documents\PDFcreator\PDFcreator\iTextSharpSign\PDFSigner.cs
>       > :line 298
>       > at iTextSharpSign.Form1.button1_Click(Object sender, 
>       > EventArgs e) in 
>       > 
> D:\Documents\PDFcreator\PDFcreator\iTextSharpSign\Form1.cs:line 109
>       > at System.Windows.Forms.Control.OnClick(EventArgs e)
>       > at System.Windows.Forms.Button.OnClick(EventArgs e)
>       > at 
> System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
>       > at System.Windows.Forms.Control.WmMouseUp(Message& m, 
>       > MouseButtons button, Int32 clicks)
>       > at System.Windows.Forms.Control.WndProc(Message& m)
>       > at System.Windows.Forms.ButtonBase.WndProc(Message& m)
>       > at System.Windows.Forms.Button.WndProc(Message& m)
>       > at 
>       > 
> System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
>       > at 
>       > 
> System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
>       > at 
>       > System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr 
>       > hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
>       > at 
> System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
>       > at 
>       > System.Windows.Forms.Application.ComponentManager.System.Windo
>       > ws.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessage
>       > Loop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
>       > at 
>       > System.Windows.Forms.Application.ThreadContext.RunMessageLoopI
>       > nner(Int32 reason, ApplicationContext context)
>       > at 
>       > System.Windows.Forms.Application.ThreadContext.RunMessageLoop(
>       > Int32 reason, ApplicationContext context)
>       > at System.Windows.Forms.Application.Run(Form mainForm)
>       > at iTextSharpSign.Program.Main() in 
>       > 
> D:\Documents\PDFcreator\PDFcreator\iTextSharpSign\Program.cs:line 17
>       > at System.AppDomain.nExecuteAssembly(Assembly 
> assembly, String[] args)
>       > at System.AppDomain.ExecuteAssembly(String assemblyFile, 
>       > Evidence assemblySecurity, String[] args)
>       > at 
> Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
>       > at 
> System.Threading.ThreadHelper.ThreadStart_Context(Object state)
>       > at System.Threading.ExecutionContext.Run(ExecutionContext 
>       > executionContext, ContextCallback callback, Object state)
>       > at System.Threading.ThreadHelper.ThreadStart()
>       > 
>       > I didn't think that this was particularly useful so I found 
>       > the exact line that was causing the exception. The line is in 
>       > the SetHashKey Method in PdfEncryption.cs:
>       > 
>       > md5.Initialize();
>       > ...
>       > 
>       > This can be traced back up to PdfStamper.Close() method.
>       > I put a break point at this line and got the stack calls at 
>       > that point:
>       > 
>       > iTextSharpSign.exe!iTextSharp.text.pdf.PdfEncryption.SetHashKe
>       > y(int number = 38, int generation = 0) Line 293 
>       > 
>       > iTextSharpSign.exe!iTextSharp.text.pdf.PdfIndirectObject.PdfIn
>       > directObject(int number = 38, int generation = 0, 
>       > iTextSharp.text.pdf.PdfObject objecti = {Dictionary of type: 
>       > /XObject}, iTextSharp.text.pdf.PdfWriter writer = 
>       > {iTextSharp.text.pdf.PdfStamperImp}) Line 119 + 0xe bytes 
>       > 
>       > iTextSharpSign.exe!iTextSharp.text.pdf.PdfIndirectObject.PdfIn
>       > directObject(int number = 38, iTextSharp.text.pdf.PdfObject 
>       > objecti = {Dictionary of type: /XObject}, 
>       > iTextSharp.text.pdf.PdfWriter writer = 
>       > {iTextSharp.text.pdf.PdfStamperImp}) Line 97 + 0x11 bytes 
>       > 
>       > iTextSharpSign.exe!iTextSharp.text.pdf.PdfWriter.PdfBody.Add(i
>       > TextSharp.text.pdf.PdfObject objecta = {Dictionary of type: 
>       > /XObject}, int refNumber = 38, bool inObjStm = true) Line 355 
>       > + 0x1c bytes 
>       > 
>       > iTextSharpSign.exe!iTextSharp.text.pdf.PdfWriter.PdfBody.Add(i
>       > TextSharp.text.pdf.PdfObject objecta = {Dictionary of type: 
>       > /XObject}, int refNumber = 38) Line 343 + 0xe bytes 
>       > 
>       > iTextSharpSign.exe!iTextSharp.text.pdf.PdfWriter.PdfBody.Add(i
>       > TextSharp.text.pdf.PdfObject objecta = {Dictionary of type: 
>       > /XObject}) Line 292 + 0x1b bytes 
>       > 
>       > iTextSharpSign.exe!iTextSharp.text.pdf.PdfWriter.AddToBody(iTe
>       > xtSharp.text.pdf.PdfObject objecta = {Dictionary of type: 
>       > /XObject}) Line 1866 + 0xc bytes 
>       > 
>       > iTextSharpSign.exe!iTextSharp.text.pdf.PdfWriter.Add(iTextShar
>       > p.text.pdf.PdfImage pdfImage = {Dictionary of type: 
>       > /XObject}, iTextSharp.text.pdf.PdfIndirectReference fixedRef 
>       > = null) Line 991 + 0xa bytes 
>       > 
>       > iTextSharpSign.exe!iTextSharp.text.pdf.PdfWriter.AddDirectImag
>       > eSimple(iTextSharp.text.Image image = {Rectangle: 125x35 
>       > (rot: 0 degrees)}, iTextSharp.text.pdf.PdfIndirectReference 
>       > fixedRef = null) Line 967 + 0x11 bytes 
>       > 
>       > iTextSharpSign.exe!iTextSharp.text.pdf.PdfWriter.AddDirectImag
>       > eSimple(iTextSharp.text.Image image = {Rectangle: 125x35 
>       > (rot: 0 degrees)}) Line 905 + 0xb bytes 
>       > 
>       > iTextSharpSign.exe!iTextSharp.text.pdf.PdfContentByte.AddImage
>       > (iTextSharp.text.Image image = {Rectangle: 125x35 (rot: 0 
>       > degrees)}, float a = 250.0, float b = 0.0, float c = 0.0, 
>       > float d = 75.0, float e = 0.0, float f = 0.0, bool 
>       > inlineImage = false) Line 1211 + 0x10 bytes 
>       > 
>       > iTextSharpSign.exe!iTextSharp.text.pdf.PdfContentByte.AddImage
>       > (iTextSharp.text.Image image = {Rectangle: 125x35 (rot: 0 
>       > degrees)}, float a = 250.0, float b = 0.0, float c = 0.0, 
>       > float d = 75.0, float e = 0.0, float f = 0.0) Line 
> 1133 + 0x1d bytes 
>       > 
>       > iTextSharpSign.exe!iTextSharp.text.pdf.PdfSignatureAppearance.
>       > GetAppearance() Line 329 + 0x79 bytes 
>       > 
>       > iTextSharpSign.exe!iTextSharp.text.pdf.PdfSignatureAppearance.
>       > PreClose(System.Collections.Hashtable exclusionSizes = null) 
>       > Line 732 + 0x11 bytes 
>       > 
>       > iTextSharpSign.exe!iTextSharp.text.pdf.PdfSignatureAppearance.
>       > PreClose() Line 677 + 0x9 bytes 
>       > iTextSharpSign.exe!iTextSharp.text.pdf.PdfStamper.Close() 
>       > Line 189 + 0xa bytes 
>       > iTextSharpSign.exe!iTextSharpSign.PDFSigner.Sign(string 
>       > SigReason = "", string SigContact = "", string SigLocation = 
>       > "", bool visible = true) Line 294 + 0xa bytes 
>       > 
>       > iTextSharpSign.exe!iTextSharpSign.Form1.button1_Click(object 
>       > sender = {Text = "Sign"}, System.EventArgs e = {X = 33 Y = 14 
>       > Button = Left}) Line 109 + 0x61 bytes 
>       > [External Code] 
>       > iTextSharpSign.exe!iTextSharpSign.Program.Main() Line 17 + 
>       > 0x1a bytes 
>       > [External Code] 
>       > 
>       > Thank you
>       > David
>       > 
>       > Paulo Soares wrote:
>       > 
>       > What you're tying is possible because PdfReader(string 
>       > file, byte[] 
>       > ownerPassword) will remove the encryption and will 
>       > allow the PDF to be 
>       > signed. I've no idea where the error comes from as you 
>       > don't show any stack 
>       > strace.
>       > 
>       > Paulo
>       > 
>       > ----- Original Message ----- 
>       > From: "David Saier" 
>       > To: 
>       > Sent: Tuesday, July 11, 2006 9:05 PM
>       > Subject: [iText-questions] Adding a signature to an 
>       > encrypted pdf document.
>       > 
>       > 
>       > Hello,
>       > 
>       > I have been trying to use iText to create a signature 
>       > in an encrypted pdf 
>       > document. Basically I have a pdf document which is 
>       > password encrypted with a 
>       > known owner password, and I want to add a signature to 
>       > it. When I try it it 
>       > gives me an "Object reference set to null" error, 
>       > making me believe the 
>       > problem is in accessing the document. I have gotten my 
>       > code to work if the 
>       > pdf is not encrypted, however this is not an option for 
>       > me, I have to have 
>       > the document locked before I add a signature to it.
>       > 
>       > Using the PdfReader(string file, byte[] ownerPassword) 
>       > constructor for the 
>       > PdfReader I pass into the PdfStamper.CreateSignature 
>       > does not seem to work.
>       > 
>       > Is what I am trying to do possible?
>       > 
>       > Thanks,
>       > David
>       > 
>       > 
>       > ---------------------------------
>       > Yahoo! Music Unlimited - Access over 1 million 
>       > songs.Try it free.
>       > 
>       > 
>       > 
>       > --------------------------------------------------------------
>       > ------------------
>       > 
>       > 
>       > >
>       > > 
>       > --------------------------------------------------------------
>       > -----------
>       > > Using Tomcat but need to do more? Need to support web 
>       > services, security?
>       > > Get stuff done quickly with pre-integrated technology 
>       > to make your job 
>       > > easier
>       > > Download IBM WebSphere Application Server v.1.0.1 
>       > based on Apache Geronimo
>       > > 
>       > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&;
>       > dat=121642
>       > >
>       > 
>       > 
>       > 
>       > --------------------------------------------------------------
>       > ------------------
>       > 
>       > 
>       > > _______________________________________________
>       > > iText-questions mailing list
>       > > [email protected]
>       > > https://lists.sourceforge.net/lists/listinfo/itext-questions
>       > > 
>       > 
>       > 
>       > 
>       > 
>       > --------------------------------------------------------------
>       > -----------
>       > Using Tomcat but need to do more? Need to support web 
>       > services, security?
>       > Get stuff done quickly with pre-integrated technology 
>       > to make your job easier
>       > Download IBM WebSphere Application Server v.1.0.1 based 
>       > on Apache Geronimo
>       > 
>       > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&;
>       > dat=121642
>       > _______________________________________________
>       > iText-questions mailing list
>       > [email protected]
>       > https://lists.sourceforge.net/lists/listinfo/itext-questions
>       > 
>       > 
>       > 
>       > ________________________________
>       > 
>       > Do you Yahoo!?
>       > Everyone is raving about the all-new Yahoo! Mail Beta. 
>       > > ahoo.com/handraisers> 
>       > 
>       
>       
>       Aviso Legal:
>       Esta mensagem é destinada exclusivamente ao 
> destinatário. Pode conter informação confidencial ou 
> legalmente protegida. A incorrecta transmissão desta mensagem 
> não significa a perca de confidencialidade. Se esta mensagem 
> for recebida por engano, por favor envie-a de volta para o 
> remetente e apague-a do seu sistema de imediato. É proibido a 
> qualquer pessoa que não o destinatário de usar, revelar ou 
> distribuir qualquer parte desta mensagem. 
>       
>       Disclaimer:
>       This message is destined exclusively to the intended 
> receiver. It may contain confidential or legally protected 
> information. The incorrect transmission of this message does 
> not mean the loss of its confidentiality. If this message is 
> received by mistake, please send it back to the sender and 
> delete it from your system immediately. It is forbidden to 
> any person who is not the intended receiver to use, 
> distribute or copy any part of this message.
>       
>       
>       
>       
> --------------------------------------------------------------
> -----------
>       Using Tomcat but need to do more? Need to support web 
> services, security?
>       Get stuff done quickly with pre-integrated technology 
> to make your job easier
>       Download IBM WebSphere Application Server v.1.0.1 based 
> on Apache Geronimo
>       
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&;
> dat=121642
>       _______________________________________________
>       iText-questions mailing list
>       [email protected]
>       https://lists.sourceforge.net/lists/listinfo/itext-questions
>       
> 
> 
> ________________________________
> 
> Sneak preview the all-new Yahoo.com 
> <http://us.rd.yahoo.com/evt=40762/*http://www.yahoo.com/previe
> w> . It's not radically different. Just radically better. 
> 


Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter 
informação confidencial ou legalmente protegida. A incorrecta transmissão desta 
mensagem não significa a perca de confidencialidade. Se esta mensagem for 
recebida por engano, por favor envie-a de volta para o remetente e apague-a do 
seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de 
usar, revelar ou distribuir qualquer parte desta mensagem. 

Disclaimer:
This message is destined exclusively to the intended receiver. It may contain 
confidential or legally protected information. The incorrect transmission of 
this message does not mean the loss of its confidentiality. If this message is 
received by mistake, please send it back to the sender and delete it from your 
system immediately. It is forbidden to any person who is not the intended 
receiver to use, distribute or copy any part of this message.


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to