File Printing

This is a discussion on File Printing within the A Brief History of Cprogramming.com forums, part of the Community Boards category; I have a question. I am a novice programmer needing help at work. I need to automate printing of several ...

  1. #1
    jloyd01
    Guest

    Question File Printing

    I have a question. I am a novice programmer needing help at work. I need to automate printing of several pdf files. A single pdf is created that needs to go to one or more clients in my company. I am in charge of automating this task. I have written a program in perlscript that does everything except the acual printing of the pdf. I need a way to simply print these pdf's out without user interaction. A command line program that accepts the file name would be useful. Any help on where to start?

  2. #2
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,738
    what compiler are you using?

    If you are using fstreams (fstream.h), try using an ofstream with the file PRN....then you can print...

    ex:

    ofstream print ( "PRN" );
    print << "Printing to the printer......";
    My Website

    "Circular logic is good because it is."

  3. #3
    _B-L-U-E_ Betazep's Avatar
    Join Date
    Aug 2001
    Posts
    1,412
    you would have to write a program that can open/read .pdf files (which is way more complicated than you could probably do as a novice programmer), fstreams just will not cut it.

    Another option is to find a .pdf program that already has a print utility. You would need one that you could spawn and make external input commands to. (like CTRL P)

    Then you may be able to open the file with the program, CTRL P, ENTER, ALT F4.

    That is still pretty complicated and not at all very efficient.

    Look up batch processing of .pdf files. That may help you as well.

    See if you can find a ,pdf handler that is open source. (This won't be an Adobe sort of thing....)

    I would imagine the biggest problem would be conversion of the pdf format into a print format (ASCII, images) that would be recognized by the printer.

    ~Betazep
    Last edited by Betazep; 04-20-2002 at 11:12 PM.
    Blue

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    Well......there is the easiest way....you could simply use the system

    (Assuming you are using windows)

    Code:
    #include <windows.h>
    
    int WINAPI WinMain(HINSTANCE hThisInstance, 
    				   HINSTANCE hPrevInstance, 
    				   LPSTR lpszArgument,
    				   int nFunsterStil)
    
    {
    
    	int nRes;
    
    	nRes = (int)ShellExecute(HWND_DESKTOP,"print",
    		lpszArgument,NULL,NULL,0);
    
    	if(nRes<32)	
    	MessageBox(HWND_DESKTOP,"Could not print","ERROR",MB_OK);
       
        return 0;
    }
    Compile as "PrintPDF" or whatever...

    Use as a commandline

    PrintPDF MyPdfFile.pdf
    You will not see anything going to screen........but it should spit the document out of the printer.....

    That's about the simplest and most effective way I can think of.

  5. #5
    jloyd01
    Guest

    Thumbs up

    That helps alot. I am using windows and thought I could do somthing like that, but have never tried printing before. I found an extensive JAVA library for handling pdf's but it didn't seem to easy to print. Mainly most of the open source stuff out there is centered on making pdf's.

  6. #6
    jloyd01
    Guest

    Question

    Fordy, thanks for the code however I must be doing something wrong. I have a copy of MS Visual C/C++ that I am using to compile my c programs. It gives me this error

    "Linking...
    LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
    Debug/printPDF.exe : fatal error LNK1120: 1 unresolved externals
    Error executing link.exe.

    printPDF.exe - 2 error(s), 0 warning(s)"

    The program will compile but not link. I don't understand modt of the code, so I couldn't find the error. Maybe I don't have a proper headder file installed.

    JOhn

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Formatting a text file...
    By dagorsul in forum C Programming
    Replies: 12
    Last Post: 05-02-2008, 04:53 AM
  2. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 04:44 PM
  3. Inventory records
    By jsbeckton in forum C Programming
    Replies: 23
    Last Post: 06-28-2007, 05:14 AM
  4. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 11:12 PM
  5. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 05:10 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21