We work for pwc, Need your urgent assistance for the below issue.
We recently upgraded our Pdf.Kit with Aspose 8.2.0
We are facing issue while extracting the Text from the PDF using Facade.PDFExtractor Method.
Here is the bit of code we used to achieve this.
Extract text from the input PDF document
//extractorLatest.ExtractText();
We are getting the error "Item has already been added Key being used ’ . ’ Key being added ’ . ’ "
Thanks for your inquiry. Can you please share your sample document and code snippet here? So we will test the scenario and will provide you more information accordingly. Moreover, can you please confirm whether you are getting this error with some specific PDF document or all.
To our observation when the template has some data it's happening, but template without data is working fine.So not sure but with our trail and error method which ever template we have generated with data is not working.
We are attaching both the templates, one with data in it (which is not working) and the other without data in it ( which is working).
The code snippet that we used to extract text is as below:
I have tested the scenario using Aspose.Pdf for .NET 8.5.0 where I have used the following code snippet to extract text from both PDF files and as per my observations, the data is properly being extracted. For your reference, I have also attached the resultant Text files containing extracted contents.
We apologize for your inconvenience.
[C#]
//open input PDF
PdfExtractor pdfExtractor = new PdfExtractor();
pdfExtractor.BindPdf("c:/pdftest/NotWorkingPDF.pdf");
//use parameterless ExtractText method
pdfExtractor.ExtractText();
MemoryStream tempMemoryStream = new MemoryStream();
pdfExtractor.GetText(tempMemoryStream);
string text = "";
//specify Unicode encoding type in
//StreamReader constructor
using (StreamReader streamReader = new StreamReader(tempMemoryStream, Encoding.Unicode))
{
streamReader.BaseStream.Seek(0, SeekOrigin.Begin);
text = streamReader.ReadToEnd();
}
File.WriteAllText("c:/pdftest/NotWorkingPDF_output.txt", text);
Thanks for your feedback. Please check subscription expiry date from license file. You can upgrade to Aspose.Pdf for .NET 8.5.0 if it is released before your license expiry date.
Moreover, please note we can’t provide any fixes or patches for older versions of Aspose.Pdf as we maintain a single code base. All fixes and new features are always added into new versions of our products. So, we strongly recommend you please use the latest official release ofAspose.Pdf for .NET to get a fix of reported issue.