Git Product home page Git Product logo

Comments (7)

SokoloffA avatar SokoloffA commented on June 27, 2024

Sorry for silence. I am on vacation

пятница, 3 июля 2015 г. пользователь michaelweghorn написал:

Currently, Boomaga does not support sending multiple files in one print
job. Only the first file of the print job is taken into account by Boomaga.

Example command for printing multiple files in one print job on the
command line:
lp -d Boomaga first.pdf second.pdf

Only "first.pdf" is taken into account by Boomaga (is added to the
"Jobs"), not "second.pdf".

It would be great if Boomaga could support sending several files in one
print job.

I have tested this with Debian Jessie and a current build of Boomaga's
master branch (commit a3e0347
a3e0347
).

In the real use case, the files are not sent to the printer on the command
line but created by LibreOffice's mail merge (form letter) feature and sent
to the printer by LibreOffice as one print job.


Reply to this email directly or view it on GitHub
#29.

Best regards,
Alexander.

from boomaga.

SokoloffA avatar SokoloffA commented on June 27, 2024

I use a (http://www.cups.org/documentation.php/doc-2.1/api-filter.html)[file backend] for CUPS (only this backend does not require a daemon). Unfortunately, the file backend does not support multiple files in a single job. So I can't do it just now.
I opened a bug, I hope they will add this feature https://www.cups.org/str.php?L4710

from boomaga.

michaelweghorn avatar michaelweghorn commented on June 27, 2024

I further examined this.
It seems like the backend actually does get all of the files, but as multiple PDF files simply concatenated each after the other (not as a real PDF file with two pages).
You can see that when directly using the "file" backend to save to a file that which would otherwise be passed to the backend.

To do so:

  • Create two input files: echo first > /tmp/first; echo second > /tmp/second
  • Set FileDevice Yes in /etc/cups/cups-files.conf
  • Set up a print queue that simply writes everything it gets into a file: sudo lpadmin -p tofile-printer -v file:/var/spool/cups/tofile-printer -E -P boomaga.ppd
  • Print both files in a single print job: lp -d tofile-printer /tmp/first /tmp/second

The file /var/spool/cups/tofile-printer is created. When opening it with a text editor (e.g. vim), one can see that it consists of two single PDF file, whose content is simply concatenated:

%PDF-1.3
[further content of first PDF file]
%%EOF
%PDF-1.3
[further content of second PDF file]
%%EOF

If the backend handles this appropriately, it should be possible to extract the single PDF files again.
I wrote small test CUPS backend in Python to demonstrate what I mean s. attachment). This backend first extracts the single PDF files and then uses pdftk to create a single PDF file out of them.
In order to run it, the tool pdftk needs to be installed. (On Debian jessie, it is contained in the package pdftk).

To use it:

  • replace the value of BASEPATH at the top of the script with a path to a directory that CUPS may write to; possibly create it beforehand
    (the value currently given should probably work; depending on the system, something in $HOME or /tmp may also work)
  • run the following commands:
sudo cp multipdf.py /usr/lib/cups/backend/multipdf # creates the CUPS backend
sudo chmod 700 /usr/lib/cups/backend/multipdf
echo first > /tmp/first; echo second > /tmp/second
sudo lpadmin -p test-multi-input -v multipdf:/ -E -P boomaga.ppd # set up print queue
lp -d test-multi-input /tmp/first /tmp/second # print files

This creates the file /var/spool/cups/result.pdf. When opening the file, one can see that it is a PDF file with two pages, namely the content of the two input files.

I think that by doing a more or less similar thing in boomaga, it might also be possible to handle multiple input files there (extract the single files, add them).

from boomaga.

michaelweghorn avatar michaelweghorn commented on June 27, 2024

Here is the test backend. I renamed the file to "multipdf.txt" because uploading Python scripts with the correct file suffix ".py" does not seem to be allowed/supported by GitHub.
multipdf.txt

from boomaga.

SokoloffA avatar SokoloffA commented on June 27, 2024

You are right. I've long wanted to rewrite the backend to C++, it looks lake a good occasion.

from boomaga.

SokoloffA avatar SokoloffA commented on June 27, 2024

I wrote new CPP backend. Now command
for i in {1..9}; do echo "Document # $i" > $i.txt; done lp *.txt works fine
You can test it from cpp_backend branch (git clone https://github.com/Boomaga/boomaga.git --branch cpp_backend)

But pay attention that lp first.pdf second.pdf does not work, CUPS transfer only the first document. It seems that concatenating is a hack or bug, and it may stop working in the future.
Maybe will be better for you to write wrapper for lp command ?

from boomaga.

michaelweghorn avatar michaelweghorn commented on June 27, 2024

Thank you so much for the implementation!

I can reproduce the behaviour you described on Debian jessie.

The problem with the PDF files seems to be a bug in CUPS.
Further details are described in the following bug reports (which refer to each other):

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=793989
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=771259
https://www.cups.org/str.php?L4430

My comment in the first mentioned bug (Debian #793989) is also true for the problem with the PDF files you described:

"I just rebuilt the CUPS packages
currently in Jessie (version 1.7.5-11+deb8u1) with the patch attached to
#771259 and the problem does not occur with this modified version."

The upstream bug for CUPS (last hyperlink) has not yet been resolved.

Therefore, this needs to be resolved in CUPS and nothing is to be done on the side of Boomaga.

from boomaga.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.