Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > General Discussion
  New Posts New Posts RSS Feed - Opening a PDF searching for a Topic
  FAQ FAQ  Forum Search   Register Register  Login Login

Opening a PDF searching for a Topic

 Post Reply Post Reply
Author
Message
jabaltie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 Nov 05
Location: Brazil
Status: Offline
Points: 138
Post Options Post Options   Thanks (0) Thanks(0)   Quote jabaltie Quote  Post ReplyReply Direct Link To This Post Topic: Opening a PDF searching for a Topic
    Posted: 06 Dec 05 at 5:57AM

This is not a question about the Quick PDF library...

Say that we have for instance the QuickPDF Reference Guide and we want to open it directly within the GetInformation function.

IOW :

Would there be a way to start Acrobat directly on a bookmark topic ?

Using the WINDOWS START command, the only thing I can do , so far, is to open the PDF :

START  "iSEDQuickPDF 5.11 Reference Guide.pdf"

Would there be arguments to make it search for a string or a bookmark topic ?

Back to Top
Alex View Drop Down
Beginner
Beginner


Joined: 06 Dec 05
Location: United States
Status: Offline
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote Alex Quote  Post ReplyReply Direct Link To This Post Posted: 06 Dec 05 at 10:15AM

If You are using Acrobat 7 there is a paper which list all opening parameters that can be set.

http://partners.adobe.com/public/developer/en/acrobat/PDFOpenParameters.pdf

 

Back to Top
jabaltie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 Nov 05
Location: Brazil
Status: Offline
Points: 138
Post Options Post Options   Thanks (0) Thanks(0)   Quote jabaltie Quote  Post ReplyReply Direct Link To This Post Posted: 06 Dec 05 at 1:30PM
Unfortunatelly I cant use Acrobat 7 because I'm on a Win98 machine.

As far as I know, there is no way to run it on this OS.

On the other hand, I cant go to W2K because I have a mainframe terminal emulator that wont run on it...

So, I have to solve it on version 7...
Back to Top
chicks View Drop Down
Debenu Quick PDF Library Expert
Debenu Quick PDF Library Expert


Joined: 29 Oct 05
Location: United States
Status: Offline
Points: 251
Post Options Post Options   Thanks (0) Thanks(0)   Quote chicks Quote  Post ReplyReply Direct Link To This Post Posted: 06 Dec 05 at 1:47PM
Look at Adobe's IACReference.PDF. You can use the DDE method DocGoToNameDest to go to a named destination, or DocGoTo to go to a specified page. Both work with Reader as far back as version 4, and up to the latest version. Note that not all of the methods will work with Reader.
Back to Top
jabaltie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 Nov 05
Location: Brazil
Status: Offline
Points: 138
Post Options Post Options   Thanks (0) Thanks(0)   Quote jabaltie Quote  Post ReplyReply Direct Link To This Post Posted: 07 Dec 05 at 5:02AM
Maybe one could help me out with a VBScript to do it ?

I mean, a VBScript to open a PDF file and then issue a DocGoToNameDest("COMPUTE") for instance...
Back to Top
chicks View Drop Down
Debenu Quick PDF Library Expert
Debenu Quick PDF Library Expert


Joined: 29 Oct 05
Location: United States
Status: Offline
Points: 251
Post Options Post Options   Thanks (0) Thanks(0)   Quote chicks Quote  Post ReplyReply Direct Link To This Post Posted: 07 Dec 05 at 12:17PM
DDE isn't supported by VBScript. Here's a simple examle in "C". Note that it hasn't been fully tested. A .zip with source and .exe is here:

http://www.geocities.com/sea_sbs/files/pdfc.zip

usage examples:

pdfc -p 33 e:\temp\mypdf.pdf (go to page 33 of doc)

pdfc -d "compute" e:\temp\mypdf.pdf (go to named dest)

------------------------------------------------------

#include <windows.h>
#include <ddeml.h>
#include <string.h>
#include <stdio.h>


// Determine if Acrobat or Reader is running
BOOL isAdobeRunning()
{
    HWND hWndAdobe=0;

    // Find window with classname "AcobeAcrobat"
    hWndAdobe = FindWindow("AdobeAcrobat", NULL);
    return(hWndAdobe ? TRUE : FALSE);
}

void usage(char *p)
{
    printf("usage:\t%s [options] [drive:]<pdfpath>\n", p);
     printf("options:\n");
    printf("\t-d destination (go to named dest. Surround in quotes if spaces embedded)\n");
    printf("\t-p page : (go to page)\n");
     exit(0);
}

// Callback function for DDE messages
HDDEDATA CALLBACK DDECallback(     UINT wType,
                    UINT wFmt,
                    HCONV hConv,
                    HSZ hsz1,
                    HSZ hsz2,
                    HDDEDATA hDDEData,
                    DWORD dwData1,
                    DWORD dwData2)
{
     switch (wType) {

     default:
          return NULL;
          break;
     }
}


// Send a DDE execute request to Acrobat/Reader
static BOOL SendExecCmd(LPSTR lpszCmd)
{
     DWORD dwDDEInst = 0;
     UINT ui;
     HSZ hszApplication;
     HSZ hszTopic;
     HCONV hConv;
     HDDEDATA hExecData;

     // Initialize DDEML
     ui = DdeInitialize(&dwDDEInst,
               DDECallback,
               CBF_FAIL_ALLSVRXACTIONS,
               0l);

     if (ui != DMLERR_NO_ERROR) {
          return FALSE;
     }

     // Initiate a conversation with the acroview application
     // on the control topic.
     hszApplication = DdeCreateStringHandle(     dwDDEInst,
                              "acroview",
                              CP_WINANSI);

     hszTopic = DdeCreateStringHandle(dwDDEInst,
                         "control",
                         CP_WINANSI);

     hConv = DdeConnect(dwDDEInst,
               hszApplication,
               hszTopic,
               NULL);

     // Free the HSZ now
     DdeFreeStringHandle(dwDDEInst, hszApplication);
     DdeFreeStringHandle(dwDDEInst, hszTopic);

     if (!hConv) {
          return FALSE;
     }

     // Create a data handle for the exec string
     hExecData = DdeCreateDataHandle(dwDDEInst,
                         lpszCmd,
                         lstrlen(lpszCmd)+1,
                         0,
                         NULL,
                         0,
                         0);

     // Send the execute request
     DdeClientTransaction(     (void FAR *)hExecData,
                    (DWORD)-1,
                    hConv,
                    NULL,
                    0,
                    XTYP_EXECUTE,
               10000, // ms timeout
                    NULL);

     // Done with the conversation now.
     DdeDisconnect(hConv);

     // Done with DDEML
     DdeUninitialize(dwDDEInst);

     return TRUE;
}

int main(int argc, char* argv[])
{
     char szFile[MAX_PATH];
     char szPath[MAX_PATH];
    char cmd[MAX_PATH*2];
    char dest[MAX_PATH];
     char *p;
    int page=0;
     int i;

    dest[0] = '\0';

    if (argc < 2)
     {
          usage(argv[0]);
          return 0;
     }

     for(i=1;i<argc;i++)
     {
          p = argv;

          if(*p == '-')
          {
               if(++i >= argc)
                    usage(argv[0]);

               switch (*(++p)) {
               case 'p' :
                         p = argv;
                         if(!isdigit(*p)) {
                        printf("Invalid Page: %s\n", p);
                         }
                         else {
                        page = atoi(p);
                        printf("Page: %ld\n", page);
                         }

                         continue;
               case 'd' :
                         p = argv;
                    strcpy(dest, p);
                    printf("Dest: %s\n", dest);

                         continue;
               default:
                    continue;
            }
        }

        // Construct full path to file
        strcpy(szPath, argv);

        // Get the path to the executable
        ZeroMemory (szFile, MAX_PATH);
        FindExecutable(szPath, NULL, szFile);
        if (!szFile[0])
        {
            printf("'%s' not found or Adobe Acrobat or Reader not installed.\n", szPath);
            continue;
        }

        // Make sure it's a PDF file
        p = strrchr(szPath,'.');
        if(p==NULL)
        {
            printf("Not a PDF file: '%s'\n", szPath);
            return(1);
        }

        if( stricmp(p,".pdf")!=0)
        {
            printf("Not a PDF file: '%s'\n", szPath);
            return(1);
        }

        // Open Reader
        ShellExecute(NULL,"open",szFile,NULL,NULL,SW_NORMAL);

        Sleep(3000);

        if(!isAdobeRunning())
            Sleep(3000);

        // Send the DocOpen DDE command
        sprintf(cmd,"[DocOpen(\"%s\")]", szPath);
        printf("cmd: %s\n", cmd);
        SendExecCmd(cmd);

        // Send the Page or NamedDest DDE command
        if(page > 0) {
            sprintf(cmd,"[DocGoTo(\"%s\",%ld)]", szPath, page);
            printf("cmd: %s\n", cmd);
            SendExecCmd(cmd);
        }
        else if(strlen(dest)) {
            sprintf(cmd,"[DocGoToNameDest(\"%s\",\"%s\")]", szPath, dest);
            printf("cmd: %s\n", cmd);
            SendExecCmd(cmd);
        }
    }

    return(0);
}

Back to Top
jabaltie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 Nov 05
Location: Brazil
Status: Offline
Points: 138
Post Options Post Options   Thanks (0) Thanks(0)   Quote jabaltie Quote  Post ReplyReply Direct Link To This Post Posted: 07 Dec 05 at 12:33PM
Hi Chicks

Thank you so much 4 your support !

As a matter of fact, it's not working, unfortunatelly.

Here's the PDF I'm trying to open :

http://www.DES.online.unimep.br/au/cobol8591.pdf

This is the command line I'm using :

pdfc.exe -d "COMPUTE" C:\WORK\COBOL8591.PDF

What happens ?

Get these screens :

http://www.DES.online.unimep.br/au/shot1.jpg
http://www.DES.online.unimep.br/au/shot2.jpg

Thanks again !
Back to Top
chicks View Drop Down
Debenu Quick PDF Library Expert
Debenu Quick PDF Library Expert


Joined: 29 Oct 05
Location: United States
Status: Offline
Points: 251
Post Options Post Options   Thanks (0) Thanks(0)   Quote chicks Quote  Post ReplyReply Direct Link To This Post Posted: 07 Dec 05 at 1:01PM
Jose,

1. The "missing index" warning happens when you open the document manually with Reader, too. Nothing to do with pdfc.exe.

2. Are there any Named Destinations in this document? Going to a Named Dest is not the same thing as searching...
Back to Top
chicks View Drop Down
Debenu Quick PDF Library Expert
Debenu Quick PDF Library Expert


Joined: 29 Oct 05
Location: United States
Status: Offline
Points: 251
Post Options Post Options   Thanks (0) Thanks(0)   Quote chicks Quote  Post ReplyReply Direct Link To This Post Posted: 07 Dec 05 at 2:01PM
Jose,

Here's a VERY BASIC example of a wrapper vbscript for pdfc.exe for PDF files that don't have named destinations. It uses QuickPDF to search through the outline (top level only - you'll need to enhance to search through child levels) for a specified term ("Index", in this case). If it finds the term, it gets the page number from the outline, then execs pdfc.exe with the page number and document path.

You'll need to do some serious enhancements to make it useful.

------------------------------------------------------
Dim QP, objShell
Dim inFileName
Dim id, page, title, term
Dim ret

'-- Init iSedQuickPDF and FSO objects
Set QP = CreateObject("iSED.QuickPDF")
Set objShell = CreateObject("Shell.Application")

'-- Set file name
inFileName = "C:\temp\cobol8591.pdf"

'-- Unlock the PDF library
Call QP.UnlockKey(" -- MY QUICKPDF KEY -- ")

'-- Load the input PDF
ret=QP.LoadFromFile(inFileName)
WScript.Echo ret

'-- Search for the Index
term="Index"

'-- Loop through Outline
id = QP.GetFirstOutline()
Do While id > 0
    title = QP.OutlineTitle(id)
    If title=term Then
        page = QP.GetOutlinePage(id)
        WScript.Echo "Found '" & term & "' on page:" & page
        objShell.ShellExecute "pdfc.exe","-p " & page & " " & inFileName, "", "open", 1
        Exit Do
    End If
    id = QP.GetNextOutline(id)
Loop

'-- Clean up
Set QP = Nothing
Set objShell = Nothing

'-- We're Done!
WScript.Quit(Err)
Back to Top
chicks View Drop Down
Debenu Quick PDF Library Expert
Debenu Quick PDF Library Expert


Joined: 29 Oct 05
Location: United States
Status: Offline
Points: 251
Post Options Post Options   Thanks (0) Thanks(0)   Quote chicks Quote  Post ReplyReply Direct Link To This Post Posted: 09 Dec 05 at 1:19AM
Jose,

This little guy should do what you want:

http://www.geocities.com/sea_sbs/files/pdfsrch.zip

Searches recursively through all bookmarks and children to match a search term from commandline:

pdfsrch "c:\my pdfs\IACReference.pdf" "link annotation"

Will do case-insensitive search and match "Link Annotation" bookmark, then open to its reference page (31) in IACReference.pdf in Reader.

Requires the DLL version of QuickPDF in your path.

Back to Top
jabaltie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 Nov 05
Location: Brazil
Status: Offline
Points: 138
Post Options Post Options   Thanks (0) Thanks(0)   Quote jabaltie Quote  Post ReplyReply Direct Link To This Post Posted: 09 Dec 05 at 8:05AM
You offer a finger and I want the whole arm...

The thing is : sometimes a WHOLE WORD search is needed... In my case, I searched for COMPUTE, from the COMPUTE verb. However, it found OBJECT-COMPUTER before... This wasnt the topic I wanna open upon...

BTW, only today I read your posting about that Girl From Ipanema. I'm far away (500km) from her ! I'm on the interior side of the Country and she's in Rio, which is on the coast, of course.

Where are U talking from ?
Back to Top
chicks View Drop Down
Debenu Quick PDF Library Expert
Debenu Quick PDF Library Expert


Joined: 29 Oct 05
Location: United States
Status: Offline
Points: 251
Post Options Post Options   Thanks (0) Thanks(0)   Quote chicks Quote  Post ReplyReply Direct Link To This Post Posted: 09 Dec 05 at 12:12PM
OK, download it again. I changed from a simple "instr" match to a regex match, so you will have the power of regular expression pattern matching to specify exactly how to search.

For the rules of this particular regex engine, search for "REGEXPR" here:

http://www.powerbasic.com/support/help/pbcc/index.htm

Try these two example searches to see the difference:

pdfsrch cobol8591.pdf compute
pdfsrch cobol8951.pdf "\bcompute\b"

The pattern can get a lot more complex than this simple example. Make sure to enclose the regex pattern in quotes, or the CMD shell may try to interpret them.

Back to Top
jabaltie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 Nov 05
Location: Brazil
Status: Offline
Points: 138
Post Options Post Options   Thanks (0) Thanks(0)   Quote jabaltie Quote  Post ReplyReply Direct Link To This Post Posted: 12 Dec 05 at 7:15AM
Great !

Now it's fine !

Once more, thank you !
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store