We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose Pdf Document construction issue with DocuSign docs

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;
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!!!
var memoryStream = new 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


You may please upload your sample PDF document while creating a post in post editor. Please find upload button in the post editor menu to upload the file. We will test the scenario in our environment and address it accordingly.

Unsuccessful.PDF (248.2 KB)
I have attached an example pdf


We tested the scenario in our environment while using 21.3 version of the API and did not notice any issue. Could you please try using the latest version of the API and if issue still persists, please share the base64 string for our reference in .zip format. We will again test the scenario in our environment and address it accordingly.