Click here to Skip to main content
15,885,782 members
Please Sign up or sign in to vote.
1.80/5 (2 votes)
See more:
I have a list box that display files. When you click on the file in the list box, it is displayed as a AxAcroPDF object.

The problem I have is that when I select the file and press my delete button, the file is deleted but the pdf is still displayed on the screen.

How do I clear the file from the AxAcroPDF object?
Posted
Updated 22-Feb-17 3:54am

Hi.

I experienced the same problem trying to clear AxAcroPDF object.

I solved it disposing and re-creating the object, and setting the properties again (size, position, etc.), as follows:

AxAcroPDFobject.Dispose();
AxAcroPDFobject = new AxAcroPDFLib.AxAcroPDF
{
Enabled = true,
Location = new System.Drawing.Point(5, 132),
Name = "AxAcroPDFobject",
Size = new System.Drawing.Size(192, 242),
};
container.Controls.Add(AxAcroPDFobject);

* You need to update the size and location coordinates (numbers in bold).
* "container" is the form or groupbox containing the AxAcroPDF object.

Note: this code is for C#. I hope this help you.
 
Share this answer
 
v3
All you need to do is load a pdf that does not exists. I found this out by mistake by mistyping my pdf file name.

AxAcroPDFobject.LoadFile("DONTEXISTS.pdf")

This will return the pdf viewer to blank status.
 
Share this answer
 
Comments
Matiuscomputers 17-Jun-21 10:04am    
Thank you
I've searched the Internet for an answer & haven't found one. I made a work around. I created a blank file & load it when I'm finished with the current document.
 
Share this answer
 
public void clearaxpdf()
{
if (axAcroPDF1 != null)
{
foreach (Process proc in Process.GetProcessesByName("AcroRd32"))
{
proc.Kill();
}

}
}
then call this function
 
Share this answer
 
v2
Comments
Richard Deeming 22-Feb-17 13:13pm    
FIVE YEARS too late.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900