Jump to content

Recommended Posts

Posted (edited)

I need help.

I have a project that outputs reports to PDF using @mLipok's lovely QuickPDF.  The PDF is created with no problem and I am sure the problem is not there.

However, I then have to open the PDF so the user can see it.

I use (a) short file name and (b) object properties

$oQP.SetPageLayout(2)
$oQP.SetPageMode(3)

... $sFilename ; as created by UDF
Local $sShortname = FileGetShortname( sFilename , 1 )

Run( @ComSpec & " /c start /max " & sShortname, "", @SW_HIDE ) ; force default PDF reader to open PDF maximized

Then the RUN should open it with the default application.

I have tested extensively on 32 bit Win7 and 64 bit Win10.  Works.

However, 64 bit Win8 and another Win7 laptop gives a problem.

The problem is this: when (typically) Adobe Reader is ALREADY open, the PDF opens almost instantaneously.  If the Reader is not open, it seems to stall.  Never opens.

The host on which the report will be opened is unknown to me and the PDF reader can not be hard coded.

Right now, my only brutal, very un-stylish solution is to force the Reader open prior to the RUN command.

Any ideas or advice on what causes this or how it could be remedied would be greatly appreciated.

Anything, please.

-Skysnake

Edited by Skysnake

Skysnake

Why is the snake in the sky?

Posted (edited)

Hi.

I will try to Look when I back home.

Edit : today.

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Would ShellExecute work?

I've seen similar issues when different PDF readers have been installed one after the other, e.g. Foxit then Adobe. The registry isn't correctly updated in some cases.

  Reveal hidden contents

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Posted

Aha, that helps.

I just checked. The reason I use Run() is that ShellExecute used to fail... now both fail...

any suggestions on cleaning up the registry without becoming too invasive?

Thx 

-Skysnake

Skysnake

Why is the snake in the sky?

Posted

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)

Dear @mLipok, I understand. But I would prefer to use local resources. create the PDF and then get (whatever is installed locally) to open the PDF... :)

I do not have control over the hardware this will be installed and want to make the use as easy as possible.

So, I guess I am looking at some kind of "do you want to fix the reader problem" option...

 

Meanwhile...

Some feedback... is it possible that Reader 9 and Reader 11 work differently?

Or, could MacAfee interfere with the file open? I know MacAfee has been in contention here before and I hate it... :(

 

-Skysnake

Edited by Skysnake

Skysnake

Why is the snake in the sky?

Posted
  On 11/22/2016 at 3:39 PM, Skysnake said:

any suggestions on cleaning up the registry without becoming too invasive?

Expand  

if it's not your machine, then don't go there. not your responsibility and you will probably do more harm than good.

have you considered the possibility that no PDF viewer is installed at all on the target machine?

i'd advise either choose an alternative, more trivial format, like HTML or XPS. if you insist on PDF, i'd advise you bundle your software with a free portable PDF viewer (pick one from this list), and use it specifically to display your PDF documents, and yours only.

Signature - my forum contributions:

  Reveal hidden contents

 

Posted

Hmm, thx @orbs, similar solution to what @mLipok suggested. I will certainly look at that.  Bundling will make the distribution bigger, but does solve this kind of silly "I cant see my reports" problem... Thx

-Skysnake

Skysnake

Why is the snake in the sky?

Posted

@Skysnake, if you are considering the Adobe Reader ActiveX control, then it may solve the slowness issue, but will not work when Adobe Reader is not installed.

Signature - my forum contributions:

  Reveal hidden contents

 

Posted

I can now add that I have seen the process stalled in the Task Manager.  

I do understand if there is no reader installed nothing will work, point taken... But then the user can install a reader of choice... perhaps a "testForReader()" function?  

Somewhere I read a reference to "recently created files..." -> why would this be an issue and could this be related to the problem I am experiencing?

-Skysnake

Skysnake

Why is the snake in the sky?

Posted (edited)

Hi, you could check the file association and get the executable.

If the executable is Adobe Reader you can start it direct with the command line option /n. That means Reader will start the file in a new instance.

If you find another PDF viewer you can start it also direct. If you find nothing you can give a hint or a link to a PDF viewer.

 

br, Reinhard

 

PS.: In cmd you can use "assoc .pdf" and then use the result in "ftype ....." to get the program, but I think I saw also examples here.

Edited by ReFran
Posted (edited)
  On 11/23/2016 at 10:37 PM, PACaleala said:

@Skysnake Why dont you use Internet Explorer to display the pdf  ?

Expand  

This solution still will require AdobeReader.
So in case when you have AdobeReader the best option will be to embed Acrobat with my UDF.
 

@Skysnake try this concept:

....
#include "AcrobatReaderViewer.au3"
....

If  _AcrobatReader_IsInstaled() Then
    ; use
    _Acrobat_Show($sPDF_FileFullPath)
ElseIf .... Then
    ; try other options just ShellExecute ....
Else
    ; Ultimately it may not be any possibility to view the document.
EndIf
....
Func _AcrobatReader_IsInstaled()
    Local $oTemp = ObjCreate("AcroPDF.PDF.1")
    If @error Then Return False
    $oTemp = Null
    Return True
EndFunc
....

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

The solution appears to be a combination of the following:

  • Use the Shortname of the document with FileGetShortName
  • Get the Default app opening the PDF with these commands
  • Local $idPDFAssoc = Run(@ComSpec & " /c " & 'assoc .pdf', "", "", $STDOUT_CHILD)
    ;...
        Local $idPDFAssoc = Run(@ComSpec & " /c " & 'ftype ' & $aArray[1], "", "", $STDOUT_CHILD)
        ; Wait until the process has closed using the PID returned by Run.
        ProcessWaitClose($idPDFAssoc)
        Local $PDFAssociation = StdoutRead($idPDFAssoc)
    ;...
            $PDFPath = $aArray[0] & '"'
            ConsoleWrite("$PDFPath " & $PDFPath & @CRLF) ; path to PDF EXE
            Return $PDFPath

    Open the file with ShellExecute  

  • Close File handles and objects to release, so that next run can use same

:)

 

Skysnake

Why is the snake in the sky?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...