Click here to Skip to main content
15,887,954 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I got problem when create an instance/object CAcroPDDoc in User laptop for second PDF.
But it can run successfully in my laptop.

The following is my code:
C#
private void PrintPDF(string pFileName)
{
   bool BOpenDoc = false;

   //Create an Acrobat AV Document object
   Type TypeAcrobatAVDoc;
   TypeAcrobatAVDoc = Type.GetTypeFromProgID("AcroExch.AVDoc");
   Acrobat.CAcroAVDoc ObjAdobeAVDoc = (Acrobat.CAcroAVDoc)Activator.CreateInstance(TypeAcrobatAVDoc);
   BOpenDoc = ObjAdobeAVDoc.Open(pFileName, "");

   if (BOpenDoc)
   {
      //Create an Acrobat Document object
      Type TypeAcrobatPDDoc;
      TypeAcrobatPDDoc = Type.GetTypeFromProgID("AcroExch.PDDoc");
      Acrobat.CAcroPDDoc ObjAdobePDDoc = (Acrobat.CAcroPDDoc)Activator.CreateInstance(TypeAcrobatPDDoc);
      ObjAdobePDDoc = ObjAdobeAVDoc.GetPDDoc();

      int IntStartLine = 0;
      int IntEndLine = ObjAdobePDDoc.GetNumPages() - 1;

      ObjAdobeAVDoc.PrintPagesSilent(IntStartLine, IntEndLine, 3, 1, 1);
      ObjAdobePDDoc.Close();
   }
   ObjAdobeAVDoc.Close(Convert.ToInt32(true));
}


private void Button_Click(object sender, EventArgs e)
{
   string strFile1 = "File1.pdf";
   string strFile2 = "File2.pdf";
   PrintPDF(strFile1);
   PrintPDF(strFile2); //Got error
}


Then I got error in below code:
C#
Acrobat.CAcroAVDoc ObjAdobeAVDoc = (Acrobat.CAcroAVDoc)Activator.CreateInstance(TypeAcrobatAVDoc);


Below is the error message:
Creating an instance of the COM component with CLSID {72498821-3203-101B-B02E-04021C009402} from the IClassFactory failed due to the following error: 80010108 The object invoked has disconnected from its clients. (Exception from HRESULT: 0x80010108 (RPC_E_DISCONNECTED)).


User uses Acrobat XI and physical printer.
I use Acrobat Pro DC and Virtual printer.
I don't know exactly what went wrong.

Anyone can help me please?
Thank you.

What I have tried:

I already used many virtual printer like "Microsoft Print to PDF", "One Note", "Microsoft XPS Document Writer".
But no error.
Posted
Comments
[no name] 14-Feb-22 1:41am    
There are multiple versions of XI; with different features; and how they relate to your version, you haven't established.
Member 12721774 14-Feb-22 3:17am    
Hi Gerry, thanks for your response.
So you mean, the root cause is because of the different version of acrobat?
I was wondering why it worked with the first PDF.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900