Hi, I've made a program to print in Linux. The steps are:
1. Open a new temporary LaTeX file
2. Insert the strings to be printed in LaTeX
3. Close and save the temporary LaTeX file
4. Convert the temporary LaTeX file to DVI file in the shell
5. Convert the DVI file to PS file in the shell
6. Print the PS file with CUPS
7. Delete all the temporary files
The code is like this:
Code:
//Print to file
fstream filestr;
//Insert LaTeX code and strings to be printed here
..........
filestr.close();
//Print this!!!!!
int jobid;
int num_dests;
cups_dest_t *dests;
// Get printer destinations
num_dests = cupsGetDests(&dests);
cups_dest_t *mydest;
// Get the default printer
mydest = cupsGetDest(NULL, NULL, num_dests, dests);
//Convert to DVI
system("latex ./temp-print.tex");
//Convert to PS
system("dvips temp-print -t landscape -o temp-print.ps");
//Print to default printer
jobid = cupsPrintFile(mydest->name, "./temp-print.ps", "tes", 0, NULL);
if (jobid == 0)
puts(ippErrorString(cupsLastError()));
else
{
SDL_Delay(20000); //Delay to make sure the printing job finished
int status;
status = cupsCancelJob(mydest->name, jobid);
system("rm -f ./temp-print.*"); //Delete all temporary files
}
The code works fine. But the problem is, when I executed the code, my program is kind of lagging. I suspected it's because I used 3 calls to sh ( system("latex ./temp-print.tex"); , system("dvips temp-print -t landscape -o temp-print.ps"); , system("rm -f ./temp-print.*"); ). How can I make my program run smoothly?
Thanks in advance.
PS: I see that the board has been maintenanced recently because I couldn't find my previous messages prior to August 2006.