Features, discussions, tips, tricks, questions, problems and feedback

Viewing pdf document on Graphic Form

Hello colleagues!

I have a task to show the System Manual (PDF document) in graphic form.
I first tried using AcroPDF.dll because there are many examples on the internet and it has good reviews as well, but when I tried to add this dll to the toolBox in MapsDesigner nothing happened.

After that I thought it would be nice to create my own control in VisualStudio with this AcroPDF.dll.
It works fine in VisualStudio WinForms, but when I tried to add this custom control to a graphical form in MapsDesigner, I got the error

" System.IO.FileNotFoundException: Could not load file or assembly “AxInerop.AcroPDFLib, Version=1.0.0.0, Culture = neutral, PublicKeyToken = null”"

After 20 minutes, I discovered that AcroPDF.dll is an interop assembly and when you add it to a form in VisualStudio, it automatically adds references to Interop.AcroPDFLib and AxInterop.AcroPDFLib.
Knowing this fact, I added links to these dlls on GraphicFrom in MapsDesigner and managed to add my own control, but after a few seconds later MapsDesigner just shut down itself. And it happened again when I opened this GraphicForm.

Can some one explaine why does this happen ?

p.s. Excuse me please for my English. I’m not good at it :frowning:

Hi Alex,
Since this is third party solution, we cannot much do about it. However, there are simpler ways.

  1. Set Edge browser to be Your default PDF browser.
  2. Draw WebBrowser control on graphic form
  3. in URL property put location of the pdf file. example:

file:///C:/temp/thispdf.pdf

If this will not work, make sure Your webBrowser control is using Edge as engine


or alternatively, in the topic above it is also described how to use WebViewCompatible control.

This topic was already discussed also when it comes to IE browser (if Your windows is older):

Some additional notes on creating your own control:

  • The control should be placed in the “plugins” folder along with all its dependencies
  • The control can be added by right clicking anywhere in the toolbox within the Designer:

image

Special notes:

  • Certain controls (especially older ActiveX controls that are “wrapped” as new .NET controls) do not function well in a multi-threaded UI environment. They may cause critical exceptions on the MAIN UI thread which results in the application closing.
  • The Designer environment is also different from the Operator environment, so the control may “behave” better in the Operator
  • More information on the “crash” can often be found in the Windows Eventlog. For the Operator, in the event of a critical error, there may also be a “.op_restart” file within the folder where the Operator is running with Exception information.
  • The bottomline is that third party controls that are not developed for multi threaded environments and are not able to receive property updates from different threads (and requiring to invoke) do not function well as .NET controls within MAPS.