Solved

Acrobat Issue

Posted on 2003-11-06
7
1,155 Views
Last Modified: 2007-12-19
I'm trying to automate opening Acrobat Reader and printing a pdf file using the Acrobat ActiveX control.  I create the PDF control just fine, but for one reason or another the LoadFile fails.  I think I'm missing something, because Acrobat Reader is not showing up in the task manager.  I'm using Acrobat 6.0 and MS Visual C++ .NET 2003 (7.1).  Does anyone know what I'm doing wrong?  Any help would be greatly appreciated.  

#include <iostream>
#include <string>

#import "C:\PROGRA~1\Adobe\ACROBA~1.0\Reader\ActiveX\pdf.tlb"

using namespace std;

int main()
{
  CoInitialize(NULL);
  try
  {
    PdfLib::_DPdfPtr pdf;
    HRESULT hr = pdf.CreateInstance("PDF.PdfCtrl.5"); // Returns S_OK
    hr = pdf->LoadFile("c:\\vpd.pdf"); // Throws error
    hr = pdf->Print();
  }
  catch(_com_error &ce)
  {
    string error = ce.ErrorMessage(); // Error says "Catastrophic failure"
  }

  CoUninitialize();
}
0
Comment
Question by:mnashadka
7 Comments
 
LVL 4

Expert Comment

by:AmitAgarwal
Comment Utility
I guess you have to take the memership of the Adobe to get the SDK.
Because there might be lot of internal flags which you are not aware of may be set before you call LoadFile

amit
0
 
LVL 44

Expert Comment

by:AndyAinscow
Comment Utility
Does the file exist and is it a pdf file?
0
 
LVL 8

Author Comment

by:mnashadka
Comment Utility
Yes, the file exists and is a pdf file.  I even moved it to the root of the C: drive so that I could avoid any issues with spaces in the file name or whatever.
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 44

Expert Comment

by:AndyAinscow
Comment Utility
Does the LoadFile function require any other options setting?  
0
 
LVL 8

Author Comment

by:mnashadka
Comment Utility
That's what I'm asking.  There is very little in the imported tlh file as far as member functions, and nothing that looked obvious.
0
 
LVL 25

Accepted Solution

by:
clockwatcher earned 250 total points
Comment Utility
Per the Acrobat SDK docs, Acrobat Reader doesn't support OLE automation.  Supposedly you'd have to use DDE.  The full blown Acrobat does support automation.  Here's a sample that prints a page.

#include "stdafx.h"
#include <iostream>
#include <string>

using namespace std;

#import "C:\Program Files\Adobe\Acrobat 5.0\Acrobat\acrobat.tlb"

int _tmain(int argc, _TCHAR* argv[])
{

  CoInitialize(NULL);
  try
  {
        Acrobat::CAcroAVDocPtr pAVdoc("AcroExch.AVDoc");
        pAVdoc->Open("c:\\testsign.pdf", "");
        pAVdoc->PrintPagesSilent(0, 0, 1, 0, 1);
        pAVdoc->Close(1);
  }
  catch(_com_error &ce)
  {
    string error = ce.ErrorMessage(); // Error says "Catastrophic failure"
  }

  CoUninitialize();
}

The PDF.tlb you're referencing deals with the PDF.ocx control and I'm pretty sure that has to be hosted within a container for you to get it to work.
0
 
LVL 8

Author Comment

by:mnashadka
Comment Utility
Thanks clockwatcher, that's exactly what I needed.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now