locked
PDF documents printing using Acrobat dll RRS feed

  • Question

  • Hi,

    I tried to print the documents using acrobat namespace & some errors are occurring during debugging.. Input for my program is document url.

    DLL: Reference AcroPDF.dll from COM

    AcroPDFLib.AcroPDF doc = new AcroPDFLib.AcroPDF();

    doc.LoadFile(fileUri);

    doc.printAll();

    DLL: Reference AcroRd32.dll from COM

    Acrobat.AcroAVDoc doc = new Acrobat.AcroAVDoc();

    doc.Open(fileUri, string.Empty);

    Acrobat.AcroPDDoc di = (Acrobat.AcroPDDoc)doc.GetPDDoc();

    int pageCount = di.GetNumPages();

    doc.PrintPagesSilent(0, pageCount - 1, 3, 1, 1);

    doc.Close(1);

    Retrieving the COM class factory for component with CLSID {CA8A9780-280D-11CF-A24D-444553540000} failed due to the following error: 80040154.

    I’m getting the above error. I tried the solution mentioned in the link http://social.msdn.microsoft.com/Forums/en-CA/csharplanguage/thread/08a28a1a-6c16-4fae-9b9b-d395a9024d06.

    I registered the dll using the cmd regsvr32 acrord32.dll & I’m getting another error Module acrord32.dll failed to load

    Please correct my error in the code.


    Anandhan.S




    Tuesday, October 4, 2011 12:34 PM

Answers

  • Hi,

    I’ve resolved the error based on the solution provided in the url http://www.vbforums.com/showthread.php?t=428812

    Solution steps:

    v  DO NOT use the 'Add reference' from COM menu to add the .dll files like AcroRd32.dll, AcroPDF.dll
    Instead, right click on the form/web toolbar, and choose to add items

    v  Choose the Adobe PDF Reader from COM components

    v  Now in your references you can see the inclusive of AcroPDFLib & AxAcroPDFLib component

    v  Place a PDF viewer(axAcroPDF1) into the form & make it invisible

    Code behind:

    axAcroPDF1.src = fileUri;                                    

    axAcroPDF1.printAll();

    Acrobat namespace will work if we have adobe professional suite.

    Project properties à Build à Platform target should be x86

    Thursday, October 6, 2011 11:37 AM

All replies

  • Hello,

    you can read "C# Printing a PDF Silently with Adobe Acrobat" article to know how to print PDF documents with Adobe reader in C#.

    a simple brief code is

    Process p = new Process();
    p.StartInfo.FileName = @"C:\Program Files (x86)\Adobe\Reader 10.0\Reader\AcroRd32.exe";
    p.StartInfo.Arguments = "/t \"Label.pdf\" \"HP4000\" \"HP LaserJet 4100 Series PCL6\" \"out.pdf\"";
    p.CreateNoWindow = true;
    p.Start();
    p.WaitForExit();
    
    


    Any fool can know. The point is to understand.(Albert Einstein)
    Tuesday, October 4, 2011 12:41 PM
  • Hi,

    Input for my program is the document url. how can i achieve it?


    Anandhan.S
    Tuesday, October 4, 2011 3:01 PM
  • args parameter in main(string[] args) recieve application arguments!

    [STAThread]
    static void Main(string[] args)
    {
        //get args count!
        int fileCount = args.Length;
    
        //you can enumerate application arguments!
        foreach (string filePath in args)
        {
        }
    }
    


    Any fool can know. The point is to understand.(Albert Einstein)
    Tuesday, October 4, 2011 9:08 PM
  • Hi,

    I’ve resolved the error based on the solution provided in the url http://www.vbforums.com/showthread.php?t=428812

    Solution steps:

    v  DO NOT use the 'Add reference' from COM menu to add the .dll files like AcroRd32.dll, AcroPDF.dll
    Instead, right click on the form/web toolbar, and choose to add items

    v  Choose the Adobe PDF Reader from COM components

    v  Now in your references you can see the inclusive of AcroPDFLib & AxAcroPDFLib component

    v  Place a PDF viewer(axAcroPDF1) into the form & make it invisible

    Code behind:

    axAcroPDF1.src = fileUri;                                    

    axAcroPDF1.printAll();

    Acrobat namespace will work if we have adobe professional suite.

    Project properties à Build à Platform target should be x86

    Thursday, October 6, 2011 11:37 AM
  • Thanks  for sharing your solution here.

    It's a wonderful solution.

    Thanks for your understanding and support.


    Best Regards,
    Rocky Yue[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, October 7, 2011 8:18 AM
    Moderator