Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Acrobat Issue

Posted on 2003-11-06
7
1,158 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
ID: 9697452
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
ID: 9701979
Does the file exist and is it a pdf file?
0
 
LVL 8

Author Comment

by:mnashadka
ID: 9701994
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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 44

Expert Comment

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

Author Comment

by:mnashadka
ID: 9702016
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
ID: 9708187
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
ID: 9715397
Thanks clockwatcher, that's exactly what I needed.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
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 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.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

840 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