You are not logged in.
For shipping, I need to print parcel labels quite often. These labels are supplied as a single-page PDF, size A4. The content is in landscape format – please refer to this example image. I cannot change the layout of the supplied PDF.
I would like to print the labels on self-adhesive paper. The paper is size A4, containing two separate A5 stickers (landscape). If I print the PDF as-is, the top part of the label will print nicely on the top sticker, the lower part of the label onto the lower sticker. I don't need the lower half of the label (it's just a summary/receipt, and the post office will print their own receipt anyway), and would like to avoid wasting half of the self-adhesive paper.
So, when printing, I select the following options in the printing dialogue:
Paper size: A5
Orientation: landscape (or reverse landscape)
Auto rotate and center is disabled
No scaling is selected
In print preview, everything looks fine: Only the top part of the label is shown, on an (presumably) A5 paper sheet in landscape.
Once I print the sheet, the correct area will be printed – but in portrait. Somewhere between the print preview and the actual printing, the content is rotated 90 degrees and centered horizontally on the A4 paper sheet. Depending on my selection of landscape or reverse landscape in the printing dialogue, the content is vertically shifted to the top or bottom of the page.
I can crop the PDF to size A5 in a PDF editor and print as desired, this however is tedious.
Is there a way to achieve the desired result with the help of just CUPS printing and printing dialogue?
If not, is there a simple way to tell CUPS to send the PDF through a preprocessing stage (such as cpdf -crop…)? I'm more than willing to create a separate printer entry for that.
Last edited by Condor (2019-09-28 16:10:57)
Offline
I think you are already almost there, but select to print only odd pages (option right above scaling). This will only print the first half of the document in A5.
Offline
Just tried your suggestion – unfortunately, no change. The content is still printed in portrait, horizontally centered on the A4 sheet.
Offline
I can crop the PDF to size A5 in a PDF editor and print as desired, this however is tedious.
Why is it tedious? What tool(s) are you using? Have you used pdfcrop or related poppler tools? These can readily be scripted.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
I tested it right before. Very odd. Maybe something like this might be an option:
convert mylabel.pdf -crop 0x50%+0+0 -density 300 +repage pdf:- | lp -dMY_PRINTER_NAMEOffline
Condor wrote:I can crop the PDF to size A5 in a PDF editor and print as desired, this however is tedious.
Why is it tedious? What tool(s) are you using? Have you used pdfcrop or related poppler tools? These can readily be scripted.
It's tedious because it requires several steps. The label is generated on-line, downloaded as PDF. Presently, I open the PDF straight from the browser and hit the print button, done.
Cropping it in Master PDF Editor (which I was using for tests) requires me to store the download, open it in the editor, perform several clicks to crop the file, then print it which requires additional adjustments in the printing dialogue. Using a tool like pdfcrop or poppler reduces some mouse jiggling, but then again requires me to hit the command line. It seems I would replace one piece of tedious work with another.
My aim is to open the generated label, hit print, perhaps change one or two options and be done.
Therefore my second question:
is there a simple way to tell CUPS to send the PDF through a preprocessing stage (such as cpdf -crop…)?
With a second printer config entry (even though it's the same physical printer), the required steps between download and a “print now!” command reduce to essential zero.
Offline
Maybe something like this might be an option:
convert mylabel.pdf -crop 0x50%+0+0 -density 300 +repage pdf:- | lp -dMY_PRINTER_NAME
Thank your for the suggestion. I get the error
convert: attempt to perform an operation not allowed by the security policy `gs' @ error/delegate.c/ExternalDelegateCommand/378.
convert: no images defined `pdf:label.pdf' @ error/convert.c/ConvertImageCommand/3273.Haven't yet investigated the reason more.
As I use cpdf for other stuff rather often, I used
cpdf -mediabox "0mm 148.5mm 210mm 148.5mm" label.pdf -o half-label.pdfwith good results.
Offline
Ah sorry, this is a simple fix. There are policies in place to call external programs and in this case gs (ghost script) is not allowed like almost everything by default.
Edit /etc/ImageMagick-7/policy.xml
...
<policy domain="delegate" rights="exectute" pattern="gs" />
<policy domain="coder" rights="read | write" pattern="PDF" />
</policymap>Either remove the rights="none" line or replace none with execute.
To be perfectly honest it doesn't matter which program to use though, because all we need is the output on stdout to pipe it into lp.
To simplify the process and maybe it allows you what you wanted to do in the first place check this out: https://en.opensuse.org/SDB:Using_Your_ … _with_CUPS
Also there are these projects: https://aur.archlinux.org/packages/tea4cups-svn/ or https://aur.archlinux.org/packages/tea4cups-py3-git/
Unfortunately I have no experience with either of them, but they could provide the functionality you need.
Offline
Can you use a https://en.wikipedia.org/wiki/Paper_cutter and put the half pages into the tray oriented "correctly"? (Right now they're in there rotated by 90° and a tail, that's unlikely what the printer expects)
Offline
Can you use a https://en.wikipedia.org/wiki/Paper_cutter and put the half pages into the tray oriented "correctly"? (Right now they're in there rotated by 90° and a tail, that's unlikely what the printer expects)
Actually … that is a pretty clever solution!
To feed the label, I would need to pull out the paper tray anyway, put the label sheet in and return the tray. There are cheap replacement trays for my printer available on ebay. I will get one, put the A5 label in “upright” and simply hot-swap the trays.
The default printing options for this case will be set with an additional printing queue for the same printer.
Done!
Thank you all for chipping in to help me out!
Offline