Search code examples
c#axacropdf

Clear and Reload PDF with axAcroPDF


I have a axAcroPDF object with a textbox and two buttons.

Button1 loads Open File Dialog, sends a filename/path to the axAcroPDF object and sends the filename/path to a textbox.

What I want with button3 is to realase the loaded pdf file and clear the filename from the textbox. So that the user can reload another pdf file.

My attempt is below:

private void button3_Click(object sender, EventArgs e)
        {
            textBox1.Text = String.Empty;
            axAcroPDF1.Dispose();
            axAcroPDF1.setLayoutMode("SinglePage");
            axAcroPDF1.Show();
        }

Initially, I've tried with axAcroPDF1.Hide(); and axAcroPDF1.Dispose();

This hides the axAcroPDF, but I'm unable to reload a new file.

Any suggestions how I should fix this?


Solution

  • Clearing the AxAcroPDF is as simple as providing a file, that doesn't exist:

    AxAcroPDF1.LoadFile("Empty")
    

    A lot of people are confused the same way, trying to achive this...