Question

Print routine to open AcroRd32.exe , print file on network, CLOSE AP(this is problem)

Asked by: digdug89

I have asked this question before, but I am still stuck.  I am using a dos batchfile to print a .pdf drawing from our server.  I can get the file to print, however Adobe seems to "hang" after the file is printed.  I have used the /p /t commands to no avail. I have even found a process terminator that will end the process, but I don't think this is a viable solution. It needs to print with no user intervention.  So, what I am asking for is : Simple code either in a batchfile or Vbapp that will accept in 3 parms (printer-name, Directory,filename) and print the correct file.  Such as.....
@echo off
c:
net use lpt1: /delete /y
net use lpt1: \\vactor_wts_nt1\mislaser

cd c:\progra~1\adobe\acroba~1.0\reader
acrord32.exe /p /h c:\shop\shop\PD-58491A-A.Pdf
pv -k -f acrord32.exe

Exit

This code will print the document ok, but will not CLOSE Adobe.  It will not execute pass the print pdf line.  PLEASE HELP!

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2004-01-05 at 12:44:50ID20841450
Tags

print

,

command

Topic

Adobe Acrobat

Participating Experts
7
Points
475
Comments
37

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. VB.NET | Parameters | If parm = NULL
    I have a program that works great as long as I pass my parameters (like program.exe "parm1"). My problem is I want it to do something specific if no parm is passed (like program.exe). Currently if I pass no parm I get a error. What next? Thx!!!
  2. AP div
    Hello. I am trying to create a page using the AP Div option to insert the my links(text). This is the only way I know how to insert elements at the exact places I want it. I drag them to exact area I want them in; however, they will not stay in that location when I open th...
  3. Difference between Paint Shop Prop X and Corel Draw X3…
    Hi. I am new to web graphics, can someone please explain difference between Paint Shop Prop X and Corel Draw X3/X4 ?

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: khkremerPosted on 2004-01-05 at 14:09:49ID: 10047631

Use this command:
AcroRd32.exe /t path printername drivername portname

The /t flag prints and terminates Acrobat Reader

 

by: khkremerPosted on 2004-01-05 at 14:10:49ID: 10047640

BTW: The /h flag that you are using opens Acrobat or Reader in "hidden" mode, but it stays open.

 

by: digdug89Posted on 2004-01-05 at 14:14:20ID: 10047672

Thank you for your post. However, I have used the acrord32.exe /p /t c:\shop\shop\PD-58491A-A.Pdf, but the app still remains open.  After researching this, It seems that Adobe changed this command in 6.0 which we are currently using.  I have used multiple combinations, but have not yet found one that will close Adobe Reader.

 

by: khkremerPosted on 2004-01-05 at 14:24:16ID: 10047752

Don't use /p /t, just /t.

 

by: khkremerPosted on 2004-01-05 at 14:36:17ID: 10047867

The parameter is still documented in the Acrobat 6 SDK. BTW: You don't have to provide all four parameters. It does work if you just specify the file name and the printer name.

 

by: khkremerPosted on 2004-01-05 at 15:53:22ID: 10048331

I think you are right: It looks like Acrobat Reader does not get terminated after the file prints. And it also looks like you need all four parameters. I'll keep looking.

 

by: antonierajPosted on 2004-01-06 at 05:43:11ID: 10052030

yes, I think Adobe reader 6 doesnot suppport /t ...Download Adobe reader 5 - available in
cgim.adobe.com/acrobat/reader18/download.cgi?JustSendFile=Y

Try this out....

The syntax for printing a .PDF document from the command-line is:

PathToAcrobat.exe /t Filename Printer PrintDriver PrinterPort

where:

PathToAcrobat.exe       is the path to Acrobat.exe or Acrord32.exe.
/t                                prints the document and is supposed to terminate.
Filename                     is the path to the .PDF document you wish to print.
Printer                         is the name of the printer you want the document to print on.
PrinterDriver                from the printer's Properties page.
PrinterPort                  The printer's port, which cannot contain any / characters.


Example:
"C:\Program Files\Adobe\Acrobat 5.0\Reader\AcroRd32.exe" /t "C:\Saved\Protect_Your_PC.pdf" \\JSI001\HP2250 "HP Business Inkjet 2250 (PCL5C)" LPT1:

check this also:

http://www.experts-exchange.com/Web/Graphics/Adobe_Acrobat/Q_20706656.html

 

by: antonierajPosted on 2004-01-06 at 05:43:48ID: 10052033

 

by: khkremerPosted on 2004-01-06 at 06:00:51ID: 10052134

Using Reader 5 does however mean that you cannot print any files that use PDF1.5 features.

 

by: digdug89Posted on 2004-01-06 at 06:55:49ID: 10052560

I have tried the command  :\progra~1\adobe\acroba~5.0\reader\acrord32.exe /t c:\filename \\networkprinter , and it seems to have the same result.  The file prints fine, but adobe remains open. Termination of adobe is key for me since I am running this batchfile from our as/400. It needs to close to allow the 400 to finish its processing. Thank you all for your responses! Could it be that I need all 4 parameters? I have use both 5.0 and 6.0 reader.

 

by: antonierajPosted on 2004-01-06 at 07:05:32ID: 10052649



Download Adobe Reader 4 from...
http://cgim.adobe.com/acrobat/reader14/download.cgi?JustSendFile=Y
ftp://ftp.adobe.com/pub/adobe/acrobatreader/win/4.x/ar405eng.exe

what version of pdf  - You use.. 1.3 or 1.4 or 1.5.

Whether u have tested printing via Adobe reader 4 in AS/400 before...

 

by: khkremerPosted on 2004-01-06 at 07:25:54ID: 10052852

I did a few more experiments, and it really looks like this feature (even though still mentioned in the latest SDK documentation) is gone. The problem is that these parameters were never documented. The Developer FAQ just listed them as undocumented and said that some developers were sucessful in using them...

If your objective is to print a PDF file automatically, there are other solutions. Free ones and commercial ones. What type of printer are you using? If it's a Postscript printer, then the solution is pretty straight forward: Just install Ghostscript and use it's pdf2ps filter. Then spool the PS file to your printer. If it's not a PS printer, you can still use Ghostscript with the correct output module for your printer.

I don't have any links to commercial software right now, but I'll be back with more.

 

by: khkremerPosted on 2004-01-06 at 07:31:17ID: 10052908

Traction Software's Batch & Print Pro should be able to do what you want to do. It has both a GUI and a command line interface to print different file types (including PDF). You can download an evaluation version from their web site:

http://www.traction-software.co.uk

 

by: antonierajPosted on 2004-01-06 at 07:39:20ID: 10052983

We have two apps that may help you here:

1. Batch & Print Pro, can print pdf's to multiple printers: http://www.traction-software.co.uk/batchprint/index.html

2. Close App - is a dos program that closes applications, so for example you could do
acrord32.exe print.pdf
closeapp "Acrobat"

this will close any application by looking for the window name:
http://www.traction-software.co.uk/closeapp/index.html

 

by: antonierajPosted on 2004-01-06 at 07:43:14ID: 10053016

khkremer i was type the text & i have not seen you text ...before...submitting..

 

by: antonierajPosted on 2004-01-06 at 08:01:27ID: 10053179


check this out

http://www.planetpdf.com/asp/default.asp?action=9&read=36960&fid=52#97819

Commandline Acrobat 6.0 details found -- with kill application for close Adobe reader

 

by: digdug89Posted on 2004-01-06 at 08:24:29ID: 10053422

Thank you for your suggestions.  One problem I have is, I need to call this app from our as400 and pass 3 parms(printername,directory,filename).  The close app program is similiar to what I currently have.  However, after excuting adobe to print the file, it seems to "hang" until the application is closed through the end task option.  The next line in the batch file will NOT execute until this has happened.  Once closed the rest of the batch file seems to execute normally.  I am checking into ghost script now, but I believe the problem will arise that I need to send the parms. It might be that there is no viable solution for this.  I am coming to that conclusion. User interaction seems to be a must with all these programs.

 

by: khkremerPosted on 2004-01-06 at 08:28:14ID: 10053457

I would not call this "commandline Acrobat 6.0 details found", it's still the same (undocumented) parameter :-)
Killing the application may cause problems depending on the type of printer you are using (at least I think this is what causes the different behavior): On two different machines I have seen two different behaviors: One one machine the AcrRd32.exe command does not return, on my second machine it returned right away and created the print job in the background. In both cases you would have a hard time to find the right moment to kill the process.
Also, starting the reader with the print flag will fail (at least on my system) if onother instance of Acrobat or Reader is already running. You may be able to get around this by specifying the /n parameter (which creates a new instance of Acrobat or Reader).

 

by: khkremerPosted on 2004-01-06 at 08:33:20ID: 10053519

With Ghostscrpt (or Batch&Print Pro) you can write a batch file that takes your three parameters and combines them to a command line for gs or any other program that you need to spool the job, then call the program and just wait until it's done. The program will end automatically (different from Acrobat or Reader).

In the case of gs, you first convert the file to a PS file, which you have to spool to your printer (or to a printable file for your specific printer). You might be able to use the command line lpr command to spool the file to the printer.

 

by: digdug89Posted on 2004-01-06 at 09:27:30ID: 10053979

I am looking at the documentation for GS, but there isn't much there on command line printing.  Can you maybe show me an example of how to create a command from the example below.  I know I can read in the 3 parms into the batchfile. How to convert them for GS to use would be the tricky part for me.  

Current batch file example

c:
cd c:\progra~1\adobe\acroba~1.0\reader acrord32.exe /t c:\shop\%1\%3 \\vactor_wts_nt1\%2

The %variables are the ones I currently use.

 

by: khkremerPosted on 2004-01-06 at 14:40:43ID: 10056810

GS is _NOT_ a tool to do command line printing: It is one part of a tool that will allow you to do command line printing. What printer are you using? If it's a Postscript printer, you would use something like this:

pdf2ps -dLanguageLevel=2 c:\shop\%1\%3 c:\temp\%3.pdf

This will create a temporary file c:\temp\%3.pdf
After you create this temp file, you need to spool it. If you can spool print jobs to your printer with the lpr protocol it becomes very simple:
lpr -P %2 c:\temp\%3.pdf

This is not as simple as just providing a few command line parameters to AcroRd32.exe. If you don't think that you have the experience to get this working, you may want to look at the Traction Software package. As I said, they have a free evaluation version, so you can just download the package and give it a try. This will definitely be easier to implement than the Ghostscript solution.

 

by: khkremerPosted on 2004-01-08 at 04:03:15ID: 10070635

Can you give us a status update?

 

by: digdug89Posted on 2004-01-08 at 06:20:27ID: 10071452

I am looking into ghostscript now.  However, I am still unable to get adobe to close.  My original intention was to use either a batchfile or a VB program.  I will be glad to award the points if I can get gs to print the pdf.  However, it seems the documentation is limited.  

 

by: khkremerPosted on 2004-01-08 at 06:29:29ID: 10071510

What printer are you using?

 

by: antonierajPosted on 2004-01-08 at 06:39:59ID: 10071592


Hi digdug89

Whether Close App /kill app  work for You ?

 

by: antonierajPosted on 2004-01-08 at 07:44:21ID: 10072176

Option Explicit

Private Declare Function WaitForSingleObject Lib "kernel32" _
(ByVal hHandle As Long, _
ByVal dwMilliseconds As Long) As Long

Private Declare Function FindWindow Lib "user32" _
Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long

Private Declare Function PostMessage Lib "user32" _
Alias "PostMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long

Private Declare Function IsWindow Lib "user32" _
(ByVal hwnd As Long) As Long

'Constants used by the API functions
Const WM_CLOSE = &H10
Const INFINITE = &HFFFFFFFF

Private Sub Form_Load()
Command1.Caption = "Print Files"
Command2.Caption = "Close Adobe Reader"
End Sub

Private Sub Command1_Click()
Dim strCommandLine As String
Dim strPrinterName As String
Dim strDriverName As String
Dim strPortName As String
Dim strFileNameToPrint As String

strFileNameToPrint = "c:\test\one.pdf"

strPrinterName = Printer.DeviceName
strDriverName = Printer.DriverName
strPortName = Printer.Port

' Perform some error checking here
      strCommandLine = "C:\Program Files\Adobe\Acrobat 5.0\Reader\AcroRd32.exe /t """ + _
strFileNameToPrint + """ """ + _
strPrinterName + """ """ + _
strDriverName + """ """ + _
strPortName + """"

If (Shell(strCommandLine, vbHide) <> 0)Then
MsgBox "Job has been sent to the printer using the command " + strCommandLine
End If
End Sub


Private Sub Command2_Click()
'Closes the Windows Adobe reader
Dim hWindow As Long
Dim lngResult As Long
Dim lngReturnValue As Long

hWindow = FindWindow(vbNullString, "Adobe Reader")
lngReturnValue = PostMessage(hWindow, WM_CLOSE, vbNull, vbNull)
lngResult = WaitForSingleObject(hWindow, INFINITE)

'Does the handle still exist?
DoEvents
hWindow = FindWindow(vbNullString, "Adobe Reader")
If IsWindow(hWindow) = 1 Then
'The handle still exists. Use the TerminateProcess function
'to close all related processes to this handle. See the
'article for more information.
MsgBox "Handle still exists."
Else
'Handle does not exist.
MsgBox "Program closed."
End If
End Sub


-->untested code..I am working on these...

 

by: digdug89Posted on 2004-01-08 at 08:48:21ID: 10072830

Let me start by thanking everyone for their suggestions and very helpful comments.  It seems this has become more complicated than originally intended.  My main goal was to automate the printing of a .pdf drawing WITHOUT USER intervention.  The only true problem I had was to close Adobe.  It has now become clear that adobe does not really handle command line printing in a manner that would be sufficient for me to use. Thanks antonieraj for your code, however all this has to be done automatically without a user to click.  This was my major headache.  The problem with the close app program is the same one I with the process viewer. Adobe must close before that line will execute. It seems adobe will "hang" until windows end task is initiated. To answer the printer question we have almost all hp's from 820c - hp5000.  I am trying to get this resolved quickly to distribute points for you hard work, however there is only so much time in my day. I must admit my experience in this area is limited, but that is why I am using this forum.  Thanks again for all your suggestions.

 

by: digdug89Posted on 2004-01-08 at 09:06:14ID: 10072985

I thought  I would add my flow of the process that it may help.

1. a user scans a card with a part number.

2. The AS/400 then invokes a pc program to print a pdf document passing that program 3 parms.
    The parms being Printer, Directory, Filename.

3.  The PC program accepts in the 3 parms, prints the .pdf file, and releases control and exits the program, thus
     allowing the 400 to complete.

 

by: khkremerPosted on 2004-01-08 at 09:31:14ID: 10073194

The fact that you are using different printer types will make the Ghostscript based solution more complicated, because you need to switch the GS output format depending on the printer. Have you downloaded the eval version of Batch&Print Pro?
One other option would be to install a CUPS print server (http://www.cups.org). This print server can print PDF documents. It does use Ghostscript in the background, but you are presented with a nice configuration web page and don't have to deal with the Ghostscript setup yourself. Cups runs on pretty much any Unix system. Your script would spool the PDF file to a print queue (again, this can be done with command line lpr), and Cups would take care of converting PDF to the printer format and sending this data to the printer.

 

by: digdug89Posted on 2004-01-08 at 09:56:53ID: 10073384

Our platform is windows 2000.  I have downloaded batch&print pro, but the documentation for any use of a batch file is limited. I am looking into that now.

 

by: elakPosted on 2004-04-05 at 08:14:12ID: 10758010

In order to print and exit acrobat properly, you'll need Acrobat 4

 

by: skyterPosted on 2004-04-14 at 00:49:59ID: 10821163

After compile this, just "pdfprint a.pdf", it will wait until acrobat(or reader) finish print,
then try to close acrobat by sending message WM_CLOSE.

If acrobat has activated and opened some document before run pdfprint,
pdfprint will wait until finish print, buy won't try to close acrobat.

my english poor, if any question please let me know.
 
---------------------------
#include <stdio.h>
#include <windows.h>

HWND hTMPWnd;

void WINAPI LogErr()    
{
  LPVOID lpMsgBuf;

  FormatMessage(
      FORMAT_MESSAGE_ALLOCATE_BUFFER |
      FORMAT_MESSAGE_FROM_SYSTEM |
      FORMAT_MESSAGE_IGNORE_INSERTS,
      NULL,
      GetLastError(),
      MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
      (LPTSTR) &lpMsgBuf,
      0,
      NULL
  );

  MessageBox (NULL, (const char *)lpMsgBuf, "a",MB_OK) ;
  LocalFree( lpMsgBuf );
}

BOOL CALLBACK EnumCallBack(HWND hwnd, LPARAM lParam)
{
  char s[255];
 
  GetWindowText (hwnd, s, 255);
  if (strstr(s, (char *)lParam)) {
    hTMPWnd = hwnd;
    return FALSE;
  }
  else
    return TRUE;

}

HWND FindSubWnd(char * szWnd)
{
  EnumWindows (EnumCallBack, (LPARAM)szWnd);
  return hTMPWnd;

}

int main(int argc, char* argv[])
{
  char szFile[1024];
  DWORD size=1024;
  SHELLEXECUTEINFO ei;
  HWND hWnd;
  int i;
  char szAdobe[255];
  char szAdobeDoc[255];

 
  ZeroMemory( &ei, sizeof(ei) );
  ei.cbSize = sizeof(ei);

  if (argc < 2)
    return FALSE;

  // Get the path to the viewer executable and launch it.
  ZeroMemory (szFile, 1024);
  FindExecutable(argv[1], NULL, szFile);
  if (!szFile[0])
    return FALSE;
  printf ("Acrobat: %s\n", szFile);
  if (strstr(szFile, "AcroRd32"))
    strcpy (szAdobe, "Adobe Reader");
  else
    strcpy (szAdobe, "Adobe Acrobat");


  ei.fMask = SEE_MASK_FLAG_DDEWAIT ;
  ei.lpVerb = "print";
  ei.lpFile = argv[1];
  ei.nShow = SW_HIDE;


  hWnd = FindSubWnd (szAdobe);
 
  ShellExecuteEx (&ei);

  strcpy (szAdobeDoc, szAdobe);
  strcat (szAdobeDoc, " - [");
  strcat (szAdobeDoc, argv[1]);
  strcat (szAdobeDoc, "]");
  if (!hWnd) {
    //LogErr();
    //WaitForInputIdle(ei.hProcess,INFINITE);
    Sleep(10000);

    for(i=0; i<1000; i++) {
      Sleep(1000);
      hWnd = FindWindow(NULL, szAdobeDoc);
      printf ("Find Window: %d\n", hWnd);
      if (!hWnd) {
        SendMessage (FindWindow(NULL, szAdobe), WM_CLOSE, 0, 0);
        goto Final;
      }
    }
  }
  else {
    Sleep(10000);

    for(i=0; i<1000; i++) {
      Sleep(1000);
      hWnd = FindWindow(NULL, szAdobeDoc);
      printf ("Find Window: %d\n", hWnd);
      if (!hWnd) {
        goto Final;
      }
    }
  }

Final:
 
  fclose(fopen("Finish", "w"));
  //LogErr()
      return TRUE;

 

}

 

by: mvrogersPosted on 2004-06-07 at 14:06:08ID: 11253494

It may be too late for another suggestion here, but maybe someone will find it useful.  :)

It sounds to me like the batch file printing was already working really well except for the problem of having the batch file hang until Acrobat exits.  Why not start Acrobat Reader with this command?

start acrord32.exe /p /h c:\shop\shop\PD-58491A-A.Pdf

The start command will cause the batch file to continue execution without waiting for Acrobat Reader to exit.

-- Mark

 

by: mettedraqPosted on 2004-09-24 at 10:50:56ID: 12145816

I have also run into this problem at work... on a windows 2000 or xp machine.. can't remember.. anyways.. it seems that since Acrobat 5.0, adobe does not support the undocumented command /t.. that seems odd to me because they include it in file type printto command in windows.  But then again that could be from me upgrading to 6.0.

The one solution that I have found did not make me happy but is supported.  You simply have to get your hands on an Acrobat 6.0 sdk, which I have not yet found for free..

And program using the API to print from a command line.

Personally there should be a freeware way around this.  Especially for something this simple.

Then again.. it's my company's problem and not mine.  I would just use linux and I'm sure there's something there.  These people are just afraid of anything not windows based.  I guess I should leave it at that.  I'll post more info if I get any but somebody should make a simply pdf print program in c using the acrobat sdk and send it out as freeware and put the link on here..

That would be nice.. and if I have to.. if legal that is.. I would do so... but first I need to find a copy of the SDK..

Mettedraq....

p.s. anything that could help out here as a freeware solution would be gladly accepted by me.. :)

 

by: khkremerPosted on 2004-09-24 at 11:04:10ID: 12145930

Download the Acrobat 5 SDK, it's still available for free. Almost everything from the v5 SKD will work with Acrobat 6. Get it as long as it's still free.

 

by: eicomputerPosted on 2004-11-15 at 14:46:37ID: 12588877

I have been wrestling with the same problem for a few days now. My students send their print jobs as PDF files to a Windows Print Server connected to a Ricoh AP204 color laser printer. All of the students use iMacs running OS X (10.3.6) and there is no acceptable PPD file from Ricoh to allow them to print directly to the AP204 (the problem seems to be that OS X wants to send PS Type 3 commands and the Ricoh only accepts PS Type 2). We got around this by using OS X's ability to save any file in PDF format. I shared a folder on the Windows Print Server and needed a daemon to examine the folder and, when it found files there, print them and then delete them.

This turned out to be rather complicated. However, I came up with a solution using Windows Scripting and a shell extensions ActiveX control written by G. Born (credit is given in the script). The solution uses two three known directories on the Windows Print Server:
1. The script directory
2. The PDF file directory (shared)
3. The Printed file directory (PDFs are moved from (2) as they are printed
The solution runs in an infinite loop and does three things:
1. It deletes any files in the Printed directory and waits 10 seconds
2. It  copies any PDF files found in the PDF directory to the Printed directory and prints them
3. It waits five minutes and then starts over again
The values for the directories and timeouts are easily modified.

The requirements are noted in the script: I use Adobe Reader 6.0.2 and G. Born's ShellExtension.ocx (it can be downloaded from: http://ourworld.compuserve.com/homepages/Guenter_Born/WSHBazaar/WSHExtend.zip along with some very illuminating scripts).

If you need to kill the script it is listed in the Task Manager Processes window as wscript.exe

' Filename:      PrintPDF.vbs
'
' Author:      Br. David Carlson
' Modified:      Wade Eilrich
'
' Reference:      Based partially on nimbdascan.vbs by Brian J. LaSitis
'                 and Linux vcremove by Br. David Carlson. Also uses
'                 the ActiveX control for ShellExtension.ocx written
'                 by G. Born
'
' Date:            01/25/04
'
' Revised:    02/13/04 to keep a separate log file for each of the drives scanned. - Br. David
'               11/13/04 copy, print, log, delete PDF files - Wade Eilrich
'
' Description:      This script scans the C (and any other drives - see end of
'            file) drive(s) for PDF files in TBP directories. It then
'            prints any files it finds and then deletes them to reclaim
'            disk space. The files removed have the form: *.pdf
'               These files are created by students when they want to print
'            from a Mac OS X system to a non-Mac printer.
'            This script should be scheduled to be run on a periodic
'            basis using the AT command.
'
' Assumptions:      The scripts all reside in the C:\MyScripts directory
'            The files all exist in the TBP directory
'            The files are have the .PDF extension
'            The printed files are moved to C:\Printed
'            We create a temporary files called pdf.tmp in the MyScripts directory
'            We create a log file called pdflog.txt in the MyScripts directory
'
' Requirements: ShellExtension.ocx ActiveX Control
'            Acrobat Reader must be installed
'            ShellExtension.ocx is in the MyScripts directory and has been registered
'            using regsvr32 C:\Myscripts\ShellExtension.ocx
'


Option Explicit

Dim cTarget


Sub PrintPDFDirectory(cTarget)
   Const cScriptPath = "c:\MyScripts"   ' Adjust this location as desired.
   Const DeleteReadOnly = True
   Const OpenFileForReading = 1
   Const OpenFileForWriting = 2
   Const OpenFileForAppending = 8

   Dim oShell, fso, tsInFile, tsOutFile, tsFileName, cDir, app, qt, prn, port
   Dim oShExt, code, prnFile, path
   Dim cy, cm, cd, ch, cs, cmin, dt


   'On Error Resume Next        ' not safe in an infinite loop

   Set oShell = WScript.CreateObject("WScript.Shell")
   Set oShExt = WScript.CreateObject("ShellExtension.ShellObjects")

   ' Produce the list of files:

   cDir = Left(cTarget, 1)

   ' Example of how to use different file specifications
 '  oShell.Run "%comspec% /c dir " & cTarget & "*.obj " & cTarget & "*.ilk " & cTarget & "*.pch " & cTarget & _
 '     "*.pdb " & cTarget & "*.idb /s /b > " & cScriptPath & "\vc.tmp", 0, True
 
   ' We are only looking for PDF files
   oShell.Run "%comspec% /c dir " & cTarget & "*.pdf /s /b > " & cScriptPath & "\pdf.tmp", 0, True

   ' Print the files:

   ' Open the text file that contains the directory listing
   ' Put the drive letter into the filename.
   Set fso = WScript.CreateObject("Scripting.FileSystemObject")
   Set tsInFile = fso.OpenTextFile("pdf.tmp")
   Set tsOutFile = fso.OpenTextFile("pdflog" & ".txt", OpenFileForAppending, True)  

   Do While Not tsInFile.AtEndOfStream

      tsFileName = tsInFile.ReadLine

      ' Example of looking at multiple directories for files
'     if (instr(1, tsFileName, "\Debug\", vbTextCompare) > 0) or _
'        (instr(1, tsFileName, "\Release\", vbTextCompare) > 0) then
'        tsOutFile.WriteLine("Deleting: " & tsFileName)

      ' Examine the files in the TBP directory
      ' Print any PDF files found
      if (instr(1, tsFileName, "\TBP\", vbTextCompare) > 0) then

       ' Move the file to the PRINTED directory
         ' It must NOT be a subdirectory of the TBP directory
       prnFile = fso.GetFileName(tsFileName)
       prnFile = "C:\Printed\" & prnFile    ' modify this as necessary
       fso.MoveFile tsFileName, prnFile

         ' Print the file
       code = oShExt.WSHShellExecute("print", prnFile, 1, 1, true)

         ' Log success and errors
       cy = Year(Now)
       cm = Month(Now)
       cd = Day(Now)
       ch = Hour(Now)
       cs = Second(Now)
       cmin = Minute(Now)
         dt = cm & "-" & cd & "-" & cy & " " & ch & ":" & cmin & ":" & cs & " "
         if code > 32 then
            tsOutFile.WriteLine(dt & prnFile & "Printed")
         else
            tsOutFile.WriteLine(dt & prnFile & "Error-" & code)
         end if

       ' Close the Adobe Reader application
         ' First, wait for Reader to open, activate it (to bring it into the foreground)
         ' Finally send it ALT-F4 to close it
         wScript.Sleep(5000)       ' adjust this value as needed
       oShell.AppActivate "Adobe Reader"
       oShell.SendKeys "%{F4}"

     end if
   Loop


   ' Clean up
   tsInFile.Close
   tsOutFile.Close
   Set tsOutFile = Nothing
   Set tsInFile = Nothing

   ' Delete the temporary file, but NOT the log file
   fso.DeleteFile("pdf.tmp"), DeleteReadOnly

   Set oShell = Nothing
   Set oShExt = nothing
   Set fso = Nothing
End Sub

Sub ClearDirectory(cTarget)
   Const FO_DELETE = &H3
   Const FOF_ALLOWUNDO = &H40
   Const FOF_FILESONLY = &H80          '  on *.* (do only files - not directories)
   Const FOF_NOCONFIRMATION = &H10     '  No user prompt

   Dim source, destin, oShExt, code
   source = cTarget
   destin = cTarget

   Set oShExt = WScript.CreateObject("ShellExtension.ShellObjects")
   code = oShExt.WSHFileOperation(FO_DELETE, source, destin, FOF_FILESONLY + FOF_ALLOWUNDO + FOF_NOCONFIRMATION)

   ' Further improvements might include writing failure information to the log
   ' if code <> 0 Then
     ' MsgBox "Deletion error: " & code
   ' end if

   Set oShExt = nothing
End Sub

' Main program loop
' Delete all the files in the PRINTED directory
' Wait 10 seconds
' Print PDF files in the C:\TBP (To Be Printed) directory
' Wait 5 minutes and repeat forever
Do
   ClearDirectory "C:\Printed\*.pdf"
   wScript.Sleep(10000)
   PrintPDFDirectory "C:\tbp\"
   wScript.Sleep(300000)
Loop

--weilrich

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...