Need ActiveX PDF Reader

Xbase++ 2.0 Build 554 or later
Message
Author
Leon Berger
Posts: 36
Joined: Thu Jan 28, 2010 2:30 pm

Re: Need ActiveX PDF Reader

#11 Post by Leon Berger »

rdonnay wrote:Trying to get an OCX to evaluate has become really frustrating.

Windows defender won't let me run the installation program for the SoraxSoft demo.
I installed the SoraxSoft Demo without any problems (32- and 64-bit) on Windows 10 Pro 1909, Build 18363,592 and active Windows Defender.
Best regards
Leon

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Need ActiveX PDF Reader

#12 Post by rdonnay »

I decided to ignore Windows Defender because it was verified by Google on the download.

I finished the installation.

Thanks.
The eXpress train is coming - and it has more cars.

skiman
Posts: 1183
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Need ActiveX PDF Reader

#13 Post by skiman »

Hi Roger,

I was wondering if you already did some tests with this activeX?

I'm using the Acrobat reader and sometimes we have problems with the annoying toolbar coming up in de window. If this ActiveX is better to control, I would consider changing it.
Best regards,

Chris.
www.aboservice.be

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Need ActiveX PDF Reader

#14 Post by rdonnay »

Chris -

I determined that the problems with Acrobat were due to security issues.
Rather than try to find a replacement PDF reader I found that I could turn off security using a registry entry.
My customer's IT guys said it would be ok.

The below code makes Acrobat PDFs load much faster:

Code: Select all

DC_RegWrite( HKEY_LOCAL_MACHINE,'SOFTWARE\Policies\Adobe\Acrobat Reader\DC\FeatureLockDown','bProtectedMode',0 )
The eXpress train is coming - and it has more cars.

skiman
Posts: 1183
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Need ActiveX PDF Reader

#15 Post by skiman »

Hi Roger,

Don't you have problems with that toolbar that appears in Acrobat?

I'm using the following, but it looks as it is sometimes ignored:

Code: Select all

oPdf:setShowToolbar(False)
oPdf:setShowScrollbars(False)
oPdf:setView("Fit")
oPDF:loadFile(cPDFfile)
Best regards,

Chris.
www.aboservice.be

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Need ActiveX PDF Reader

#16 Post by rdonnay »

Don't you have problems with that toolbar that appears in Acrobat?
Actually, this application is not using the Acrobat OCX, instead it is using XbpHtmlViewer.
This is because there are many more file types that are being viewed besides PDF.

Yes, the toolbar is very annoying but it only appears when the same PDF is viewed more than one time in sequence.
I am looking at techniques to solve this problem.
The eXpress train is coming - and it has more cars.

skiman
Posts: 1183
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Need ActiveX PDF Reader

#17 Post by skiman »

rdonnay wrote:
Yes, the toolbar is very annoying but it only appears when the same PDF is viewed more than one time in sequence.
Yes indeed, it is always when the same PDF is shown again.

We also have sometimes JPG of PNG files to show. Never thought about the htmlviewer to use instead of the Acobat Reader. I convert the images to pdf before showing them. Maybe your solution is better.
Best regards,

Chris.
www.aboservice.be

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Need ActiveX PDF Reader

#18 Post by rdonnay »

This is how I solved the problem with the Acrobat toolbar.

I discovered that if anything other than a .PDF is loaded into the html viewer, it does a reset to the Acrobat control that is inherited by the html viewer and no toolbar will appear the next time a PDF is loaded. Maybe it clears the file cache.

There will be a short flash in the viewer before the PDF appears but that appears to be acceptable.

Code: Select all

ELSEIF cDocType $ {'.TXT','.PDF','.HTML','.XML','.HTM','.ZIP','.ICO','.BMP','.RTF'}
  // Send it to viewer
  IF cDocType == '.PDF'
    MemoWrit(DC_Curpath()+'\viewer.htm','  ')
    ::viewerObject:Navigate(DC_Curpath()+'\viewer.htm')
  ENDIF
  ::viewerObject:Navigate(cDoc)
The eXpress train is coming - and it has more cars.

skiman
Posts: 1183
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Need ActiveX PDF Reader

#19 Post by skiman »

Hi Roger,

I did some tests with the htmlviewer, and it is working fine. Much better to implement according to the Adobe acrobat reader. now we can show every type of document.

Thanks for the suggestion.
Best regards,

Chris.
www.aboservice.be

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Need ActiveX PDF Reader

#20 Post by rdonnay »

Chris -

I have created a sample program that I think will give you some ideas on how to handle file viewing in an Xbase++ application.

Here is FileViewer.Prg

The FileViewer.Zip also includes a file named Viewer.aapp
This should be copied to your C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroApp\ENU folder to overwrite the existing file.
It will suppress the toolbar that is in the free version of Acrobat Reader DC.

After working closely with 2 customers who use this file viewing system in their documents systems, we have all agreed on the best way to handle viewing of documents inside an Xbase++ application.

Here is the part of the code that does the viewing of the document.

If the document type is an image, then it is put into the viewer via an html file that makes sure the image is sized for viewing.

If the document type is not supported by XbpHtmlViewer, then a message is put in the viewer telling the user to double-click the document for viewing with the registered program for that extension type. A double-click will spawn it.

If the document type is not registered, then a message is put into the viewer that it cannot be viewed.

Code: Select all

STATIC FUNCTION ViewDocument( oViewer, cDoc, lItemSelected, oBrowse )

LOCAL cHtml, cDocType := '', aRef, aData, lIsValidType, aBranch

cDocType := Upper(cDoc)
cDocType := Substr(cDocType,_AtLast(cDocType,'.'))

aBranch := DC_RegQueryBranch(HKEY_CURRENT_USER, ;
               'Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\' + ;
               Lower(cDocType) + '\UserChoice')

IF Empty(aBranch)
  aBranch := DC_RegQueryBranch(HKEY_CURRENT_USER, ;
               'Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\' + ;
               Lower(cDocType) + '\OpenWithProgids')

ENDIF

lIsValidType := !Empty(aBranch)

IF cDocType $ {'.JPG','.PNG', '.GIF', '.TIFF', '.TIF'}
  // Send image to viewer in a <IMG> tag
  IF !lItemSelected
    cHtml := '<img src="' + cDoc + '" width=' + Alltrim(Str(oViewer:currentSize()[1]-20)) + '>'
    MemoWrit('Viewer.Htm',cHtml)
    cDoc := DC_CurPath()+'\' + 'viewer.htm'
    Sleep(10)
    oViewer:Navigate(cDoc)
  ENDIF
ELSEIF cDocType $ {'.TXT','.PDF','.HTML','.XML','.HTM','.ZIP','.ICO','.BMP','.RTF'}
  // Send it to viewer
  // To suppress Acrobat DC Toolbar, copy viewer.aapp to the following folder:
  // Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroApp\ENU
  oViewer:Navigate(cDoc)
ELSE
  // Spawn it and show a message in the viewer
  IF cDocType $ {'.XLS','.XLSX','.CSV'}
    cDocType := 'Microsoft Excel'
  ELSEIF cDocType $ {'.DOC','.DOCX'}
    cDocType := 'Microsoft Word'
  ELSEIF cDocType $ {'.MOV','.AVI','.MP4'}
    cDocType := 'Video'
  ENDIF
  IF lIsValidType
    cHtml := '<H2>Your ' + cDocType + ' document will be displayed in a new window.<br><br>'
    cHtml += 'Press the ENTER key or Double click the document name to view the document'
  ELSE
    cHtml := '<H2>Your document has no registered program that is associated with '
    cHtml += 'this file type: ' + cDocType
  ENDIF
  IF !lItemSelected
    MemoWrit('Viewer.Htm',cHtml)
    cDoc := DC_CurPath()+'\' + 'viewer.htm'
    Sleep(10)
    oViewer:Navigate(cDoc)
  ENDIF
ENDIF

IF lItemSelected
  DC_SpawnUrl(cDoc)
ENDIF

SetAppFocus(oBrowse)

RETURN nil
The sample program suppresses showing any kind of document that should not be spawned, such as .EXE, .DLL, etc.
Attachments
fileviewer.zip
(2.71 KiB) Downloaded 712 times
The eXpress train is coming - and it has more cars.

Post Reply