0

string docuAddr = @"C:\Users\psimmon\source\repos\PDFTESTAPP\PDFTESTAPP\TempForms\forms-www.courts.state.co.us-Forms-PDF-JDF1117.pdf"; byte[] bytes = Encoding.Unicode.GetBytes(docuAddr);

PdfLoadedDocument loadedDocument = new PdfLoadedDocument(bytes, true);---blows here PdfLoadedForm myForm = loadedDocument.Form; PdfLoadedFormFieldCollection fields = myForm.Fields;

not sure what I have done wrong here, but the PDF file is opening, either in a browser or a fileexployer window. so it has to be me, guessed at most of this, all you very smart folks, I could use your gray matter. forgive my stupidity.

  • using iTextSharp.text.pdf; using Syncfusion.Pdf; using Syncfusion.Pdf.Parsing; using System.Linq; using System.Text; sorry forgot to show my usings – peter g simmon Aug 31 '22 at 12:46
  • I have been able to extract all the field names from the PDF-Original document. There are still a few fields I can not seem to identify via the TEXT NAME. These fields have three different characters in their name which is not on the Keyboard, squareRoot, delta, pie. anybody got a keyboard replacement for them?? also having trouble setting ANY fields value. this should set a field- to the value of -10_2- does the _ matter? it should all be text? i think? pdfFormFields.SetField("JDF 1117.10_2(0)", "10_2"); – peter g simmon Aug 31 '22 at 19:36
  • 1
    Your `bytes` contain the Unicode encoding of the PDF file path and name. But it should contain the bytes of the file itself. Use `File.ReadAllBytes` instead of `Encoding.Unicode.GetBytes`. – mkl Sep 01 '22 at 14:22

1 Answers1

-1

The reported exception “could not find valid signature (%PDF-)” may occurs due to the file is not a PDF document. We suspect it seems the other format files are saved with the “.pdf” extension. We could not open and repair this type of document on our end, we have already added the details in our documentation,

Please find some of the following corrupted error messages that cannot be repaired: UG: https://help.syncfusion.com/file-formats/pdf/open-and-save-pdf-file-in-c-sharp-vb-net#possible-error-messages-of-invalid-pdf-documents-while-loading

If you want to find this type of corrupted document, Syncfusion PDF Library provides support to check and report whether the existing PDF document is corrupted or not with corruption details and structure-level syntax errors.

UG: https://help.syncfusion.com/file-formats/pdf/working-with-document#find-corrupted-pdf-document

Blog: https://www.syncfusion.com/blogs/post/how-to-find-corrupted-pdf-files-in-c-sharp.aspx

KB: https://www.syncfusion.com/kb/9686/how-to-identify-the-corrupted-pdf-document-using-c-and-vb-net

Dharman
  • 30,962
  • 25
  • 85
  • 135
gowtham raj
  • 187
  • 2