Facing Catastrophic Failure during Save Operation - PDFXChange Editor SDK

Forum for the PDF-XChange Editor - Free and Licensed Versions

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Paul - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

sandeep
User
Posts: 2
Joined: Wed Apr 29, 2026 1:38 pm

Facing Catastrophic Failure during Save Operation - PDFXChange Editor SDK

Post by sandeep »

We’re encountering a “Catastrophic Failure” error when attempting to save a document. I’ve included the exception details and the relevant code below for reference.

Here’s the scenario where the issue occurs: we have a Reload UI button that, when clicked, closes the currently active form and reinitializes the PDF Editor form. This form is then added back into a split container and displayed. However, when the user tries to save the document after this process, the exception is thrown.

Exception:
Catastrophic failure (0x8000FFFF (E_UNEXPECTED))
at PDFXEdit.IPXV_Document.Save(Object pDest, Int32 nFlags, IProgressMon pProgress, IPXV_ExportConverter pDestConv, ICab pDestConvParams, IAFS_FileSys pDestFS, ICab pAdvancedParams, UInt64 hWndParent)
at TestAXControl.FrmPdfEditor.button1_Click(Object sender, EventArgs e) in C:\Users\sbala\source\repos\TestAXControl\TestAXControl\FrmPdfEditor.cs:line 59
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(HWND hWnd, MessageId msg, WPARAM wparam, LPARAM lparam)

Code: Form1(MainForm)

Code: Select all

namespace TestAXControl
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            this.Initialize();
        }

        public void Initialize()
        {
            FrmPdfEditor pdfForm = new FrmPdfEditor()
            {
                TopLevel = false,
                FormBorderStyle = FormBorderStyle.None,
                Dock = DockStyle.Fill,
            };

            this.splitContainer1.Panel2.Controls.Add(pdfForm);
            pdfForm.Show();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.ReloadUiInternal();
        }

        private void ReloadUiInternal()
        {
            var pdfForm = Application.OpenForms.OfType<FrmPdfEditor>().FirstOrDefault();
            pdfForm?.Dispose();

            // Clear dynamic UI panels
            this.splitContainer1.Panel2.Controls.Clear();
            

            // Re-run initialization logic
            this.Initialize();
            this.Focus();
        }
    }
}
Code: FrmPdfEditor

Code: Select all

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace TestAXControl
{
    public partial class FrmPdfEditor : Form
    {
        private int[] nEditorIDS;

        public FrmPdfEditor()
        {
            InitializeComponent();
            this.Initialize();
        }

        public void Initialize()
        {
            this.axpxV_Control1.SetLicKey(this.GetKeyUnescaped());
            this.axpxV_Control1.OpenDocFromPath(@"C:\Users\sbala\source\repos\TestAXControl\TestAXControl\Einstein 5.0-Prod_Installation_Guid.pdf");
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.axpxV_Control1.Doc.Save();
        }

        public string GetKeyUnescaped()
        {
            var value = ConfigurationManager.AppSettings["TrackerEditorRegKey"];
            if (string.IsNullOrEmpty(value))
            {
                return string.Empty;
            }

            return value
                .Replace("\\r\\n", System.Environment.NewLine)
                .Replace("\\n", "\n")
                .Replace("\\r", "\r")
                .Replace("\\t", "\t");
        }
    }
}
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 12927
Joined: Wed Jan 03, 2018 6:52 pm

Re: Facing Catastrophic Failure during Save Operation - PDFXChange Editor SDK

Post by Daniel - PDF-XChange »

Hello, sandeep

Thank you for the report, would it be possible for you to assemble a sample project where the issue is reproducible and share it with us?

Kind regards,
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
[email protected]
sandeep
User
Posts: 2
Joined: Wed Apr 29, 2026 1:38 pm

Re: Facing Catastrophic Failure during Save Operation - PDFXChange Editor SDK

Post by sandeep »

Here is a sample codebase that reliably reproduces the issue.

Steps to reproduce:

1. Run the application in Debug mode using Microsoft Visual Studio.
2. Once the application launches, make some changes to the PDF document and click the Save button.
3. Click on the Reload UI button.
4. Again, make some changes to the PDF document and click Save.

At this point, the application breaks and throws the exception.

Kindly review the attached files for further details.
TestAXControl.zip
You do not have the required permissions to view the files attached to this post.
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 12927
Joined: Wed Jan 03, 2018 6:52 pm

Re: Facing Catastrophic Failure during Save Operation - PDFXChange Editor SDK

Post by Daniel - PDF-XChange »

Hello, sandeep

Thank you very much for this, I have passed this along to the Dev team to investigate the issue, and will keep you informed of their response.

Kind regards,
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
[email protected]
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2491
Joined: Thu Jun 30, 2005 4:11 pm

Re: Facing Catastrophic Failure during Save Operation - PDFXChange Editor SDK

Post by Vasyl - PDF-XChange »

Hi sandeep.

Thanks for the sample program. Now we understand where the problem is. In case you are creating the pdf control many times (or creating many instances of the pdf control), you need to use a slightly different approach. Like this:

Code: Select all

public PDFXEdit.PXV_Inst Inst = null;

public Form1()
{
    // ONCE initialize the PDF-XChange Editor SDK
    string licKey = ...;
    Inst = new PDFXEdit.PXV_Inst();
    Inst.Init(null, licKey);
...
    InitializeComponent();
    this.Initialize();
}

private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
    // Finally, ONCE uninitialize the PDF-XChange Editor SDK
    if (Inst != null)
    {
        Inst.Shutdown();
        Inst = null;
    }

    /////////////////////////////////////////////////////////////////////////////////////
    // Forced release of all COM-objects that may still captured by Garbage Collector.
    // It is critical to release them before destroying of pdfCtl!
    /////////////////////////////////////////////////////////////////////////////////////
    GC.Collect();
    GC.WaitForPendingFinalizers();
}
Without this "manual" SDK initialization/uninitialization, each new pdf-control instance initializes the SDK before it is created and automatically uninitializes the SDK when it is destroyed. But there is one hidden problem: when the SDK is initialized a second time in the context of the same process - our internal JS-engine cannot start a second time. And this will create problems with with documents containing interactive forms and also affects document saving.

Therefore, you need to use the method proposed above to initialize and uninitialize the SDK only once per runtime...

HTH.
PDF-XChange Co. LTD (Project Developer)

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.