hi, my name is eran,
we bought your PDF product.
i tried to upload file and get the next error
we have this product
Aspose.PDF for .NET 19.5
Server Error in ‘/’ Application.
An entry with the same key already exists.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: An entry with the same key already exists.
Source Error:
Line 74: Dim docHtml As New Aspose.pdf.Document(f.InputStream) Line 75: Dim textAbsorber As New TextAbsorber() Line 76: docHtml.Pages.Accept(textAbsorber) Line 77: Dim extractedText As String = textAbsorber.Text Line 78: Response.Write(extractedText)
We have not been able to reproduce the issue in our environment. Would you please share sample application containing SSCCE code so that we may again try to reproduce it, and investigate further.
Imports Aspose.pdf
Imports Aspose.Pdf.Text
Imports Aspose.Words
Imports Aspose.Words.Saving
Imports System.Data
Imports System.Data.OleDb
Imports System.IO
Imports System.Runtime.Serialization.Formatters.Binary
Imports System.Net
Imports adodb
Partial Class docToText
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim license As New Aspose.Words.License()
license.SetLicense("c:\wwwroot\aspose\Bin\Aspose.Words.lic")
Dim license1 As New Aspose.pdf.License()
license1.SetLicense("c:\wwwroot\aspose\Bin\Aspose.pdf.lic")
Dim fileCollection As HttpFileCollection = Request.Files
For i As Integer = 0 To fileCollection.Count - 1
Dim f As HttpPostedFile = fileCollection(i)
If f.ContentLength > 0 Then
Dim fileName As String = f.FileName
Dim fileArr = split(fileName,".")
Dim fileType = fileArr(ubound(fileArr))
'---=== Convert to bytes ===---
' Dim fs As System.IO.Stream = f.InputStream
' Dim br As New BinaryReader(fs)
' Dim buffer() As Byte = br.ReadBytes(Convert.ToInt32(fs.Length))
' Dim htmlStream As New MemoryStream(buffer)
if lcase(fileType)="pdf" then
Dim docHtml As New Aspose.pdf.Document(f.InputStream)
Dim textAbsorber As New TextAbsorber() ' =====> !!!!!! the error is thrown here !!!!!!
docHtml.Pages.Accept(textAbsorber)
Dim extractedText As String = textAbsorber.Text
Response.Write(extractedText)
else
Dim info As FileFormatInfo = FileFormatUtil.DetectFileFormat(f.InputStream)
Dim lf As Aspose.words.LoadFormat = info.LoadFormat
Dim options = New Aspose.words.LoadOptions(lf, "", "")
Dim docWord As New Aspose.words.Document(f.InputStream, options)
Dim docStream As New MemoryStream()
Dim fileExtension As String = FileFormatUtil.LoadFormatToExtension(lf)
Dim sf As Aspose.words.SaveFormat = FileFormatUtil.ExtensionToSaveFormat(fileExtension)
sf = FileFormatUtil.LoadFormatToSaveFormat(lf)
Dim opt
opt = New Saving.OoxmlSaveOptions()
if sf.ToString() = "Doc" then
opt = New Saving.DocSaveOptions(sf)
elseif sf.ToString() = "Docx" then
opt = New Saving.OoxmlSaveOptions(sf)
elseif sf.ToString() = "Rtf" then
opt = New Saving.RtfSaveOptions()
end if
docWord.Save(docStream, opt)
Response.Write(wordReadFile(docWord))
end if
End If
Next i
End Sub
Function wordReadFile(ByVal docWord As Aspose.words.Document) As String
Dim builder As New DocumentBuilder(docWord)
Dim textCv As String = builder.Document.GetText()
textCv = Replace(textCv, "Evaluation Only. Created with Aspose.Words. Copyright 2003-2014 Aspose Pty Ltd.", "")
wordReadFile = textCv
End Function
End Class
Please always share narrowed down code snippet. We have converted it to SSCCE but the issue is not reproduced.
Dim fileName As String = dataDir & "AllJobs_3195556_u6yw4dl.pdf"
Dim fileArr = Split(fileName, ".")
Dim fileType = fileArr(UBound(fileArr))
If LCase(fileType) = "pdf" Then
Dim docHtml As New Aspose.Pdf.Document(fileName)
Dim textAbsorber As New TextAbsorber() ' =====> !!!!!! the error is thrown here !!!!!!
docHtml.Pages.Accept(textAbsorber)
Dim extractedText As String = textAbsorber.Text
Console.WriteLine(extractedText)
End If
Kindly share narrowed down sample application so that we may investigate further.