Reputation: 3153
i know this question seems simple but it is giving me a headache. I have a programm from where i want to show a pdf and this works fine and dandy but when i want to change the pdf it won't work. The application has two two tabpages, one for the PDF and one for the design etc. I can click on Print and a pdf is created and it loads. When changing the pdf, because i changed something in the first tab, it doesn't delete the old one and it won't load the new pdf file.
Here is my code:
//The PdfFile variable is the path to the old pdf file
//and file variable is the path to the new pdf file
if (wbPdfViewer != null)
{
wbPdfViewer.AllowNavigation = true;
wbPdfViewer.Navigate(new Uri("http://www.google.de")); //this should navigate
wbPdfViewer.Url = new Uri("http://www.google.de"); //this is just a try
bool isallowed = wbPdfViewer.AllowNavigation; //check during debbuging if it is set
string url = wbPdfViewer.Url.ToString(); //see if it works during debbuging
}
if (pdfViewer.Document != null) //this is an optional viewer ... nevermind that
{
pdfViewer.Document.Close();
pdfViewer.Document.Dispose();
}
try
{
DHIO.File.Delete(PdfFile);
}
catch(Exception ex)
{
#if DEBUG
MessageBox.Show("PdfViewer 02002: Couldn't delete PDF file");
#endif
}
if (wbPdfViewer != null)
{
GC.Collect();
if (string.IsNullOrEmpty(file) || !DHIO.File.Exists(file))
return;
wbPdfViewer.Navigate(new Uri(file));
ShowNavigationControls();
return;
}
As you can see i want to delete the PdfFile and it shouldn't be in access because i changed the page (in a later version google.de is replaced with about:blank or something else).
So my question is how to change the URL so that my program isn't accessing the pdf file anymore ? i tried it with the navigationComplete event but this won't fire
and as always thanks in advance
Upvotes: 0
Views: 6395