System.ArgumentException: #=zKvEEkeFVqwrNYzqVZC7R3PQ= : Stack empty

We have a Site Small Business License (ID: 250619205945) for Aspose.PDF for .NET. We’re encountering the error below when attempting to convert a PDF to HTML. I can’t share the original PDF as it has very sensitive data,

System.ArgumentException: #=zKvEEkeFVqwrNYzqVZC7R3PQ= : Stack empty.[ at System.Collections.Generic.Stack1.ThrowForEmptyStack() at System.Collections.Generic.Stack1.Pop() at #=zwEX1Uu7dldtf217e6c2Vlt5TNbZI.#=zF1EWBQBwa7gZ(#=zKvEEkeFVqwrNYzqVZC7R3PQ= #=zrdVsDwI6pTrg) at #=zKvEEkeFVqwrNYzqVZC7R3PQ=.#=z_F0x1jI=(#=zoVHmWXIhc2gq2wzEdZDZzFvMEZ75 #=zP_CJXA=) at #=zlhXhAdh9IJDmmqihfLXt3ExHNsMe.#=z_F0x1jI=(#=zoVHmWXIhc2gq2wzEdZDZzFvMEZ75 #=zP_CJXA=)] at #=zlhXhAdh9IJDmmqihfLXt3ExHNsMe.#=z_F0x1jI=(#=zoVHmWXIhc2gq2wzEdZDZzFvMEZ75 #=zP_CJXA=) at #=zU__E6g90ZK9q5z2Lh1eOyM=.#=z_F0x1jI=(#=zoVHmWXIhc2gq2wzEdZDZzFvMEZ75 #=zP_CJXA=) at #=zwEX1Uu7dldtf217e6c2Vlt5TNbZI.#=z9v4uogY=(#=zU__E6g90ZK9q5z2Lh1eOyM= #=zsm9BCvY=) at #=zWs9OEn45iDbIC0_G0FudTUXzfX4gdxpsyIpfNJk=.#=z9v4uogY=(#=zU__E6g90ZK9q5z2Lh1eOyM= #=zsm9BCvY=, Int32 #=zCDcJqSDuYIC, #=zLWfY1GDsnzi4gbkbqNpYezhbehk6jOHf4a8mus= #=zWfpNSHQ=, Int32 #=zbiyyvCbMse2HRGDsEA==, Boolean #=zeyRwk5xHwIp0) at #=zWs9OEn45iDbIC0_G0FudTUXzfX4gdxpsyIpfNJk=.#=zQKdGxBQ=(IList1 #=zbJX7hvH4$pRw, #=zsVi5ka7VZoeqUsALq1rKoX7QDQO_U31Irg== #=zHEvI$RQ=, #=zLWfY1GDsnzi4gbkbqNpYezhbehk6$jOHf4a8mus= #=zWfpNSHQ=) at #=zicJEYSe8ojmDYAFVwQdn0BEwfJzB.#=zQKdGxBQ=(String #=zO_rwQ6Lqxgu5, #=zV1wR2OpHSzh6ESL5x_Fw_K286GC$zu6y9A== #=zWfpNSHQ=, IList1 #=zbJX7hvH4$pRw, #=zSpbEBVZH4KYAIiJMp4VNIwMjkUvxbpR6xIwAVg8= #=zwK7ZHhs=, #=zB53NA0_UkclcPpAE4C6YFp$FMZGn #=z3yt5nOnhSMOd) at #=zgW0SO93dHwCiuztE8DE0rjk=.#=z_jmTB3PHlpEHP0hwQ==(Document #=zkpRYe8U=, #=z6CMTrgsArskM #=zbJX7hvH4pRw, String #=zAhZt18o0u4TfHKo58Q==, Stream #=zJu0ziu6Ah7D, HtmlSaveOptions #=zWfpNSHQ=) at #=zgW0SO93dHwCiuztE8DE0rjk=.#=zrhZrJVA=(Document #=zkpRYe8U=, String #=zAhZt18o0u4TfHKo58Q==, Stream #=zJu0ziu6Ah7D, HtmlSaveOptions #=zWfpNSHQ=) at Aspose.Pdf.Document.#=zLS1eURibouep(Stream #=zEaBP12rexdE_, SaveOptions #=zWfpNSHQ=) at Aspose.Pdf.Document.#=z4yNowysVF6br(Stream #=zVkoFDydK3HO, SaveOptions #=zWfpNSHQ=) at Aspose.Pdf.Document.Save(Stream outputStream, SaveOptions options) at

@Mark.Otway.troweprice.com

Cause

The error message you’re encountering, System.ArgumentException: Stack empty, typically indicates that the code is attempting to access an element from an empty stack. This can occur during the conversion process if the PDF document has unexpected content or structure that the conversion engine cannot handle.

Solution

To troubleshoot and resolve this issue, consider the following steps:

  1. Check PDF Content: Ensure that the PDF document does not contain any unsupported features or corrupted elements. If possible, try converting a simpler PDF to see if the issue persists.

  2. Use Error Logging: Implement error logging during the conversion process. This can help capture any specific issues that arise when processing the PDF.

  3. Adjust Conversion Options: Utilize the HtmlSaveOptions class to customize the conversion process. For example, you can enable or disable certain features that might be causing the issue.

  4. Update Aspose.PDF Library: Ensure you are using the latest version of the Aspose.PDF library, as updates often include bug fixes and improvements.

Code

Here’s a basic example of how to convert a PDF to HTML using HtmlSaveOptions:

using Aspose.Pdf;

private static void ConvertPDFtoHTML()
{
    // Load the PDF document
    using (var document = new Document("input.pdf"))
    {
        // Create HTML save options
        var htmlOptions = new HtmlSaveOptions
        {
            // Customize options as needed
            SplitIntoPages = true // Example option
        };

        // Save the document to HTML format
        document.Save("output.html", htmlOptions);
    }
}

Next Steps

  1. Test the conversion with a different PDF file to see if the issue is specific to the original document.
  2. If the problem persists, reach out to Aspose support with details of the PDF structure or any specific features it contains.
  3. Review the documentation for any additional options that may help in handling complex PDF structures during conversion.

Please implement these steps and let me know if you need further assistance!

Sources:
[1]: Convert PDF to HTML in .NET - Aspose Documentation