We have a pile of PDF documents that have external links to other pdf documents.
Is there anyway we can trap a callback so we can --
a) Stop the default behaviour being opening another PDF viewer as an external process (typically it ends up being Adobe Reader or IE)?
b) Verify it's opening a path that exists so we can handle the error, or redirect it to open another file?
Links to other PDF documents
Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan
-
- User
- Posts: 4
- Joined: Wed Aug 14, 2013 5:26 pm
-
- User
- Posts: 4
- Joined: Wed Aug 14, 2013 5:26 pm
Re: Links to other PDF documents
Got a little bit ahead...
if ("Prompts.ConfirmOpenSite".Equals(pName))
{
object fileNameToOpen;
pdfViewer.GetProperty("Prompts.ConfirmOpenSite.Name", out fileNameToOpen, 0);
pdfViewer.SetProperty("Prompts.ConfirmOpenSite.KeepUserChoice", 1, 0); // keep changes
pdfViewer.SetProperty("Prompts.ConfirmOpenSite.UserChoice", "No", 0); // cancel default
OpenPdfFile(new Uri((string)fileNameToOpen).ToString()); // crash there
}
Crashes when I open a new PDF file though, unless I put a sleep and thread it .... for example..
private void pdfViewer_OnEvent(object sender, AxPDFXCviewAxLib._IPDFXCviewEvents_OnEventEvent e)
{
switch (e.type)
{
case (int)PXCVA_EventTypes.PXCVA_OnDisplayPrompt:
{
OnPromptDisplayed(e.name);
break;
}
}
}
private void OnPromptDisplayed(string pName)
{
if ("Prompts.ConfirmOpenSite".Equals(pName))
{
object fileNameToOpen;
pdfViewer.GetProperty("Prompts.ConfirmOpenSite.Name", out fileNameToOpen, 0);
pdfViewer.SetProperty("Prompts.ConfirmOpenSite.KeepUserChoice", 1, 0);
pdfViewer.SetProperty("Prompts.ConfirmOpenSite.UserChoice", "No", 0);
Task.Run(() => {
System.Threading.Thread.Sleep(40);
OpenPdfFile(new Uri((string)fileNameToOpen).ToString());
});
}
}
Putting in "sleep" scares me --- is that safe?
if ("Prompts.ConfirmOpenSite".Equals(pName))
{
object fileNameToOpen;
pdfViewer.GetProperty("Prompts.ConfirmOpenSite.Name", out fileNameToOpen, 0);
pdfViewer.SetProperty("Prompts.ConfirmOpenSite.KeepUserChoice", 1, 0); // keep changes
pdfViewer.SetProperty("Prompts.ConfirmOpenSite.UserChoice", "No", 0); // cancel default
OpenPdfFile(new Uri((string)fileNameToOpen).ToString()); // crash there
}
Crashes when I open a new PDF file though, unless I put a sleep and thread it .... for example..
private void pdfViewer_OnEvent(object sender, AxPDFXCviewAxLib._IPDFXCviewEvents_OnEventEvent e)
{
switch (e.type)
{
case (int)PXCVA_EventTypes.PXCVA_OnDisplayPrompt:
{
OnPromptDisplayed(e.name);
break;
}
}
}
private void OnPromptDisplayed(string pName)
{
if ("Prompts.ConfirmOpenSite".Equals(pName))
{
object fileNameToOpen;
pdfViewer.GetProperty("Prompts.ConfirmOpenSite.Name", out fileNameToOpen, 0);
pdfViewer.SetProperty("Prompts.ConfirmOpenSite.KeepUserChoice", 1, 0);
pdfViewer.SetProperty("Prompts.ConfirmOpenSite.UserChoice", "No", 0);
Task.Run(() => {
System.Threading.Thread.Sleep(40);
OpenPdfFile(new Uri((string)fileNameToOpen).ToString());
});
}
}
Putting in "sleep" scares me --- is that safe?
-
- User
- Posts: 381
- Joined: Mon Jun 13, 2011 5:10 pm
Re: Links to other PDF documents
You say it crashes unless you add the a sleep statement; what is the nature of the crash?
What is your OpenPdfFile() function?
What is your OpenPdfFile() function?