Hello, I am experiencing an error after i extract all pdf text. The error is Aspose.Pdf.InvalidPdfFileFormatException: Incorrect file header
We are using Aspose.pdf v25.1.0
The document is actually a test word document converted to pdf. It has only two placeholders I am trying to validate.
Here is the code i found on your docu page:
static string ExtractTextFromDocument(string filepath)
{
var content = "";
// Open PDF document
using (var document = new Aspose.Pdf.Document(filepath))
{
// Create TextAbsorber object to extract text
var textAbsorber = new Aspose.Pdf.Text.TextAbsorber();
// Accept the absorber for all the pages
document.Pages.Accept(textAbsorber);
// Get the extracted text
string extractedText = textAbsorber.Text;
// Create a writer and open the file
using (TextWriter tw = new StreamWriter(filepath))
{
// Write a line of text to the file
content = extractedText;
}
}
return content;
}
The thing is, after first call i get the text, but if i start my program again, it throws me this exception.
Here are the exception details:
Aspose.Pdf.InvalidPdfFileFormatException: Incorrect file header
bei #=zlYyarVQJMjpSyhehktU1mamPknAXDAwz2w==.#=zvyOI3NLrp5LW()
bei #=zlYyarVQJMjpSyhehktU1mamPknAXDAwz2w==..ctor(Stream #=zwVGl0eI=, String #=zmTf2QaQ=, Boolean #=zQMj3m3ABoKZm)
bei #=zlYyarVQJMjpSyhehktU1mamPknAXDAwz2w==..ctor(String #=zknqpjIY=)
bei #=zIpW2EyzbsHVsvKtk$HBW7tgVPJ4cHEk7_3Vw24I=.#=z0zbOOc4=(String #=zknqpjIY=)
bei #=zApFIQrNhKlNquO1I2tURgk$iDyBKKWVaVA==..ctor(String #=zknqpjIY=)
bei #=zIpW2EyzbsHVsvKtk$HBW7tgVPJ4cHEk7_3Vw24I=.#=zbfTkVVvDZmFo(String #=zknqpjIY=)
bei #=zg24GGpN3Sb5fWsHGy1SQMW2pMkKS.#=zqsgnhZI=(String #=zknqpjIY=)
bei #=zg24GGpN3Sb5fWsHGy1SQMW2pMkKS..ctor(String #=zknqpjIY=)
bei Aspose.Pdf.Document.#=zFh3k7lA=(String #=zknqpjIY=, String #=zmTf2QaQ=)
bei Aspose.Pdf.Document..ctor(String filename)
bei aspose.pdf_test.Program.ExtractTextFromDocument(String filepath)
The file I am trying with is here:
1.pdf (33.8 KB)
The file contains @@leftsigner and @@rightsigner placeholders, font “Times New Roman”, font size 1pt.
This reminders me to ask you, are all font sizes supported (even 0,5pt)?
Kind regards,
Aleksandar