Please give a brief summary of your issue:
(Think of this as an email subject)
Error while importing FormData into PDF
Please describe your issue and provide steps to reproduce it:
(The more descriptive your answer, the faster we are able to help you)
I wanted to import XFDF string to PDF document.
Below code i have tried with
val file = createNewFile()
// add blank pdf in filepath
mPdfDoc = PDFDoc(file?.absolutePath)
val xfdf_string = xfdfSample
val fdf_doc = FDFDoc.createFromXFDF(xfdf_string)
mPdfDoc?.fdfMerge(fdf_doc)
mPdfViewCtrl?.doc = mPdfDoc
// Creating new Pdf file:
fun createNewFile():String{
try {
val rootPath: String = requireContext().cacheDir
.absolutePath.toString() + “/XFDF/”
val root = File(rootPath)
if (!root.exists()) {
root.mkdirs()
}
val f = File(rootPath + "sample.pdf")
if (f.exists()) {
f.delete()
}
f.createNewFile()
val out = FileOutputStream(f)
out.flush()
out.close()
return f
} catch (e: java.lang.Exception) {
e.printStackTrace()
}
}
I am facing the error like,
"Exception:
Message: PDF header not found. The file is not a valid PDF document.
Conditional expression: false
Filename : Parser.cpp
Function : SkipHeader
Linenumber : 1163
Error code : 0
"
I am following something wrong. Please correct me with correct approach.
Thanks in Advance.
Please provide a link to a minimal sample where the issue is reproducible:
PDF header not found. The file is not a valid PDF document.
means that you are passing a non-PDF file to the PDFDoc constructor. Please double check exactly what you are passing into the PDFDoc constructors (check the binary/hex data perhaps).
Note that XFDF is not a PDF file.
If you are still stuck, then please provide the exact PDF file you are trying to open.
Also confirm the exact line of code that throws the exception.
I resolved to fix the crash while loading pdf. But, I am unable to see the expected result after importing xfdf string into PDF.
I am sending here below with all details. Please assist me what am i doing wrong.
Here is my code:
val file = Utils.copyResourceToLocal(activity, resourceId, fileName, “.pdf”)
mPdfDoc = PDFDoc(file.absolutePath)
// XFDF loading:
val xfdf_string = xfdfSample
val fdf_doc = FDFDoc.createFromXFDF(xfdf_string)
mPdfDoc?.fdfMerge(fdf_doc)
mPdfViewCtrl?.doc = mPdfDoc.
Here, I am trying to import xfdf string ( given in attachment ) into “inspection_sample_pdf” from attachment. I have attached the attachment of expected result & how this is showing in PDFTron.
Missing Info are:
The dropdown data like: Insp. agency, TIO reference, drop & selected radio options are not matching with Expected attached photo. inspection_sample_pdf.pdf (477.2 KB)