10

I'm after a virtual printer which takes each page of "printed" output and converts into multiple images (one image for each page)... eg. .jpg, or .png, etc..

I'm specifically looking for something to work with Open-Office Writer, but I assume that such a virtual printer would work across the board for any app which can send its output to a "printer".

Is there such a thing in the Ubuntu repository?

PS. I want one "normal" picture image per page.. ie Many images are output.
...(like the Snagit virtual printer in Windows)

2
  • is the image format important? you could print to file, and set the output type as svg?
    – richzilla
    Nov 19 '10 at 19:07
  • The format is not critical in this instance... and I've just realized how little I know about .svg as a picture format... I'd prefer a more general (common) format, but this may suit.... just looked at the "print to file" options, but I can't see the "svg" option anywhere... (I'll take another look at it...
    – Peter.O
    Nov 19 '10 at 19:54
3

Does it need to be an image file rather than a PDF? If not, you could use

sudo apt-get install cups-pdf

With ImageMagick you can convert PDFs to images from the command line but maybe that's getting too longwinded. Also, though I don't have it installed on the machine I'm currently used, I read on blog comment that GIMP can open PDFs...?

2
  • 1
    Thanks.. I do specifially want individual images... I've just added more detail to my question.
    – Peter.O
    Nov 19 '10 at 18:55
  • 1
    I've checked it out a bit more (now that I've learnt a bit more and almost know what I'm doing :), and yes, yes, yes :) ImageMagick works! ...and so easy! ...using one of ImageMagicks tools: convert -density 400 /home/fred/PDF/test.pdf test%d.jpg ... (Also I've learnt just today of a command line app to convert any/all OpenOffice format files to any other; eg. pdf .. it is called unoconv and is available in the Ubunto repository... These two tools working together make it all very simple... Thanks
    – Peter.O
    Nov 21 '10 at 10:02
3

First print your document as pdf and then you can convert it to jpg or png using GIMP.

Printing your document as pdf:

Open your document in open office,and then click pdf option to export your document as pdf or goto file menu and choose export as pdf.

alt text

Converting pdf to jpg|png:

Open your pdf in GIMP(Right click your pdf and then choose Open with GIMP Image Editor)

Now again goto file menu and select the option save as,Now be sure you choose the correct format.Choose JPG or PNG to save that pdf file into image format..

3
  • karthick, I'll try your method, and see how it compares to the one I just posted.... I think though, that based on other .pdf to image foemats methods I've seen.... it may result in a single jpg... (which is not what I want).. .but I'll check now...
    – Peter.O
    Nov 20 '10 at 9:34
  • karthick. When I open -> import the .pdf pages as "layers", it only imports the first page... When I import the pages as "images" it produces multiple gimp documents each of which must be saved manually and individually.. This is definitely no good for a 100 page original .odt ... If I've missed something, please let me know.
    – Peter.O
    Nov 20 '10 at 9:53
  • I'll check into Gimp a bit further, maybe it has a batch feature... Yes, Gimp can save pages indivicually, but I would need batch capability... The ghostscript method works (see my answer), but the image quality is not very good. Gimp's pdf conversion quality is much better (+1).
    – Peter.O
    Nov 21 '10 at 9:38
3

Well, i finally found a way to get it to produce individually numbered jpegs; one per page of printed output.

--(also, see the UPDATE, below)--

First, I added a "Generic-PostScript-Printer"..
Panel -> Sysetm -> Administration -> Printing
or
$ system-config-printer

The next step is, in OpenOffice, to choose [*] Print to file (in the Print dialog)
and save the PostScrip file to wherever you like, eg. ~/print-to-file.ps

The final step is to use ghostscript to do the conversion. It has many output devices.
You can list the devices via: $ gs -h

To output sequentiall numbered jpeg images, this is the command:

$ gs -dBATCH -dNOPAUSE \  
 -sOutputFile=/home/fred/print-to-file.ps.%d.jpeg \  
 -sDEVICE=jpeg /home/fred.print-to-file.ps`   

For the png format, change the filename's sufix to .png.
and use png16 / png256 / etc for -sDEVICE


UPDATE:
I've just now realized that ghostscript can also take a .pdf as input...
So I tried using the .pdf from OpenOffice's Export to PDF option, as the input to gs (ghostscript) ...
The .odt source file was text-only and the resluting images have marginally better kearning, so it may be worth comparing the ".pdf" as imput, vs ".ps" for your specific situation.. font, images etc...

In summary (for this pdf method):

  • Export as PDF
  • $ gs -dBATCH -dNOPAUSE -sOutputFile=/home/fred/print-to-file.pdf.%d.jpeg -sDEVICE=jpeg /home/fred.print-to-file.pdf

UPDATE 2:
Although this method works, the quality of output images was not up to par.
Upping the jpg quality to 100% still produced sub-standard results..
Even tiff images were producing aberrations in the text (no anti-aliasing?).

Maybe there is a way to tweak ghostscript further, but I started looking elsewhere, and thanks to Roddie's suggestion, I've changed my tack and definitely prefer the "non virtual-printer" method of unoconv + ImageMagick (mentioned in my comment to Roddie's answer)... The image quality from ImageMagick is great! ..

A "two line" script of these two commands would make a simple "Nautilus Action", and bypass the need to directly use OpenOffice.
But if you want to convert an unsaved document to images, then you would need you use "cups-pdf" or the menu "File->Save as PDF" option instead of "unoconv".

1

Its not something ive ever needed to do on linux but cups-pdf looks like it might do the job for you. This is available in the software centre or via the terminal:

sudo apt-get install cups-pdf

you can check if everything has worked by going to System > Administration > Printing, and you should have a printer there called pdf. As its installed as a printer on the system, it should work with any application that would normally print.

By default these are saved to a folder called PDF under your home folder. It is possible to change this by altering /etc/cups/cups-pdf.conf. Search for the OUT variable and change this to whatever you want.

Im not sure there is anyway to alter the save location on a per-usage basis, perhaps someone with more knowledge would be able to elaborate.

As a side note, Open Office writer already has an option to export to pdf in the file menu.

5
  • Thanks but I don't want a pdf in this particular case... I want one "normal" picture image per page.. ie Many images are output. (I'll add this to my question) ... but its good to know about the cups-pdf
    – Peter.O
    Nov 19 '10 at 18:53
  • Its not pretty, but imagemagick can convert pdfs to images, and theres a post processing section in the cups-pdf.conf that takes any script to run after the file has been created. If your short of other options it might be worth a shot.
    – richzilla
    Nov 19 '10 at 19:02
  • Again thanks, but that won't work for me, because I want to use the standard "Print" option via the command-line.... but its good gneeral knowledge (for some situation down the track).
    – Peter.O
    Nov 19 '10 at 19:07
  • I just realizes that only the "export" option bypasses the print process... and that cups-pdf does use it. (but I'm still looking for the multi image solution)
    – Peter.O
    Nov 19 '10 at 19:26
  • judging from the cups-pdf.conf it seems possible that you can run whatever program or script you like instead of ghostscript, as well as a post-processing script or program, so it should be possible to force it to do what you want with the help of something like imagemagick... ;)
    – JanC
    Nov 20 '10 at 9:38
1

We have taken the sources of cups-pdf and modified them to create svg.

This way we have a virtual network printer that creates svg for all our MS windows users.

As explained above the advantage for Linux users is smaller as they can always output ps or pdf and use inkscape or so to create svg.

However, even for Linux users it can be convenient to 'just print' and pick up the resulting svg in the user directory of the server.

Limitation we have now is that only 1 page (1 svg file) can be output at a time.

I am looking for somebody interested to package the code and place it on an ubuntu ppa.

You can mail me at ftoth AT telfort.nl

Ferry

0

You should also be able to export the file to a PDF one, right from the File menu of open Office.

1
  • I specifically want multiple jpg, or png etc image as output... (like the Snagit virtual printer in Windows) ... but thanks anyhow... Today I've certaily learnt about the pdf output possibilities of OOo :)
    – Peter.O
    Nov 19 '10 at 19:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.