Nov 25, 2009 3:44 PM
AccessViolationException fatal error, Acrobat 9, AxAcroPDFLib, .NET, Win7
-
Like (0)
How do I work around the following fatal error: AccessViolationException
Steps to reproduce the error:
1. In MS VisualStudio 2008, Create a Windows Form Application, add a Panel and a Button components to the form.
2. Add a Reference to the Acrobat COM component for AxAcroPDFLib
3. Add the following code to the main form:
private AxAcroPDFLib.AxAcroPDF ax = new AxAcroPDFLib.AxAcroPDF();
private void button1_Click(object sender, EventArgs e)
{
panel1.Controls.Add(ax);
ax.LoadFile(@"c:\temp\myfile.pdf");
ax.setView("Fit");
}
4. Run the application
5. Click the Button
6. Press the TAB key on the keyboard.
Result: The application crashes with an AccessViolationException: Memory Corrupted error.
Note: I had been working on an application for about a month now, but had Never pressed the Tab key while the application was running until today!!
Although I did not yet test EVERY key, all other keys and activities inside and outside of the Acrobat component, application, and OS seem to work ok. I can't deploy an application to production if it will crash on Tab keypress.
Platform:
Windows 7, 32bit, all current updates
Acrobat 9 Standard, all current updates
Microsoft Visual Studio 2008 Professional, all current updates
I'm not an Acrobat SDK developer expert, so this may be some simple configuration setting.
Any assistance is greatly appreciated.
Arnold
We are aware of the tab issue but I am pretty sure that it was fixed in 9.2 (the current update). Can you verify that you are on 9.2? Also, are you in Acrobat or Reader?
I verified Acrobat's Help/About: Version 9.2.0 Standard
Windows 7 Enterprise (32 bit).
I tried .NET Frameworks 2.0 and 3.5.
I didn't try Acrobat Reader. Will the Reader behave differently? The final application is for Viewing/Read Only, so I won't need the features of the Standard edition beyond what the Reader comes with. My impression was that I needed the Standard or Pro version license to embed the viewer into a workstation application.
Arnold
You don't need Standard or Pro - whatever the user has on their computer is what will be used. No "licensing" involved since you aren't distributing any Adobe parts.
Acrobat 9.2 Standard definitely does not work with Microsoft Visual Studio 2008 interop. The Tab key is the killer. I'll try the Reader now and post the results. I need to resolve this or else I will be forced to use a more stable PDF viewer component.
Acrobat Reader 9.2.0 crashes with the same AccessViolationException fatal error using Visual Studio 2008, Windows 7, and .NET framework.
This is not good.
Please let me know ASAP when this problem is fixed. I would really like to use Adobe Acrobat and the Acrobat SDK instead of a third party viewer.
Arnold
Looks like Acrobat will be dead for us in Windows 7 until this problem is fixed. I cannot get Acrobat 8 Reader to install in Windows 7, so until Acrobat 9.2.0 is fixed in Windows 7, we have to use a third party PDF viewer.
This was really unexpected!
Attention ADOBE: Please fix the <TAB> key problem in Acrobat 9.2.0 in Windows 7 and notify me ASAP as soon as the fix is ready.
As I already said, we are aware of the problem and will release a fix as soon as possible in our current update schedule.
I am running Reader 9.2.0, using XP, VS 2008 and the issue is still here.
it has not been fixed in the Reader 9.2.
Have you any information about next version which will fixe the issue ?
Is there any workaround meanwhile ?
Thank's.
I just tested this with Acrobat 9.3.1 on Windows XP and Windows Vista. This issue still exists, and has existed since Acrobat 9.0. There is an untrappable exception thrown when the user attempts to tab out of the AcroPDF control. Additionally, once a document is opened in the AcroPDF control, all keyboard keystrokes apply to the AcroPDF control, not the main application form. As a result, users with accessibility requirements cannot tab back to the application main menu or toolbar to continue operating the application once a document is opened.
I am using the AcroPDF control in a Windows executable application written in Visual Basic .NET 2008. Purchase of Acrobat Standard or better by the client for each PC that will have my application installed is a prerequisite for purchase.
My product cannot pass US Federal Government Rehabilitation Act Section 508 Requirements until this issue is resolved- effectively locking me out of the Federal Government market.
Does Adobe recommend another PDF viewer that developers should use that will allow Accessibility in their applications?
I believe this was bug #2393752 which is fixed in 9.3.2.
It is definitely NOT fixed in 9.3.2. At least with VB.Net 2005 on WinXP
Here is a workaround I've found. I haven't had any problems with it (yet), but you'll want to test it out in your application.
I was able to trap the error and prevent it from display by adding an error handler in the load event of my form and the handler subroutines.
This catches the error and prevents the user from seeing it.
I added this code to my form's load event:
Dim currentDomain As AppDomain = AppDomain.CurrentDomain
'for threads behind forms
AddHandler Application.ThreadException, AddressOf MYThreadHandler
and I declared the sub below. I just want to catch and suppress this error, so I have everything in the subroutine commented out.
Sub MYThreadHandler()
' Handle the event.
'MsgBox.Show("MYExceptionHandler caught event.")
End Sub
Hope this helps.
Forgot to say that I'm using my workaround above is used with Adobe Reader. Seems to work with 9.3.1 and 9.3.2. I haven't tested it with anything else.
Just a follow up. my project was deployed in January and its Acrobat is updated to the current version of Acrobat at this time. However, the application is a Touch Screen application, so I can't tell if the problem is resolved - since there is no keyboard attached. It is my hope that the problem is fixed so my next project development will not have the same issue.
Arnold
Ok, guys,they do not seem to fix the problem after about a year of first finding it. I am using Adove Reader 9.3.2 and the bug is still there.
I found the workaround which works perfectly.
In the window where you've created the Adobe PDF Reader Active X control override the OnPretranslateMessage() method.
Paste the following chunk of code to block the internal Adobe's Application message 0x1450 (5200L). If you do not use MFC or C++, then find a place to override message processing.
BOOL CMyDialog::PreTranslateMessage(MSG* pMsg)
{
// insert this chunk of code.
// Replace m_pdfCtrl with the name of your Adobe control.
if(pMsg->hwnd == m_pdfCtrl.GetSafeHwnd())
{
if(pMsg->message == 0x1450)
{
return TRUE;
}
}
return CDialog::PreTranslateMessage(pMsg);
}
BTW, I've send the detailed report to Adobe with the steps to replicate, and as expected no reply from them. Good for you, Adobe.
Hello to everyone.
The TAB exception STILL EXISTS in the X (10) version.
The activex generates the same problem both on .net projects and on borland c++ builder projects(no .net but classis COM).
The last answer workS(Pretranslatemessage)!
What you have to do is contained in this link http://geekswithblogs.net/Jaggi/archive/2006/02/02/67999.aspx.
Obviously you have to process the write key message "0x1450" and not WM_KEYUP.
Working in Access, I'm getting the same fault as everyone else in this thread.
If anyone knows of a way to implement the PreTranslateMessage workaround posted by aucha in VBA, it'd be greatly appreciated.
Hi guys,
I'd like to provide you with an update. Back in June 2010 I have lodged an Adobe product Security vulnerability incident report via the Adobe website. It took them 8 months to come up with a solution. The solution is however is not perfect. You need to copy a Microsoft legacy MFC dll MFC71.dll. There is no way you can download this dll officially from the Microsoft website, as they are apparently dropped support for this version of MFC.
Below is the copy of my conversation with Adobe
From: Adobe PSIRT [mailto:psirt@adobe.com]
Sent: Thursday, February 03, 2011 2:04 PM
To: aucha
Subject: RE: Adobe product security vulnerability feedback form (586)
Hello aucha,
Thank you again for your report of Adobe ID 586. Our investigation of this issue found the problem to be related to MFC71.dll , which was not installed in the case of AcroView.exe. After manually copying the MFC71.dll to the same folder as Acroview.exe (alternatively, MFC can be statically linked with the program), no crash was observed. If your investigation proves otherwise, please let us know.
Again, thank you for your continued help and discretion. Please let us know if you have any questions.
Thank you,
Wendy
Adobe Product Security Incident Response Team
-----Original Message-----
From: Adobe PSIRT
Sent: Wednesday, June 16, 2010 12:03 PM
To: aucha
Cc: Adobe PSIRT
Subject: RE: Adobe product security vulnerability feedback form (586)
Hello aucha,
Thank you for your report. We have been able to reproduce the issue and are currently working on a fix. We will be in touch with additional information as available regarding an eventual release schedule. In the meantime, we appreciate your help in not publicly disclosing this potential issue in order to protect Adobe's customers. This has been assigned the Adobe tracking number 586.
Thank you again for your help and discretion! Please let us know if you have any questions.
Thank you,
Wendy
Adobe Product Security Incident Response Team
-----Original Message-----
From: via web form [mailto:PSIRT@adobe.com]
Sent: Thursday, June 10, 2010 12:49 AM
To: Adobe PSIRT
Subject: Adobe product security vulnerability feedback form (586)
Name: aucha
Email: aucha
Phone:
CanAdobeContactUser: Yes
Product: Adobe Reader
ProductOther:
ProductVersion: 9.3.2
VulnerabilityDetail: I am a Senior Software Developer responsible for application design and development at our company. Our team has identified a vulnerability in 'Adobe PDF Reader <1.0>' Active X (IAcroAXDocShim) control residing in AcroPDF.dll. When the control is placed on a dialog form and a pdf file is loaded, then hitting <Tab> key causes the application to crash.
I have researched the Internet and found that this issue has been observed by someone at lease a year ago in version 8, and apparently has not been fixed since.
As far as I know MS Internet Explorer has a workaround for this issue.
Please advise if this will be fixed, or if there is a know workaround for this.
Regards,
aucha
DefaultConfigVulnerable: Yes
ConfigChangesRequired:
VulerabilityResult: DataLossCorruption, DenialServiceApplication
PartiesAffected: ProductOwner, ThirdParty
HowToDuplicate: Create a simple MFC Dialog based application in Visual Studio.
Add new MFC class using VS wizard 'MFC Class from Active X Control'.
Locate 'Adobe PDF Reader <1>' in the list of installed Active X Controls in the system.
Generate a class for the IAcroAXDocShim interface.
Create a pdf control on the default MFC dialog in OnInitDialog() method.
Load a document using LoadFile() method.
Run the program.
Set Focus to the Adobe reader control using mouse click. Tab out of the control by pressing <Tab> key.
The program crashes.
If having troubles creating an MFC project, please load one from codeproject: http://www.codeproject.com/KB/miscctrl/acroview.aspx
ExampleProgram: Yes
WorkaroundsFixes: Yes
WorkaroundsFixesDetail: There is no any crashes in Internet Explorer. Microsoft must have done something. Please check with them please.
At the same time they implemented additional interfaces (such as IAcroIEHelperShimObj, DWebBrowserEvents2, etc). There is no information about these interfaces in the SDK documentation, so I guess they are designed specifically for MS
VulnerabilityBeingExploited: Yes
As Akiratorishi said, you need to intercept 0x1450 message, not KeyDown message. You need to find our how to use the analog of PreTranslateMessage in MS Access
Maretine wrote:
Working in Access, I'm getting the same fault as everyone else in this thread.
- Have disabled tab stops for all controls (including the Reader control) - still occurs.
- Have the Form_KeyDown event capturing vbKeyTab and setting it to 0 - still occurs.
- Have used Private Declare Function GetAsyncKeyState Lib "User32" (ByVal vKey As Integer) As Long to intercept the Tab's
(but can't find a way to consume the Tab out of the keyboard buffer and am assuming that is why the Reader control still reacts to the Tab)
If anyone knows of a way to implement the PreTranslateMessage workaround posted by aucha in VBA, it'd be greatly appreciated.
aucha wrote:
As Akiratorishi said, you need to intercept 0x1450 message, not KeyDown message. You need to find our how to use the analog of PreTranslateMessage in MS Access
That's my difficulty.
I've been able to find examples of how to do that in C#, nothing for how to do it in Visual Basic for Applications - and VBA is sufficiently different from VB.Net that a straight transation from C# -> VB.Net doesn't work.
In this case you can try the MFC71.dll approach (see my previous post). You can then tell us all, if it worked (I myself personally did not test it, as I do not have time at the moment)
I don't understand this, since Acrobat doesn't use MFC....
The version of MFC71.DLL on my machines is 7.10.3077.0 - from 2003 which as far as I can find is the most recent one, and I can't find any legacy versions.
Even the oldest box left in the office which is running XP has ver7.10.3077.0
Un-encrypted email is inherently insecure and may not be authentic. If you have any doubts that this email is legitimate please telephone Stoneink on (02) 8838-5000 to confirm. This electronic transmission, including any attachments, is intended only for those to whom it is addressed. It may contain copyright material or information that is confidential, priveleged or exempt from disclosure by law. Any claim to privelege is not waived or lost by reason of mistaken transmission of this information. If you are not the intended recipient you must not distribute or copy this transmission and should notify the sender. Your reasonable costs for doing this will be reimbursed by the sender. Stoneink does not accept liability in connection with any computer virus, data corruption, delay, interruption, unauthorised access or unauthorised amendment.
Hello Irosenth,
I've updated to Adobe Reader X and my customers and I still have this issue. Loading the pdf document and hitting the "TAB" key crashes the ActiveX control and the parent application. Now I think I've determined that it only crashes if Adobe doesn't have an object to tab to; for example I can load a pdf with the GUI disabled then hit tab and results in a crash, and likewise, if I load a pdf with entry fields, then I am able to tab through all of the entry fields but near the end it again results in a crash.
We're not able to override an ActiveX method in our application language; otherwise I wouldn't have a problem doing so as outlined here, but is this issue being looked at so I may inform my customers that you're looking into it? If there is any other information that you require please let me know.
Thanks,
- Dustin Buschow
FYI:
I submitted this fatal error condition in Acrobat Reader to ADOBE about 1 year
ago. After 2 formal releases and 4 or more updates, this fatal bug is not
fixed.
This bug makes the touch screen application unusable with a keyboard attached,
unless I put a plug under the TAB key to prevent crashing.
The "club" of people that have joined my bandwagon to get this bug fix have
discovered the bug existed a few versions before I reported it. They have tried
all kinds of work-arounds.
It is really a concern, because I want to integrate Acrobat Reader into ATMS
2014. But I don't think anyone wants to give up the TAB key in the ATMS.
Arnold Stadlin
[signature deleted by host]
Hi,
I have the same problem with my VB-Dot.Net-Application. If someone has a workaround or an official hint to solve the Tab-Problem please let me know
VMBLaOs wrote:
Hi,
I have the same problem with my VB-Dot.Net-Application. If someone has a workaround or an official hint to solve the Tab-Problem please let me know
With VB .Net it will be not difficult to intercept message 0x1450. See for example the comments to this post
Can please give my another hint how to do this in VB.Net.
I don't know howto override the WnsProc-Sub and google only helps with C++/C# and not with Visual Basic.
I'm following up to determine if Adobe or anyone else developed a fix for this AccessViolationException fatal condition when pressing the TAB key in Acrobat.
I have confirmed that the fatal bug exists in Acrobat 10.1.0, Microsoft Visual Studio 2010, and Microsoft .NET 4, on Windows Server 2008 R2 all current updates for all products.
Up until now, my applications with Acrobat Reader in .NET have been Touch Screen oriented, so the users were unlikely to press the TAB key.
This fatal bug is now a show stopper for moving my application to the desktop where there is a TAB key on the keyboard.
Let's please fix this fatal bug in Acrobat Reader or develop a solid work around that permits the TAB key to co-exist with Acrobat Reader and Microsoft .NET Framework.
Arnold
I tested the following PreFilterMessage handler and it appears to work using VS2010, C#, .NET4, and Acrobat X Reader.
public partial class MyAcrobatReaderCTRL : UserControl, IMessageFilter
{
public MyAcrobatReaderCTRL()
{
InitializeComponent();
// Add the PreFilterMessage Handler for this control to the Parent Application
Application.AddMessageFilter(this);
}
public bool PreFilterMessage(ref Message m)
{
// Block the internal Adobe's Application Fatal AccessViolationException when pressing the TAB key.
bool bFiltered = true;
// Adobe's Application Message = 0x1450 (5200L)
const int WM_ACROBAT_1450 = 0x1450;
// Apply the filter
if (m.Msg == WM_ACROBAT_1450)
{
//// Block this message or it will trigger a fatal AccessViolationException when the TAB key is pressed.
// return true
}
else
{
// Other messages can pass through the filter
bFiltered = false;
}
return bFiltered;
}
...
}
** Thank you aucha for the explanation of the Acrobat message causing the bug, and Akiratorishi for pointing me to a reference for C# code that I could modify and implement (hopefully reliably).**
Since this is still an Acrobat/Windows.NET bug, I'm not going to tag it as "Answered" until it is either fixed or until Adobe provides an affirmative work around example that they endorse. That is - until we know that the result of this message being blocked is not causing other problems.
With the above code, at least I can deploy my application to users with keyboards and see what happens.
Arnold
Hi,
can anybody explain how to do this in this code-snippets I got from the page vb-power.net?
Imports System.ComponentModel Public Enum PDFLayoutMode DontCare ' Layout laut Dokumentvorgabe SinglePage ' einzelne Seite OneColumn ' fortlaufende Seite TwoColumnLeft ' fortlaufende Doppelseiten , ungerade Seiten links TwoColumnRight ' fortlaufende Doppelseiten , ungerade Seiten rechts End Enum Public Enum PDFPageMode none ' Default-Ansicht bookmarks ' Ansicht Lesezeichen thumbs ' Ansicht Miniaturansicht End Enum Public Enum PDFViewMode Fit ' Komplette Seite passt vollständig ins bereitgestellte Objekt FitV ' Seitenhöhe (Vertikale) passt vollständig ins Objekt FitH ' Seitenbreite (Horizontale) passt vollständig ins Objekt FitB ' Dokumentrahmen ("Bounding Box") passt vollständig ins Objekt FitBV ' Dokumentrahmenhöhe (Vertikale) passt vollständig ins Objekt FITBH ' Dokumentrahmenbreite (Horizontale) passt vollständig ins Objekt End Enum Public Class PDFView Inherits UserControl Private m_PDFHost As PDFHost Private m_isInitialized As Boolean = False Private m_ShowToolBar As Boolean = True Private m_ShowScrollBars As Boolean = True Private m_LayoutMode As PDFLayoutMode = PDFLayoutMode.DontCare Private m_PageMode As PDFPageMode = PDFPageMode.none Private m_ViewMode As PDFViewMode = PDFViewMode.Fit #Region "Host Helper Class" ''' <summary> ''' Helper Class ''' </summary> ''' <remarks> ''' Diese private Klasse hostet das Acrobat ActiveX Control, ''' so dass es in das UserControl eingefügt werden kann. ''' </remarks> Private Class PDFHost Inherits AxHost ''' <summary> ''' Initialisiert den Host ''' </summary> Public Sub New(ByVal sCLSID As String) MyBase.New(sCLSID) End Sub ''' <summary> ''' Gibt ein Objekt-Verweis auf das ActiveX Control zurück ''' </summary> Public ReadOnly Property Viewer() As Object Get Try Return Me.GetOcx Catch ex As Exception Return Nothing End Try End Get End Property ''' <summary> ''' Gibt sämtliche von der Componente verwendeten Ressourcen frei. ''' </summary> Protected Overrides Sub Dispose(ByVal disposing As Boolean) If Me.Viewer IsNot Nothing Then Me.Viewer.Dipose() End If MyBase.Dispose(disposing) End Sub End Class #End Region #Region "Initialisierungen" ''' <summary> ''' Initialisiert das UserControl ''' </summary> Public Sub New() MyBase.New() Me.InitializeComponent() End Sub Protected Overrides Sub Dispose(ByVal disposing As Boolean) If m_isInitialized Then m_PDFHost.Dispose() End If MyBase.Dispose(disposing) End Sub ''' <summary> ''' Initialisiert die Komponente. ''' </summary> ''' <remarks> ''' Über Late Binding wird versucht, eine Instanz des Acrobat Readers ''' zu erzeugen. Auf dem Zielsystem muss der Reader in der Version 7 ''' oder höher installiert sein. Ist dies nicht der Fall, wird eine ''' Fehlermeldung ausgegeben. ''' </remarks> Private Sub InitializeComponent() Dim t As Type = Type.GetTypeFromProgID("AcroPDF.PDF") If t IsNot Nothing Then m_PDFHost = New PDFHost(t.GUID.ToString) DirectCast((m_PDFHost), ISupportInitialize).BeginInit() SuspendLayout() m_PDFHost.TabIndex = 0 m_PDFHost.Visible = True m_PDFHost.Name = "PDFHost" m_PDFHost.Dock = DockStyle.Fill Controls.Add(m_PDFHost) DirectCast((m_PDFHost), ISupportInitialize).EndInit() ResumeLayout(False) PerformLayout() m_isInitialized = True Else m_isInitialized = False MessageBox.Show("Der Acrobat Reader Version 7 oder höher konnte nicht initialisiert werden." _ & vbCrLf & "Bitte installieren Sie den Acrobat Reader in der Version 7 oder höher." _ , "Überprüfung Acrobat Reader", MessageBoxButtons.OK, MessageBoxIcon.Error) End If End Sub #End Region #Region "Properties" ''' <summary> ''' Die Eigenschaft liefert True zurück, wenn der Acrobat Reader ''' initialisiert wurde, anderenfalls False. ''' </summary> <Browsable(False)> _ Public ReadOnly Property isInitialized() As Boolean Get Return m_isInitialized End Get End Property ''' <summary> ''' Legt den Layout Modus für das PDF-Dokument fest, oder liest diese aus. ''' </summary> <Description("Legt den Layout Modus für das PDF-Dokument fest, oder liest diese aus."), _ Category("Darstellung"), _ DefaultValue(GetType(PDFLayoutMode), "DontCare")> _ Public Property LayoutMode() As PDFLayoutMode Get Return m_LayoutMode End Get Set(ByVal value As PDFLayoutMode) m_LayoutMode = value Try m_PDFHost.Viewer.setLayoutMode(m_LayoutMode.ToString) Catch ex As Exception Throw ex End Try End Set End Property ''' <summary> ''' Legt den Modus für die Seitendarstellung fest,oder liest diese aus. ''' </summary> <Description("Legt den Modus für die Seitendarstellung fest,oder liest diese aus."), _ Category("Darstellung"), _ DefaultValue(GetType(PDFPageMode), "none")> _ Public Property PageMode() As PDFPageMode Get Return m_PageMode End Get Set(ByVal value As PDFPageMode) m_PageMode = value Try m_PDFHost.Viewer.setPageMode(m_PageMode.ToString) Catch ex As Exception Throw ex End Try End Set End Property ''' <summary> ''' Bestimmt, ob die ToolBar angezeigt werden soll. ''' </summary> <Description("Bestimmt, ob die ToolBar angezeigt werden soll."), _ Category("Layout"), _ DefaultValue(True)> _ Public Property ShowToolBar() As Boolean Get Return m_ShowToolBar End Get Set(ByVal value As Boolean) m_ShowToolBar = value Try m_PDFHost.Viewer.setShowToolbar(value) Catch ex As Exception Throw ex End Try End Set End Property ''' <summary> ''' Bestimmt, ob die ScrollBars angezeigt werden sollen. ''' </summary> <Description("Bestimmt, ob die ScrollBars angezeigt werden sollen."), _ Category("Layout"), _ DefaultValue(True)> _ Public Property ShowScrollBars() As Boolean Get Return m_ShowScrollBars End Get Set(ByVal value As Boolean) m_ShowScrollBars = value Try m_PDFHost.Viewer.setShowScrollbars(value) Catch ex As Exception Throw ex End Try End Set End Property ''' <summary> ''' Legt den Modus für die Seiteneinpassung fest, oder liest diese aus. ''' </summary> <Description("Legt den Modus für die Seiteneinpassung fest, oder liest diese aus."), _ Category("Darstellung"), _ DefaultValue(GetType(PDFViewMode), "Fit")> _ Public Property ViewMode() As PDFViewMode Get Return m_ViewMode End Get Set(ByVal value As PDFViewMode) m_ViewMode = value Try m_PDFHost.Viewer.setView(m_ViewMode.ToString) Catch ex As Exception Throw ex End Try End Set End Property #End Region #Region "Methoden" ''' <summary> ''' Geht im Undo-Buffer zur vorherigen Ansicht. ''' </summary> Public Sub GoBackward() Try m_PDFHost.Viewer.GoBackwardStack() Catch ex As Exception Throw ex End Try End Sub Public Sub GoForward() Try m_PDFHost.Viewer.GoForwardStack() Catch ex As Exception Throw ex End Try End Sub Public Sub GotoPage(ByVal PageNumber As Integer) Try m_PDFHost.Viewer.setCurrentPage(PageNumber) Catch ex As Exception Throw ex End Try End Sub Public Sub GotoFirstPage() Try m_PDFHost.Viewer.GotoFirstPage() Catch ex As Exception Throw ex End Try End Sub Public Sub GotoLastPage() Try m_PDFHost.Viewer.GotoLastPage() Catch ex As Exception Throw ex End Try End Sub Public Sub GotoNextPage() Try m_PDFHost.Viewer.GotoNextPage() Catch ex As Exception Throw ex End Try End Sub Public Sub GotoPreviousPage() Try m_PDFHost.Viewer.GotoPreviousPage() Catch ex As Exception Throw ex End Try End Sub Public Function LoadFile(ByVal FileName As String) As Boolean Try Dim b As Boolean = m_PDFHost.Viewer.LoadFile(FileName) If b Then Me.ShowToolBar = m_ShowToolBar Me.ShowScrollBars = m_ShowScrollBars Me.LayoutMode = m_LayoutMode Me.PageMode = m_PageMode Me.ViewMode = m_ViewMode End If Return b Catch ex As Exception Throw ex End Try End Function Public Sub PrintWithDialog() Try m_PDFHost.Viewer.PrintWithDialog() Catch ex As Exception Throw ex End Try End Sub Public Sub Zoom(ByVal Percent As Single) Try m_PDFHost.Viewer.setZoom(Percent) Catch ex As Exception Throw ex End Try End Sub #End Region End Class
Why not download the Acrobat SDK and read the documentation?
Irosenth,
I've read the applicable documentation for using the AcroPDF ActiveX control. Am I mistaken that the source code for the ActiveX control is available in the Acrobat SDK, and I can resolve the many issues that it has on my own, distribute it to thousands of users royalty free?
Also, I don't quite understand the reasons for your passive-aggressive comment. Why not just fix the problem in your ActiveX control? It's been almost three major revisions since these issues have been reported.
There is no source code for the ActiveX control available.
The ActiveX is only a "wrapper" around Reader and/or Acrobat - it does
NOTHING w/o one of those installed on the user's computer.
Irosenth,
I completely understand that ActiveX controls are wrappers, and simply call API calls offered by the reader. But are you suggesting that I write my own ActiveX control "wrapper" and distribute it to my clients- all to solve two issues? The language that we're using does not allow us to override methods within the ActiveX control like VB.NET or C#, so none of these work-arounds have worked for me.
So rather than relying on work-arounds for the past few years, I just want to know, when will these bugs finally be fixed by Adobe? I have a few users that close (and dispose) the control which causes my application to hang, while all of my users can't tab out of the control because it also causes it to hang.
I can't get any support from you, Adobe. I've tried to get support contracts, and you've refused- multiple times- to support Adobe Reader's ActiveX control. Regardless, it is distributed with either business package, Reader, Acrobat, etc., so it's hard for me get anything reliable from you when you simple say you don't support Reader, or when I then submit a ticket and it gets closed without any response. I open another ticket and the same ensues.
When can these things be fixed?
- Dustin
Thankyou all for sharing your experience.
I've been able to fix the application hang by mixing the vb code provided by VMBLaOs with c# code provided by AccessViolationException.
You can compile and use your own PDFView class (Translated in english
) adding this code to your application.
Imports System.ComponentModel
Public Enum PDFLayoutMode
DontCare ' Layout according to the document specification
SinglePage ' Single page
OneColumn ' Continuous page
TwoColumnLeft ' Continuous double pages, odd pages left
TwoColumnRight ' Continuous double pages, odd pages right
End Enum
Public Enum PDFPageMode
none ' Default view
bookmarks ' View bookmarks
thumbs ' View thumbs
End Enum
Public Enum PDFViewMode
Fit ' Entire page fits completely into the provided object
FitV ' Page height (vertical) fits completely into the object
FitH ' Page width (horizontal) fits completely into the object
FitB ' Document frame ("bounding box") fits completely into the object
FitBV ' Document frame height (vertical) fits completely into the object
FITBH ' Document frame width (horizontal) fits completely into the object
End Enum
Public Class PDFView
Inherits UserControl
Implements IMessageFilter
Private m_PDFHost As PDFHost
Private m_isInitialized As Boolean = False
Private m_ShowToolBar As Boolean = True
Private m_ShowScrollBars As Boolean = True
Private m_LayoutMode As PDFLayoutMode = PDFLayoutMode.DontCare
Private m_PageMode As PDFPageMode = PDFPageMode.none
Private m_ViewMode As PDFViewMode = PDFViewMode.Fit
''' <summary> ''' <summary> ''' <summary> End Class Protected Overrides Sub Dispose(ByVal disposing As Boolean) ''' <summary> ''' <summary> ''' <summary> ''' <summary> ''' <summary> ''' <summary> Public Sub GoBackward() Public Sub GoForward() Public Sub GotoPage(ByVal PageNumber As Integer) Public Sub GotoFirstPage() Public Sub GotoLastPage() Public Sub GotoNextPage() Public Sub GotoPreviousPage() Public Function LoadFile(ByVal FileName As String) As Boolean Public Sub PrintWithDialog() Public Sub Zoom(ByVal Percent As Single) #End Region Public Function PreFilterMessage(ByRef m As System.Windows.Forms.Message) As Boolean Implements System.Windows.Forms.IMessageFilter.PreFilterMessage
#Region " Host Helper Class "
''' <summary>
''' Helper Class
''' </summary>
''' <remarks>
''' This private class hosts the Acrobat ActiveX control so that it can be inserted into the UserControl.
''' </remarks>
Private Class PDFHost
Inherits AxHost
''' Initializes the host
''' </summary>
Public Sub New(ByVal sCLSID As String)
MyBase.New(sCLSID)
End Sub
''' Returns an object reference to the ActiveX control
''' </summary>
Public ReadOnly Property Viewer() As Object
Get
Try
Return Me.GetOcx
Catch ex As Exception
Return Nothing
End Try
End Get
End Property
''' Releases all resources used by the component
''' </summary>
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
If Me.Viewer IsNot Nothing Then
Me.Viewer.Dipose()
End If
MyBase.Dispose(disposing)
End Sub
#End Region
#Region " Initialization "
''' <summary>
''' Initializes UserControl
''' </summary>
Public Sub New()
MyBase.New()
Me.InitializeComponent()
Application.AddMessageFilter(Me)
End Sub
If m_isInitialized Then
m_PDFHost.Dispose()
End If
MyBase.Dispose(disposing)
End Sub
''' Initialize components.
''' </summary>
''' <remarks>
''' Late binding is trying to create an instance of the Acrobat Reader. On the target system must the reader version 7 or later be installed. If this is not the case, an error message will be shown.
''' </remarks>
Private Sub InitializeComponent()
Dim t As Type = Type.GetTypeFromProgID("AcroPDF.PDF")
If t IsNot Nothing Then
m_PDFHost = New PDFHost(t.GUID.ToString)
DirectCast((m_PDFHost), ISupportInitialize).BeginInit()
SuspendLayout()
m_PDFHost.TabIndex = 0
m_PDFHost.Visible = True
m_PDFHost.Name = "PDFHost"
m_PDFHost.Dock = DockStyle.Fill
Controls.Add(m_PDFHost)
DirectCast((m_PDFHost), ISupportInitialize).EndInit()
ResumeLayout(False)
PerformLayout()
m_isInitialized = True
Else
m_isInitialized = False
MessageBox.Show("The Acrobat Reader version 7 or higher could not be initialized." _
& vbCrLf & "Please install Acrobat Reader version 7 or higher." _
, "Initializiation of Acrobat Reader component", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
End Sub
#End Region
#Region " Properties "
''' <summary>
''' Property returns the Acrobat Reader initialization state.
''' </summary>
<Browsable(False)> _
Public ReadOnly Property isInitialized() As Boolean
Get
Return m_isInitialized
End Get
End Property
''' Gets or sets the layout mode for the PDF document.
''' </summary>
<Description("Gets or sets the layout mode for the PDF document."), _
Category("Layout"), _
DefaultValue(GetType(PDFLayoutMode), "DontCare")> _
Public Property LayoutMode() As PDFLayoutMode
Get
Return m_LayoutMode
End Get
Set(ByVal value As PDFLayoutMode)
m_LayoutMode = value
Try
m_PDFHost.Viewer.setLayoutMode(m_LayoutMode.ToString)
Catch ex As Exception
Throw ex
End Try
End Set
End Property
''' Gets or sets the mode for the page view.
''' </summary>
<Description("Gets or sets the mode for the page view."), _
Category("Layout"), _
DefaultValue(GetType(PDFPageMode), "none")> _
Public Property PageMode() As PDFPageMode
Get
Return m_PageMode
End Get
Set(ByVal value As PDFPageMode)
m_PageMode = value
Try
m_PDFHost.Viewer.setPageMode(m_PageMode.ToString)
Catch ex As Exception
Throw ex
End Try
End Set
End Property
''' Determines whether the toolbar should appear.
''' </summary>
<Description("Determines whether the toolbar should appear."), _
Category("Layout"), _
DefaultValue(True)> _
Public Property ShowToolBar() As Boolean
Get
Return m_ShowToolBar
End Get
Set(ByVal value As Boolean)
m_ShowToolBar = value
Try
m_PDFHost.Viewer.setShowToolbar(value)
Catch ex As Exception
Throw ex
End Try
End Set
End Property
''' Determines whether to display the ScrollBars.
''' </summary>
<Description("Determines whether to display the ScrollBars."), _
Category("Layout"), _
DefaultValue(True)> _
Public Property ShowScrollBars() As Boolean
Get
Return m_ShowScrollBars
End Get
Set(ByVal value As Boolean)
m_ShowScrollBars = value
Try
m_PDFHost.Viewer.setShowScrollbars(value)
Catch ex As Exception
Throw ex
End Try
End Set
End Property
''' Gets or sets the mode for the page fit.
''' </summary>
<Description("Gets or sets the mode for the page fit."), _
Category("Layout"), _
DefaultValue(GetType(PDFViewMode), "Fit")> _
Public Property ViewMode() As PDFViewMode
Get
Return m_ViewMode
End Get
Set(ByVal value As PDFViewMode)
m_ViewMode = value
Try
m_PDFHost.Viewer.setView(m_ViewMode.ToString)
Catch ex As Exception
Throw ex
End Try
End Set
End Property
#End Region
#Region " Methods "
Try
m_PDFHost.Viewer.GoBackwardStack()
Catch ex As Exception
Throw ex
End Try
End Sub
Try
m_PDFHost.Viewer.GoForwardStack()
Catch ex As Exception
Throw ex
End Try
End Sub
Try
m_PDFHost.Viewer.setCurrentPage(PageNumber)
Catch ex As Exception
Throw ex
End Try
End Sub
Try
m_PDFHost.Viewer.GotoFirstPage()
Catch ex As Exception
Throw ex
End Try
End Sub
Try
m_PDFHost.Viewer.GotoLastPage()
Catch ex As Exception
Throw ex
End Try
End Sub
Try
m_PDFHost.Viewer.GotoNextPage()
Catch ex As Exception
Throw ex
End Try
End Sub
Try
m_PDFHost.Viewer.GotoPreviousPage()
Catch ex As Exception
Throw ex
End Try
End Sub
Try
Dim b As Boolean = m_PDFHost.Viewer.LoadFile(FileName)
If b Then
Me.ShowToolBar = m_ShowToolBar
Me.ShowScrollBars = m_ShowScrollBars
Me.LayoutMode = m_LayoutMode
Me.PageMode = m_PageMode
Me.ViewMode = m_ViewMode
End If
Return b
Catch ex As Exception
Throw ex
End Try
End Function
Try
m_PDFHost.Viewer.PrintWithDialog()
Catch ex As Exception
Throw ex
End Try
End Sub
Try
m_PDFHost.Viewer.setZoom(Percent)
Catch ex As Exception
Throw ex
End Try
End Sub
'Block the internal Adobe's Application Fatal AccessViolationException when pressing the TAB key.
Dim bFiltered As Boolean = True
'Adobe's Application Message
Const WM_ACROBAT_1450 As Integer = 5200 '0x1450
'Apply the filter
If m.Msg = WM_ACROBAT_1450 Then
'Block this message or it will trigger a fatal AccessViolationException when the TAB key is pressed
bFiltered = True
Else
'Other messages can pass through the filter
bFiltered = False
End If
Return bFiltered
End Function
End Class
Works great.
Many thanks
Look for "Dipose" and replace it with "Dispose" in order to let the viewer dispose.
I'm working on a legacy vb6 application that experiences the same issue with Reader 10.1.
Has anyone come up with a work around that can be applied in vb6?
Thanks ahead of time.
JT
VB6 is not supported with Reader X.
From: Adobe Forums <forums@adobe.com<mailto:forums@adobe.com>>
Reply-To: "jive-1134247383-8igo-2-2e4on@mail.forums.adobe.com<mailto:jive-1134247383-8igo-2-2e4on@mail.forums.adobe.com>" <jive-1134247383-8igo-2-2e4on@mail.forums.adobe.com<mailto:jive-1134247383-8igo-2-2e4on@mail.forums.adobe.com>>
Date: Thu, 10 Nov 2011 08:19:16 -0800
To: Leonard Rosenthol <lrosenth@adobe.com<mailto:lrosenth@adobe.com>>
Subject: Re: AccessViolationException fatal error, Acrobat 9, AxAcroPDFLib, .NET, Win7 AccessViolationException fatal error, Acrobat 9, AxAcroPDFLib, .NET, Win7
Re: AccessViolationException fatal error, Acrobat 9, AxAcroPDFLib, .NET, Win7
created by james.g.taylor<http://forums.adobe.com/people/james.g.taylor> in Acrobat SDK - View the full discussion<http://forums.adobe.com/message/4018487#4018487
And Adobe continues to fail and/or refuse to resolve this issue even for those of us using .NET which IS supposedly supported.
Regards,
Michael Flint
Stoneink Pty Ltd
Here is a workaround for WPF with .NEt 3.5 and Reader X :
add In "Window_Loaded" :
ComponentDispatcher.ThreadFilterMessage += new ThreadMessageEventHandler(ComponentDispatcher_ThreadFilterMessage);
private void ComponentDispatcher_ThreadFilterMessage(ref MSG msg, ref bool handled)
{
if (msg.message == 0x1450)
handled = true;
}
Regards,
H.M
As a workaround in VBA, I used the Microsoft Web Browser control instead of the Adobe Read Control. It loaded the exact same interface, but didn't crash when you press TAB.
Hey Brian,
I have tried this in the past, but cannot figure out how to access the control's routines through the web browser component to configure the viewer's options.
Any help is appreciated.
Thank you,
- Dustin Buschow
Dustin,
I am only opening the PDF for viewing and possibly printing, so I'm not using any of the other specific PDF control routines you are probably interested in.
Sorry I couldn't be of more help.
-Brian
Hi Dustin,
You could probably use Parameters for openning PDF Files in your case. On the last page of the document they describe how to encode the parameters into the URL
aucha
Microsoft Web Browser control instead of the Adobe Read Control and loaded the exact same interface alose tab not use it crashed
Sorry Kaozci but this workaround is not so helpful. This workaround is known. This is an old problem that has no solution even with the newest release of acrobat.
The parameters work great. The thing is that I still need to have an easier way for the user to print the document from GUI in the parent application. Is there a way to reference the PDF and have it open the print dialog using something like javascript? Or even better, an undocumented parameter to open the print diaglog prompt?
North America
Europe, Middle East and Africa
Asia Pacific
Copyright © 2011 Adobe Systems Incorporated. All rights reserved.
Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy (updated 07-14-2009).