Article View: adobe.acrobat.sdk
Article #22PrintPagesSilent not working
From: rnwcoates
Date: Wed, 29 Apr 2009 15:43
Date: Wed, 29 Apr 2009 15:43
64 lines
3112 bytes
3112 bytes
I have tried the SDK PrintPages and PrintPagesSilent functions with no
results. I do not get a printed page, a dialog box, or an error. This
is running via a simple Windows Forms C# application that displays a
form with a single button. That button calls the class function shown
below.
I can open Acrobat, open a document, and click the print button to
print to the default printer, so I would assume that the Acrobat setup
is not an issue.
Thanks for any help!
- Randy
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using Acrobat;
namespace TestAdobePrinting
{
/// <summary>
/// Prints a PDF file to a given printer using the Adobe SDK.
/// </summary>
class PDFPrinterSDK
{
public static void PrintPDF(string pdfFilePath)
{
CAcroApp acrobat = new AcroAppClass();
acrobat.Hide();
try
{
CAcroAVDoc avdoc = new AcroAVDocClass();
if (avdoc.Open(pdfFilePath, ""))
{
CAcroPDDoc pddoc = (CAcroPDDoc)avdoc.GetPDDoc();
int numPages = pddoc.GetNumPages();
if (! avdoc.PrintPages(0, numPages - 1, 3, 1, 0))
{
// error occurred
throw new ApplicationException("Report did not
print due to Adobe error.");
}
}
else
{
throw new ApplicationException("Adobe SDK cannot
open the file " + pdfFilePath);
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
acrobat.CloseAllDocs();
acrobat.Exit();
acrobat = null;
}
}
}
}
Technical Details
Message-ID:
<ae24dcfa-6b3c-4a73-a81d-77e88f563c63@d2g2000pra.googlegroups.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!d2g2000pra.googlegroups.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 2105b4c04d,e8241d3935116702,start X-Google-Attributes: gid2105b4c04d,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!d2g2000pra.googlegroups.com!not-for-mail From: rnwcoates@gmail.com Newsgroups: adobe.acrobat.sdk Subject: PrintPagesSilent not working Date: Wed, 29 Apr 2009 08:43:50 -0700 (PDT) Organization: http://groups.google.com Lines: 64 Message-ID: <ae24dcfa-6b3c-4a73-a81d-77e88f563c63@d2g2000pra.googlegroups.com> NNTP-Posting-Host: 12.32.28.202 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1241048886 21167 127.0.0.1 (29 Apr 2009 23:48:06 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 29 Apr 2009 23:48:06 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: d2g2000pra.googlegroups.com; posting-host=12.32.28.202; posting-account=DpJbiQoAAACEAbrH0UUaMrDljK5keAop User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; MS-RTC LM 8),gzip(gfe),gzip(gfe)