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

Filling in form fields returns a Null Exception
https://forum.pdfsharp.net/viewtopic.php?f=2&t=1682
Page 1 of 1

Author:  psiomicron [ Sun Jun 05, 2011 5:06 am ]
Post subject:  Filling in form fields returns a Null Exception

I tried using the code in the examples but I get a Null Exception error on

Code:
PdfAcroField.PdfAcroFieldCollection fields = form.Fields; //or  document.AcroForm.Fields.Names;


I have also tried the following code but I still return a null exception:
Code:
string fileN4 = TextBox1.Text + " LOG.pdf";

  File.Copy(Path.Combine(textBox4.Text + "\\", fileN4),
               Path.Combine(Directory.GetCurrentDirectory(), fileN4), true);

  // Open the file
  PdfDocument document = PdfReader.Open(fileN4, PdfDocumentOpenMode.Modify);

  PdfTextField currentField = (PdfTextField)(document.AcroForm.Fields["<CASENUM>"]);
  //const
        string caseName = TextBox1.Text;
  PdfString caseNamePdfStr = new PdfString(caseName);

  //set the value of this field
  currentField.Value = caseNamePdfStr;


  // Save the document...
  document.Save(fileN4);


Any help would be great!

Author:  psiomicron [ Sun Jun 05, 2011 6:59 pm ]
Post subject:  Re: Filling in form fields returns a Null Exception

bump

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