We are having issues with Aspose.Pdf version 17.4 on the Document construction overload:
We have noticed the issue occurring more and more often and always involves a docusign that takes a base64 string. We have inspected these document properties, especially security tab) and nothing seems consistent to cause the failure as similar docusigned pdfs succeed. We can provide source pdf and/or base64 strings if a share path is supplied. Thank you.
Aspose PDf method that fails is:
Document(Stream stream)
Code snippet is
public virtual string FlattenPdfDocumentFromStream()
{
var fileName = string.Empty;
string response = string.Empty;
try
{
var webRequest = HttpContext.Current.Request.InputStream;
webRequest.Seek(0, SeekOrigin.Begin);
var jsonText = new StreamReader(webRequest).ReadToEnd();
var base64Text = JsonConvert.DeserializeObject(jsonText);
var bytes = Convert.FromBase64String(base64Text);
var str = new MemoryStream(bytes);
var flatDocument = new Document(str); //This line fails!!!
flatDocument.Flatten();
var memoryStream = new MemoryStream();
flatDocument.Save(memoryStream);
response = this.base64UtilityHelper.CreateBase64String(memoryStream, false);
}
catch (Exception ex)
{
_logger.Warn("EXCEPTION -- Exception thrown while trying to convert documentName:{fileName} to {convertTo} -- Message:{ex.Message}", ex);
}
return response;
}
The Document is never created and throws this:
Message: Unable to cast object of type '\b to type \u0006
Stack Trace: at .()
at . ()
at Aspose.Pdf.PageCollection.get_Count()
at Aspose.Pdf.PageCollection.()
at Aspose.Pdf.PageCollection…ctor(Document )
at Aspose.Pdf.Document.()
at Aspose.Pdf.Document.(Stream , String )
at Aspose.Pdf.Document…ctor(Stream input)
at DocConverter.Api.Controllers.DocConverterController.FlattenPdfDocumentFromStream() in C:\workspace\Transactions-DocumentConverterAPI\DocConverter.Api\Controllers\DocConverterController.cs:line 153