Sample Header Ad - 728x90

Unix & Linux Stack Exchange

Q&A for users of Linux, FreeBSD and other Unix-like operating systems

Latest Questions

1 votes
0 answers
44 views
linux lpr option to print double sided?
I am trying to figure out how to print a Postscript file double sided from the command line using lpr or lp commands. Of course I have found lots on the web telling me how to do this but they don't work for me; the file always gets printed single sided. Ubuntu 20.04.6 MATE 1.24.0 CUPS 2.3.1-9ubuntu1...
I am trying to figure out how to print a Postscript file double sided from the command line using lpr or lp commands. Of course I have found lots on the web telling me how to do this but they don't work for me; the file always gets printed single sided. Ubuntu 20.04.6 MATE 1.24.0 CUPS 2.3.1-9ubuntu1.9 The only printer is a HP Color Laserjet Pro M255dw connected wirelessly via a router. It is the default printer as shown by "lpstat -d" (I don't know if this is a "network printer" or not or whether it makes any difference.) lp and lpr are not aliased to anything; the binaries came with the system. The PostScript file was created with "enscript" enscript -DDuplex:true file just prints single sided. Printing double sided from various apps that present a print dialog, e.g. evince, works fine, so there is no doubt about the printer. The lp man page shows -o sides=two-sided-long-edge as a common option. https://www.cups.org/doc/options.html tells me the same thing. Various other web pages tell me the same thing. It doesn't work for me, either with Postscript or plain text; the output is still single sided. No errors or warnings. I have tried various other options for lp and lpr; all always print single sided. (Note: the printer output is formatted; i.e. it is not printing the PostScript source.) lpoptions | tr ' ' '\n' ; I see nothing sbout a "sides" option. lpoptions -l | grep -i side gives Duplex/2-Sided Printing: *None DuplexNoTumble DuplexTumble but lp -o Duplex=DuplexNoTumble file still prints single sided
re2 re2 (11 rep)
May 7, 2025, 08:11 PM
0 votes
0 answers
34 views
Java 11 DocPrintJob throw IOException for -o flags with AIX print spooler
I am using the Java Print Service API (javax.print) to send print jobs to a specific printer queue on an AIX system. While my code works fine with Java 8, switching to Java 11 causes it to fail with an IOException related to the -o flags passed to the AIX print spooler. **Environment Details** 1. Op...
I am using the Java Print Service API (javax.print) to send print jobs to a specific printer queue on an AIX system. While my code works fine with Java 8, switching to Java 11 causes it to fail with an IOException related to the -o flags passed to the AIX print spooler. **Environment Details** 1. Operating System: AIX with the native AIX print spooler (not CUPS). 2. Java Versions: Java 8 (works fine). Java 11 (throws IOException). Upon further inspection, I found that the -o job-sheets=standard flag is being passed to the lpr command by default. The AIX print spooler does not support this flag, which causes the job to fail. > IOException: error=254 running: '/usr/bin/lpr' '-PTESTPRN2' '-J Java > Printing' '-o job-sheets=standard' > '/tmp/javaprint13160595099572358650' usage: lpr [-fghjlmnprs] > [-PPrinter] [-#NumberCopies] [-CClass] > [-JJob] [-TTitle] I create printing spooler using smit spooler -> add queue -> remote I didnt find any option to set banner which is ultimately done jobsheet=standard attribute. For more details: we have printer connected to printserver(dlink small printserver)via usb AIX request to the printserver. Furthermore lpr -p /etc/hosts work from commandline(without -o flag) what can be the reason and solution about this problem?
Subesh poudel (11 rep)
Jan 8, 2025, 12:39 PM • Last activity: Jan 10, 2025, 06:50 PM
1 votes
1 answers
75 views
Temenos Printing Error on AIX: Unsupported lpr Flags (-J and -o) with Semeru Runtime
I'm running a Temenos application on an AIX 7.3 system configured with the AIX spooler. The lpr command works fine when tested manually. However, when the application attempts to print using Java's java.io.PrintService API, I encounter the following error: java.io.IOException: error=254 running...
I'm running a Temenos application on an AIX 7.3 system configured with the AIX spooler. The lpr command works fine when tested manually. However, when the application attempts to print using Java's java.io.PrintService API, I encounter the following error: java.io.IOException: error=254 running: '/usr/bin/lpr' '-PTESTPRN2' '-J Java Printing' '-o job-sheets=standard' '/tmp/javaprint13160595099572358650' usage: lpr [-fghjlmnprs] [-PPrinter] [-#NumberCopies] [-CClass] [-JJob] [-TTitle] [-iNumberColumns] [-wWidth] [Filename ...] It seems the Java code, triggered by Temenos, generates an lpr command with flags (-J and -o) that are not supported by the AIX lpr implementation. The spooler itself is set up correctly and prints without issues when commands are executed manually: lpr -PTESTPRN2 /etc/hosts **What I've tried:** 1. Considered downgrading to Java 8, as it might generate compatible lpr commands and lpr with -j and -o works fine, but Java 11 is currently installed. ***Note:application can't run on java8*** 2. The lpr command works fine when executed manually without unsupported flags (e.g., lpr -PTESTPRN2 /path/to/file). 3. Thought about creating a wrapper script to translate unsupported flags into AIX-compatible ones, but I'm unsure how to integrate it with Temenos. 4. Write sample Java code that uses JPS to print and got same error with java11 but works on java8. 5. Run the sample Java code with wrapper script.  It works, but still Temenos gave the same error. **Sample Java Code for Testing**
import javax.print.*;
import javax.print.attribute.*;
import javax.print.attribute.standard.*;
import java.io.*;

public class PrintHostsFileWithQueue {
    public static void main(String[] args) {
        String printerName = "TESTPRN2"; // Replace with your print queue name

        try {
            // Specify the file to print
            File file = new File("/etc/hosts");
            if (!file.exists()) {
                System.out.println("The file /etc/hosts does not exist.");
                return;
            }

            // Create a FileInputStream for the file
            FileInputStream fis = new FileInputStream(file);

            // Define the document flavor (plain text)
            DocFlavor flavor = DocFlavor.INPUT_STREAM.TEXT_PLAIN_UTF_8;
            PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet();
            attributes.add(new Copies(1)); // Number of copies
            attributes.add(new JobSheets(JobSheets.NONE, JobSheets.NONE));

            // Get all available print services
            PrintService[] printServices = PrintServiceLookup.lookupPrintServices(flavor, null);

            // Find the specified print queue
            PrintService selectedService = null;
            for (PrintService service : printServices) {
                if (service.getName().equalsIgnoreCase(printerName)) {
                    selectedService = service;
                    break;
                }
            }

            if (selectedService == null) {
                System.out.println("Printer with name '" + printerName + "' not found.");
                fis.close();
                return;
            }

            // Create a print job
            DocPrintJob printJob = selectedService.createPrintJob();

            // Create a Doc object wrapping the input stream
            Doc doc = new SimpleDoc(fis, flavor, null);

            // Print the document
            printJob.print(doc, null);

            System.out.println("Printing /etc/hosts to printer: " + printerName);
            fis.close();
        } catch (FileNotFoundException e) {
            System.out.println("File not found: " + e.getMessage());
        } catch (PrintException e) {
            System.out.println("Error during printing: " + e.getMessage());
        } catch (IOException e) {
            System.out.println("Error closing the file: " + e.getMessage());
        }
    }
}
**Wrapper Script**
#!/bin/bash

# Step 1: Backup the existing lpr binary
if [ -f /usr/bin/lpr ]; then
    echo "Backing up the existing /usr/bin/lpr..."
     mv /usr/bin/lpr /usr/bin/lpr.original
else
    echo "/usr/bin/lpr does not exist. Exiting."
    exit 1
fi

# Step 2: Create the new lpr wrapper script
echo "Creating the new /usr/bin/lpr wrapper script..."

cat  /dev/null
#!/bin/bash
# Remove unsupported options and pass others to the original lpr
ARGS=()
for arg in "$@"; do
    case "$arg" in
        -o*|*-J*) ;; # Ignore unsupported options
        *) ARGS+=("$arg") ;;
    esac
done
/usr/bin/lpr.original "${ARGS[@]}"
EOF

# Step 3: Make the new script executable
echo "Making /usr/bin/lpr executable..."
chmod +x /usr/bin/lpr

# Step 4: Confirm the change
echo "lpr wrapper script has been created and is now executable."
echo "Test the print command to confirm it's working."
Subesh poudel (11 rep)
Dec 19, 2024, 04:04 PM • Last activity: Dec 19, 2024, 07:52 PM
-1 votes
1 answers
22 views
How can start the job in the printer's queue
List all jobs in my printer: lpq -a Rank Owner Job File(s) Total Size 1st debian 20 2482850685dzfp_2433200000024816 132096 bytes How can start the job in the printer's queue then? [1]: https://i.sstatic.net/53QMGS9H.png
List all jobs in my printer: lpq -a Rank Owner Job File(s) Total Size 1st debian 20 2482850685dzfp_2433200000024816 132096 bytes How can start the job in the printer's queue then?
showkey (499 rep)
Jul 27, 2024, 12:26 AM • Last activity: Jul 27, 2024, 01:03 AM
1 votes
1 answers
186 views
How to print on endless paper on a CUPS printer using lp/lpr?
The Situation ----------------- I'm trying to print on a [Brother QL-570](https://support.brother.com/g/b/producttop.aspx?c=us&lang=en&prod=lpql570eus "Brother support page") I set up on a Raspberry Pi using CUPS. The printer is working well using `lp -d Brother_QL-570 test.pdf`. However, when I ins...
The Situation ----------------- I'm trying to print on a [Brother QL-570](https://support.brother.com/g/b/producttop.aspx?c=us&lang=en&prod=lpql570eus "Brother support page") I set up on a Raspberry Pi using CUPS. The printer is working well using lp -d Brother_QL-570 test.pdf. However, when I insert an endless label (a 30m long, 62mm wide label) I want it to print the exact length of the pdf file. For example, if the pdf provided has a format of 62x200, I want the printer to produce a 62mmx200mm long label. If I use my Windows machine this works, but with lp, it doesn't. lpoptions -p Brother_QL-570 -l yields the following: https://pastebin.com/yBJHw7a7 . CUPS has [these settings](https://drive.google.com/file/d/1R5uMX46Qfb52yDMFanejrm6Em7EVoYKj/view?usp=sharing) The printed label is always 62mmx100mm. I did use brpapertoollpr_ql570 -P Brother_QL-570 -n long_label -w 62 -h 200 in combination with lpr -P Brother_QL-570 -o media=long_label test.pdf to successfully to print 62mmx200mm labels, but creating a new media size for every new pdf I want to print would be quite tedious. Log files ----------------- Job 26 is from windows (working) Job 27 is from lpr (too short) [CUPS error_log](https://pastebin.com/SUdu1wDj) printjob-data captured following [this guide](https://wiki.ubuntu.com/DebuggingPrintingProblems#Capturing_print_job_data) job 26 job 27
MrGlue (11 rep)
Aug 25, 2023, 02:47 PM • Last activity: Jul 20, 2024, 04:17 PM
1 votes
1 answers
148 views
How to specify a number of copies in print lpr command using ssh
When I want to print a document using ssh from my local machine I use cat path/to/document.pdf | ssh my_name@server.com lpr This will print my `document.pdf` that is located in my local machine using a printer connected to server.com. If I want to print the `document.pdf` 5 times I do not know how t...
When I want to print a document using ssh from my local machine I use cat path/to/document.pdf | ssh my_name@server.com lpr This will print my document.pdf that is located in my local machine using a printer connected to server.com. If I want to print the document.pdf 5 times I do not know how to do it. I know with lpr I need to do lpr -#5 document.pdf but how to combine that with cat and ssh? I tried cat path/to/document.pdf | ssh my_name@server.com lpr -#5 and cat path/to/document.pdf -#5 | ssh my_name@server.com lpr but none of them worked.
zebda (13 rep)
Feb 20, 2024, 02:14 AM • Last activity: Feb 20, 2024, 04:00 PM
1 votes
1 answers
569 views
How to print multiple copies of a document with lpr and keep the page order
`lpr -# 2 1-2.pdf` mixes the document's page order. The first page is printed two times, then page two is printed two times. Whereas this hacky loop keeps the page order ```sh for i in {1..2} do lpr 1-2.pdf done ``` Is this really by design? --- Arch Linux LTS
lpr -# 2 1-2.pdf mixes the document's page order. The first page is printed two times, then page two is printed two times. Whereas this hacky loop keeps the page order
for i in {1..2}
do lpr 1-2.pdf
done
Is this really by design? --- Arch Linux LTS
jjk (445 rep)
Dec 19, 2023, 07:28 AM • Last activity: Dec 19, 2023, 09:13 AM
0 votes
0 answers
102 views
How to print multiple pdfs using pipe and stdin?
I am attempting to print multiple pdfs from the command line: ``` locate FilesIwantToPrint | grep pdf | lp - ``` This prints the list of pdfs on one page instead of printing the files themselves. Is it possible to achieve the latter behaviour?
I am attempting to print multiple pdfs from the command line:
locate FilesIwantToPrint | grep pdf | lp -
This prints the list of pdfs on one page instead of printing the files themselves. Is it possible to achieve the latter behaviour?
Noga Ha (1 rep)
Aug 9, 2023, 08:47 AM • Last activity: Aug 9, 2023, 09:07 AM
12 votes
3 answers
5742 views
LPR or CUPS print to Airprint printer
I've seen many a blog posting describing the process of using CUPS to present a non-airprint printer to iOS devices. However, I've dug high and low trying to find if anyone has figured out how to print *to* a printer that has an Airprint server baked in. In particular, I've got a Brother HL-2340DW t...
I've seen many a blog posting describing the process of using CUPS to present a non-airprint printer to iOS devices. However, I've dug high and low trying to find if anyone has figured out how to print *to* a printer that has an Airprint server baked in. In particular, I've got a Brother HL-2340DW that works spectacularly from iDevices. If I understand Airprint correctly, iOS does not need to know anything in particular to print to said printer. It more or less spits a PDF over IPP at the printer, and the printer does its thing. The only configuration options I get in iOS is whether I want two-sided printing (defaulting to long edge, or whatever the printer's default duplex option is), and the paper size (i.e. letter vs a4). What I don't want to do is install the binary drivers from Brother (not that I could on OpenBSD) so that I can speak "BR-3" or whatever proprietary printer control language they use. While I understand that their drivers would give me more flexibility in terms of print options, realistically I'm going to use this printer's defaults. In that sense, the more limited Airprint capabilities are perfect. Has anyone successfully gotten one of the various unix print systems (preferably CUPS) to send a print job to an Airprint printer? Since IPP Everywhere seems to still be a dream, it seems Airprint-enabled printers would be a decent enough target for basic printing support, no? Or is the Airprint protocol more proprietary / obfuscated than I'm led to believe?
Peter (231 rep)
Jul 20, 2015, 05:42 PM • Last activity: Dec 26, 2021, 08:47 PM
0 votes
1 answers
178 views
How to reconcile lpstat -s output with lpr invocations
I have a question about `lpstat` on FreeBSD-12.2. Specifically, I cannot see the relationship between he output of `lpstat` and the printer name actually required by `lpr`. For example. I run `lpstat -t` and see this: lpstat -t scheduler is running system default destination: NP4172.HAMILTON.HARTE-L...
I have a question about lpstat on FreeBSD-12.2. Specifically, I cannot see the relationship between he output of lpstat and the printer name actually required by lpr. For example. I run lpstat -t and see this: lpstat -t scheduler is running system default destination: NP4172.HAMILTON.HARTE-LYNE.CA device for CUPS_PCL3_to_File_jbb: /var/spool/cups-pdf/pcl3/cups_to_pcl3.prn device for laserIII_PCL: /var/spool/cups-pdf/byrnejb_hll/laseriii.pcl device for NP4172.HAMILTON.HARTE-LYNE.CA: socket://192.168.216.52 device for NP4173.HAMILTON.HARTE-LYNE.CA: socket://192.168.216.53 device for NP4174.HAMILTON.HARTE-LYNE.CA: socket://192.168.216.54 device for Virtual_PDF_Printer: cups-pdf:/ CUPS_PCL3_to_File_jbb accepting requests since Wed May 5 11:21:40 2021 laserIII_PCL accepting requests since Fri May 21 16:13:32 2021 NP4172.HAMILTON.HARTE-LYNE.CA accepting requests since Mon Jun 14 14:15:06 2021 NP4173.HAMILTON.HARTE-LYNE.CA accepting requests since Mon Jun 14 16:12:44 2021 NP4174.HAMILTON.HARTE-LYNE.CA accepting requests since Fri Jun 11 16:16:28 2021 Virtual_PDF_Printer accepting requests since Mon Apr 12 12:42:45 2021 printer CUPS_PCL3_to_File_jbb is idle. enabled since Wed May 5 11:21:40 2021 printer laserIII_PCL is idle. enabled since Fri May 21 16:13:32 2021 printer NP4172.HAMILTON.HARTE-LYNE.CA is idle. enabled since Mon Jun 14 14:15:06 2021 printer NP4173.HAMILTON.HARTE-LYNE.CA is idle. enabled since Mon Jun 14 16:12:44 2021 printer NP4174.HAMILTON.HARTE-LYNE.CA is idle. enabled since Fri Jun 11 16:16:28 2021 printer Virtual_PDF_Printer is idle. enabled since Mon Apr 12 12:42:45 2021 NP4172.HAMILTON.HARTE-LYNE.CA-528 root 0 Tue Jun 15 09:09:28 2021 But the printer **NP4172.HAMILTON.HARTE-LYNE.CA** is not actually recognized by lpr: lpr -P NP4172.HAMILTON.HARTE-LYNE.CA info.txt lpr: NP4172.HAMILTON.HARTE-LYNE.CA: unknown printer If I do this: lpr -P np4172 info.txt then the the file is spooled and printed. However if I do this I get the unknown printer error: lpr -P NP4172 info.txt lpr: NP4172: unknown printer This host system uses CUPS. I have the /etc/printcap file configured for lpd and the CUPS version of lpd is running (as is shown in the output of lpstat -t). The printer name np4172 is in /etc/printcap and this no doubt is where lpr is checking. But this essential information is apparently not readily found using the expected tools. This has me confused. If I want to find the actual printer names available on a host then what is the command to reveal the real printer names that lpr will accept?
James B. Byrne (125 rep)
Jun 15, 2021, 01:31 PM • Last activity: Jun 15, 2021, 07:23 PM
2 votes
1 answers
717 views
Is it possible to print multiple copies to PDF using CUPS/lpr
I'm testing an application that sends PDFs to a printer, and it may request that multiple copies are printed, sending a command like /usr/bin/lpr -T Document Title -# 10 I don't have access to a physical printer, so I'm using the CUPS generic virtual printer to "print" PDFs to disk. This works, howe...
I'm testing an application that sends PDFs to a printer, and it may request that multiple copies are printed, sending a command like /usr/bin/lpr -T Document Title -# 10 I don't have access to a physical printer, so I'm using the CUPS generic virtual printer to "print" PDFs to disk. This works, however regardless of the number of copies requested, it only prints a single file.
$ echo hello > hello.txt
$ lpr -P PDF -T test -# 2  hello.txt 
$ ls PDF/
test.pdf
Is there a configuration that will respect the copies argument, for example creating hello-1.pdf and hello-2.pdf? - Distribution is Debian 9. - cups: 2.2.1-8+deb9u6 - cups-bsd: 2.2.1-8+deb9u6 - cups-pdf: 2.6.1-22 - grep MaxCopies /etc/cups/cupsd.conf -> MaxCopies 100
snakecharmerb (127 rep)
Apr 30, 2021, 01:55 PM • Last activity: Apr 30, 2021, 02:56 PM
0 votes
0 answers
87 views
How to print a PDF on a larger paper format
I am trying to print a PDF document via the command line. The PDF has the format of a business card. The paper I am printing on is in A6 format. I have tried the following command: ``` lpr -P -o media=A6 ./BusinessCard.pdf ``` The job is sent to the printer (HP Officejet Pro 8620). Then the printer...
I am trying to print a PDF document via the command line. The PDF has the format of a business card. The paper I am printing on is in A6 format. I have tried the following command:
lpr -P  -o media=A6 ./BusinessCard.pdf
The job is sent to the printer (HP Officejet Pro 8620). Then the printer displays the following error message: >Selected print format does not match the paper format. As soon as I confirm the error, the print job is deleted from the queue. Is it possible to print a PDF with a smaller format than the paper loaded via the command line. I want the PDF to be printed in the upper left corner. # EDIT I went through the lpstat lpinfo lpq lpadmin pdfinfo pdftk xpdf man pages but could not find an option to overcome the format issue. Do I have to change my PDF before sending it to the printer?
Molitoris (101 rep)
Apr 26, 2021, 06:54 PM • Last activity: Apr 27, 2021, 01:08 PM
24 votes
6 answers
118988 views
How to show the CUPS printer jobs history?
I am printing some files from a remote computer to a network printer with the lpr command. It apparently worked, but some minutes later when I typed lpstat or lpq, the job had already disappeared, it had probably already printed the file. Is there a way to check the history or the log of my successf...
I am printing some files from a remote computer to a network printer with the lpr command. It apparently worked, but some minutes later when I typed lpstat or lpq, the job had already disappeared, it had probably already printed the file. Is there a way to check the history or the log of my successfully completed jobs in the printer queue?
Santiago (428 rep)
Apr 7, 2014, 10:08 PM • Last activity: Apr 14, 2021, 04:49 PM
4 votes
2 answers
11892 views
How do I get the right `lpr` for cups installed on Ubuntu Server 14.04?
**UPDATE** It appears the lpr in the `lpr` package is not the one that works with cups. The questions is, how do I get the cups version of `lpr` installed? **Old Question** lpr on ubuntu 10.04 includes an option "-o" that lets you pass extra options. lpr on 14.04 does not include this option. Our ap...
**UPDATE** It appears the lpr in the lpr package is not the one that works with cups. The questions is, how do I get the cups version of lpr installed? **Old Question** lpr on ubuntu 10.04 includes an option "-o" that lets you pass extra options. lpr on 14.04 does not include this option. Our application that we are moving relies on lpr and the ability to set certain options so that pages print correctly. The command is: lpr -P PrinterName -o orientation-requested=3 -o position=top-left -o media=Letter -o page-left=0 -o page-right=0 -o page-top=0 -o page-bottom=0 /path/to/file.pdf Worked fine on the old version but on the new server it fails with: usage: lpr [-cdfghlmnpqrstv] [-#num] [-1234 font] [-C class] [-i [numcols]] [-J job] [-Pprinter] [-T title] [-U user] [-wnum] [name ...] So -o was removed? How do we pass options to lpr if the options option was removed?
Nick (1181 rep)
Jun 1, 2014, 03:36 AM • Last activity: Nov 6, 2020, 02:17 AM
0 votes
2 answers
1701 views
Shell script not finding file running in Mac OS X Catalina
Hoping for a suggestion. Using a shell script in Mac OS X Catalina which broke the script. I know there were many security changes but haven't so far figured out modification to access downloads folder. Script errors because it can't get to the file to print. Script is: do shell script "cat `ls -t /...
Hoping for a suggestion. Using a shell script in Mac OS X Catalina which broke the script. I know there were many security changes but haven't so far figured out modification to access downloads folder. Script errors because it can't get to the file to print. Script is: do shell script "cat ls -t /UserName/Downloads/Barcodes*.zpl | head -1 | lpr -P BarcodePrinter -o raw " with administrator privileges Tried several modifications for the location of the file. Downloads folder is still getting file with long name where * would be variable for 20+ characters generated from the barcode file. Printer name still matches but error is: No such file or directory lpr: No file in print request ANY suggestions appreciated. Been searching forums but very much a novice and can't seem to pinpoint the right solution.
beginner (1 rep)
Mar 20, 2020, 10:58 PM • Last activity: Mar 24, 2020, 05:21 PM
20 votes
5 answers
10750 views
What does spool mean for printing?
Mark wrote [a comment][1] for me > I don't know offhand how to make cups not spool, that is, how to make the lpr command only exit after the printer driver has run. What does "spool" for printing mean? Google says it is a verb meaning "send (data that is intended for printing or processing on a peri...
Mark wrote a comment for me > I don't know offhand how to make cups not spool, that is, how to make the lpr command only exit after the printer driver has run. What does "spool" for printing mean? Google says it is a verb meaning "send (data that is intended for printing or processing on a peripheral device) to an intermediate store." What is the intermediate store that printing spool represents, for example, when printing by lpr command Mark seems to relate the meaning of spool with blocking. But I can't figure that out by looking at the definition given by Google. Thanks.
Tim (106420 rep)
Sep 24, 2018, 03:57 PM • Last activity: Feb 28, 2020, 05:27 PM
3 votes
0 answers
3249 views
How to Print All Pages of a PDF using lp or lpr
I'm getting a strange behavior with the lp command on Mac OS Catalina. I have a 12-page PDF file and want to print all pages in the PDF. I'm hoping to print hundreds of PDFs using lp or lpr with a variable number of pages. The following only prints the first page: lp -d MY_PRINTER -o fit-to-page -o...
I'm getting a strange behavior with the lp command on Mac OS Catalina. I have a 12-page PDF file and want to print all pages in the PDF. I'm hoping to print hundreds of PDFs using lp or lpr with a variable number of pages. The following only prints the first page: lp -d MY_PRINTER -o fit-to-page -o media=A4 myfile.PDF These commands also only print the first page: lp -d MY_PRINTER -o fit-to-page -o media=A4 myfile.PDF -o page-ranges=1-999999 lp -d MY_PRINTER -o fit-to-page -o media=A4 myfile.PDF -o page-ranges=1-12 But strangely, this command prints pages 3-12: lp -d MY_PRINTER -o fit-to-page -o media=A4 myfile.PDF -o page-ranges=3-999999 Does anyone know how to force lp (or lpr) to print all N pages of a PDF?
Alex Cook (131 rep)
Dec 22, 2019, 07:16 PM • Last activity: Dec 22, 2019, 07:29 PM
2 votes
0 answers
493 views
Why did duplexing with lpr start giving me blank pages?
I have a system that generates PDFs in an assortment of layouts, then sends them to a printer. I've been doing this exactly the same way religiously¹ for 3 years. The process is scripted and the scripts are under version control. Two computers are involved, one local that commits the source fil...
I have a system that generates PDFs in an assortment of layouts, then sends them to a printer. I've been doing this exactly the same way religiously¹ for 3 years. The process is scripted and the scripts are under version control. Two computers are involved, one local that commits the source files to a repository and pushes them to a remote build server where the PDFs are generated. The output is synced back to the local machine where another script sends them to the printer. The script that sends them to the printer sends odd and even pages separately and waits for user input to confirm that the paper has been flipped. The commands run look something like this (I only changed the normal print runs of 75 to 2 and stripped the full path): # Print 2 of 20170205 in cemaat-sozlu format? (y/n) y lpr -#2 -o Collate=True -o page-set=even -o outputorder=reverse 20170205-cemaat-sozlu.pdf # Page successfully flipped? (y/n) y lpr -#2 -o Collate=True -o page-set=odd 20170205-cemaat-sozlu.pdf About 2 months ago all the duplex formats started coming out with blank pages before each set. For example printing 2 copies of a 4 page PDF which should print pages 4 2 4 2, prompt for a flip, then print 1 3 1 3 started coming out with b 4 2 b 4 2. Strangely enough the odd page run did not spit out blanks. Note there are no blanks in the generated PDFs and as far as I can tell the build system is not suspect as it did not receive any updates at this time and as far as I can tell the problem is not with the source PDFs. I started fiddling with the CUPS printer configuration. No settings seemed relevant at all, but as there are a couple of driver options, I decided to play with that. * HP LaserJet m1522 MFP Series Postscript This is the driver I had been using, is the one marked "(recommended)" by CUPS, but that started giving me blanks. * HP LaserJet m1522nf MFP Foomatic/Postscript This driver works, but page alignment is all out of whack and it gave me blanks on _both_ odd and even print runs (b 4 2 4 2 then b 1 3 b 1 3). * HP LaserJet m1522nf MFP Foomatic/pxlmono This driver gives me garbage. * HP LaserJet m1522nf MFP pcl3, hpcups This driver seems to behave roughly the same as the first one except that printing takes _forever_. I don't think it likes the raster data of page 1 of each PDF and it stops for about 30 seconds in between each set of pages to spool. * HP LaserJet m1522nf MFP hpijs pcl3, 3.16.10 This driver works alright speed wise, and better than the default one in the blanks department. The 4 page sets print fine with no blanks, but the 6 page sets still have blanks (again only on the first pass: b 6 4 2 b 6 4 2 then 1 3 5 1 3 5) Both systems are running Arch Linux. The one doing the printing does get frequent updates and _probably_ got an updated version of something printing related before this started happening. It certainly did a couple weeks _after_ that because I was looking out for cups related packages. I've tested this after the second set of updates but there was no change. Note I've tried printing from acroread and evince, both of which work fine as far as duplexing goes but are not scriptable and have other issues such as page scaling and color rendition issues that just feeding the PDFs to lpr does not have. Note lpr doesn't seem to have this issue with any non-duplexed print jobs. Did something change in lpr that I can fix with either a setting or different usage? Is this a driver bug? What sort of thing should I even be looking for next? **EDIT:** Over 4,200 blank pages and counting later, I can confirm one extra detail. This happens whenever the -o page-set=even argument is used and the source PDF file's page count divided by two is odd. In other words 4 page documents are fine (2÷2=even) but 2 page documents and 6 page documents fail (2÷2=odd and 6÷2=odd). ¹ These are church bulletins in regular and large print editions with and without included sheet music, so this has been done exactly once a week every week.
Caleb (71790 rep)
Feb 5, 2017, 06:53 AM • Last activity: Apr 18, 2019, 07:17 AM
1 votes
1 answers
399 views
How to print non-consecutive pages from a file, 2 pages per sheet?
I readed a lot of information about lp and lpr linux commands. Today Im trying to print 4 non-consecutive pages from a file, 2 pages per sheet. I tryed a lot of commands: This one prints 4 sheets, 8 pages: lp -n 1 -d C1100 -o page-ranges=1,4,5,16 -o number-up=2 /path/to/files/1.pdf This one prints 5...
I readed a lot of information about lp and lpr linux commands. Today Im trying to print 4 non-consecutive pages from a file, 2 pages per sheet. I tryed a lot of commands: This one prints 4 sheets, 8 pages: lp -n 1 -d C1100 -o page-ranges=1,4,5,16 -o number-up=2 /path/to/files/1.pdf This one prints 5 sheets, 10 pages: lp -n 1 -d C1100 -o page-set=1,4,5,16 -o number-up=2 /path/to/files/1.pdf This one prints 4 sheets, 8 pages: lp -P 1,4,5,16 -n 1 -d C1100 -o number-up=2 /path/to/files/1.pdf Now Im lost. Could You help me?
Barragán Louisenbairn (43 rep)
Dec 16, 2016, 06:20 PM • Last activity: Nov 28, 2018, 08:48 PM
0 votes
1 answers
130 views
CUPS + Canon MG5650: page cropped when printing duplex
I am trying to print on my Canon MG5650 via CUPS. I have a driver "Canon MG5600 series - CUPS+Gutenprint v5.2.11" was selected. I ran the following command to print "one-sided". the results seems good (left side of the image below): lpr -P Canon_MG5600_series -o sides=one-sided document.pdf However,...
I am trying to print on my Canon MG5650 via CUPS. I have a driver "Canon MG5600 series - CUPS+Gutenprint v5.2.11" was selected. I ran the following command to print "one-sided". the results seems good (left side of the image below): lpr -P Canon_MG5600_series -o sides=one-sided document.pdf However, when I ran flowing command to print "duplex": lpr -P Canon_MG5600_series -o sides=two-sided-long-edge document.pdf The first page got cropped at the top (right side of the image below). I tried printing via the system dialog and via lpr and I got the same results. Printouts Any idea on how to fix that?
Adam (1 rep)
Sep 18, 2018, 03:59 PM • Last activity: Oct 9, 2018, 12:56 PM
Showing page 1 of 20 total questions