Skip navigation
Currently Being Moderated

AccessViolationException fatal error, Acrobat 9, AxAcroPDFLib, .NET, Win7

Nov 25, 2009 2:44 PM

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

 
Replies 1 2 Previous Next
  • Currently Being Moderated
    Nov 25, 2009 2:46 PM   in reply to AccessViolationException

    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?

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 26, 2009 6:18 AM   in reply to AccessViolationException

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 30, 2009 12:26 PM   in reply to AccessViolationException

    As I already said, we are aware of the problem and will release a fix as soon as possible in our current update schedule.

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 3, 2009 2:48 AM   in reply to lrosenth

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 9, 2010 2:08 PM   in reply to lrosenth

    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?

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 14, 2010 6:02 AM   in reply to Matthew Snapp

    I believe this was bug #2393752 which is fixed in 9.3.2.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 16, 2010 5:45 AM   in reply to lrosenth

    It is definitely NOT fixed in 9.3.2.  At least with VB.Net 2005 on WinXP

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 16, 2010 6:00 AM   in reply to Matthew Snapp

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 16, 2010 6:17 AM   in reply to Calloway333

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 10, 2010 4:46 PM   in reply to AccessViolationException

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 11, 2011 7:31 AM   in reply to aucha

    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.

     

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 17, 2011 12:45 PM   in reply to aucha

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 17, 2011 2:31 PM   in reply to Maretine

    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

     

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 17, 2011 4:36 PM   in reply to Maretine

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 17, 2011 7:29 PM   in reply to aucha

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 17, 2011 7:42 PM   in reply to Maretine

    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)

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 17, 2011 8:16 PM   in reply to aucha

    I don't understand this, since Acrobat doesn't use MFC....

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 21, 2012 6:23 PM   in reply to aucha

    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

     

    -- Edited to remove my email sig that was included inadvertently.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 29, 2011 5:02 PM   in reply to lrosenth

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 12, 2011 4:07 AM   in reply to AccessViolationException

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 12, 2011 4:17 AM   in reply to VMBLaOs

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 18, 2011 4:32 AM   in reply to aucha

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 6, 2011 2:44 AM   in reply to AccessViolationException

    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
     
    |
    Mark as:
  • Currently Being Moderated
    Jul 6, 2011 11:28 AM   in reply to VMBLaOs

    Why not download the Acrobat SDK and read the documentation?

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 7, 2011 10:41 AM   in reply to lrosenth

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 7, 2011 11:40 AM   in reply to DBuschow

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 7, 2011 12:21 PM   in reply to lrosenth

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 27, 2011 3:37 AM   in reply to DBuschow

    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


    #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

            ''' <summary>
            ''' Initializes the host
            ''' </summary>
            Public Sub New(ByVal sCLSID As String)
                MyBase.New(sCLSID)
            End Sub

            ''' <summary>
            ''' 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

            ''' <summary>
            ''' 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 Class
    #End Region


    #Region " Initialization "
        ''' <summary>
        ''' Initializes UserControl
        ''' </summary>
        Public Sub New()
            MyBase.New()
            Me.InitializeComponent()
            Application.AddMessageFilter(Me)
        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>
        ''' 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

        ''' <summary>
        ''' 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

        ''' <summary>
        ''' 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

        ''' <summary>
        ''' 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

        ''' <summary>
        ''' 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

        ''' <summary>
        ''' 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 "

        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

        Public Function PreFilterMessage(ByRef m As System.Windows.Forms.Message) As Boolean Implements System.Windows.Forms.IMessageFilter.PreFilterMessage
            '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

     

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 28, 2011 4:57 AM   in reply to Ale Bernardi - BBros

    Works great.

     

    Many thanks

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 1, 2011 7:55 AM   in reply to Ale Bernardi - BBros

    Look for "Dipose" and replace it with "Dispose" in order to let the viewer dispose.

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 10, 2011 8:19 AM   in reply to AccessViolationException

    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

     
    |
    Mark as:
1 2 Previous Next
Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points