Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Acrobat Issue

Posted on 2003-11-06
7
Medium Priority
?
1,162 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
[X]
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
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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 1000 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
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 video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

721 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