|
Packit |
df99a1 |
//C- -*- C++ -*-
|
|
Packit |
df99a1 |
//C- -------------------------------------------------------------------
|
|
Packit |
df99a1 |
//C- DjVuLibre-3.5
|
|
Packit |
df99a1 |
//C- Copyright (c) 2002 Leon Bottou and Yann Le Cun.
|
|
Packit |
df99a1 |
//C- Copyright (c) 2001 AT&T
|
|
Packit |
df99a1 |
//C-
|
|
Packit |
df99a1 |
//C- This software is subject to, and may be distributed under, the
|
|
Packit |
df99a1 |
//C- GNU General Public License, either Version 2 of the license,
|
|
Packit |
df99a1 |
//C- or (at your option) any later version. The license should have
|
|
Packit |
df99a1 |
//C- accompanied the software or you may obtain a copy of the license
|
|
Packit |
df99a1 |
//C- from the Free Software Foundation at http://www.fsf.org .
|
|
Packit |
df99a1 |
//C-
|
|
Packit |
df99a1 |
//C- This program is distributed in the hope that it will be useful,
|
|
Packit |
df99a1 |
//C- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
df99a1 |
//C- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit |
df99a1 |
//C- GNU General Public License for more details.
|
|
Packit |
df99a1 |
//C-
|
|
Packit |
df99a1 |
//C- DjVuLibre-3.5 is derived from the DjVu(r) Reference Library from
|
|
Packit |
df99a1 |
//C- Lizardtech Software. Lizardtech Software has authorized us to
|
|
Packit |
df99a1 |
//C- replace the original DjVu(r) Reference Library notice by the following
|
|
Packit |
df99a1 |
//C- text (see doc/lizard2002.djvu and doc/lizardtech2007.djvu):
|
|
Packit |
df99a1 |
//C-
|
|
Packit |
df99a1 |
//C- ------------------------------------------------------------------
|
|
Packit |
df99a1 |
//C- | DjVu (r) Reference Library (v. 3.5)
|
|
Packit |
df99a1 |
//C- | Copyright (c) 1999-2001 LizardTech, Inc. All Rights Reserved.
|
|
Packit |
df99a1 |
//C- | The DjVu Reference Library is protected by U.S. Pat. No.
|
|
Packit |
df99a1 |
//C- | 6,058,214 and patents pending.
|
|
Packit |
df99a1 |
//C- |
|
|
Packit |
df99a1 |
//C- | This software is subject to, and may be distributed under, the
|
|
Packit |
df99a1 |
//C- | GNU General Public License, either Version 2 of the license,
|
|
Packit |
df99a1 |
//C- | or (at your option) any later version. The license should have
|
|
Packit |
df99a1 |
//C- | accompanied the software or you may obtain a copy of the license
|
|
Packit |
df99a1 |
//C- | from the Free Software Foundation at http://www.fsf.org .
|
|
Packit |
df99a1 |
//C- |
|
|
Packit |
df99a1 |
//C- | The computer code originally released by LizardTech under this
|
|
Packit |
df99a1 |
//C- | license and unmodified by other parties is deemed "the LIZARDTECH
|
|
Packit |
df99a1 |
//C- | ORIGINAL CODE." Subject to any third party intellectual property
|
|
Packit |
df99a1 |
//C- | claims, LizardTech grants recipient a worldwide, royalty-free,
|
|
Packit |
df99a1 |
//C- | non-exclusive license to make, use, sell, or otherwise dispose of
|
|
Packit |
df99a1 |
//C- | the LIZARDTECH ORIGINAL CODE or of programs derived from the
|
|
Packit |
df99a1 |
//C- | LIZARDTECH ORIGINAL CODE in compliance with the terms of the GNU
|
|
Packit |
df99a1 |
//C- | General Public License. This grant only confers the right to
|
|
Packit |
df99a1 |
//C- | infringe patent claims underlying the LIZARDTECH ORIGINAL CODE to
|
|
Packit |
df99a1 |
//C- | the extent such infringement is reasonably necessary to enable
|
|
Packit |
df99a1 |
//C- | recipient to make, have made, practice, sell, or otherwise dispose
|
|
Packit |
df99a1 |
//C- | of the LIZARDTECH ORIGINAL CODE (or portions thereof) and not to
|
|
Packit |
df99a1 |
//C- | any greater extent that may be necessary to utilize further
|
|
Packit |
df99a1 |
//C- | modifications or combinations.
|
|
Packit |
df99a1 |
//C- |
|
|
Packit |
df99a1 |
//C- | The LIZARDTECH ORIGINAL CODE is provided "AS IS" WITHOUT WARRANTY
|
|
Packit |
df99a1 |
//C- | OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
Packit |
df99a1 |
//C- | TO ANY WARRANTY OF NON-INFRINGEMENT, OR ANY IMPLIED WARRANTY OF
|
|
Packit |
df99a1 |
//C- | MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
|
Packit |
df99a1 |
//C- +------------------------------------------------------------------
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
#ifndef _DJVU_TO_PS_H_
|
|
Packit |
df99a1 |
#define _DJVU_TO_PS_H_
|
|
Packit |
df99a1 |
#ifdef HAVE_CONFIG_H
|
|
Packit |
df99a1 |
#include "config.h"
|
|
Packit |
df99a1 |
#endif
|
|
Packit |
df99a1 |
#if NEED_GNUG_PRAGMAS
|
|
Packit |
df99a1 |
# pragma interface
|
|
Packit |
df99a1 |
#endif
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
/** @name DjVuToPS.h
|
|
Packit |
df99a1 |
Files #"DjVuToPS.h"# and #"DjVuToPS.cpp"# implement code that can be
|
|
Packit |
df99a1 |
used to convert a \Ref{DjVuImage} or \Ref{DjVuDocument} to PostScript
|
|
Packit |
df99a1 |
format. The conversion is carried out by the \Ref{DjVuToPS} class.
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
@memo PostScript file generator
|
|
Packit |
df99a1 |
@author Andrei Erofeev <eaf@geocities.com> \\
|
|
Packit |
df99a1 |
Florin Nicsa <Florin.Nicsa@insa-lyon.fr>
|
|
Packit |
df99a1 |
*/
|
|
Packit |
df99a1 |
//@{
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
#include "DjVuGlobal.h"
|
|
Packit |
df99a1 |
#include "GRect.h"
|
|
Packit |
df99a1 |
#include "DjVuDocument.h"
|
|
Packit |
df99a1 |
#include "DjVuText.h"
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
#ifdef HAVE_NAMESPACES
|
|
Packit |
df99a1 |
namespace DJVU {
|
|
Packit |
df99a1 |
# ifdef NOT_DEFINED // Just to fool emacs c++ mode
|
|
Packit |
df99a1 |
}
|
|
Packit |
df99a1 |
#endif
|
|
Packit |
df99a1 |
#endif
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
/** DjVuImage to PostScript converter.
|
|
Packit |
df99a1 |
Use this class to print \Ref{DjVuImage}s and \Ref{DjVuDocument}s.
|
|
Packit |
df99a1 |
The behavior is customizable. See \Ref{DjVuToPS::Options} for the
|
|
Packit |
df99a1 |
description of available options.*/
|
|
Packit |
df99a1 |
class DjVuToPS
|
|
Packit |
df99a1 |
{
|
|
Packit |
df99a1 |
public:
|
|
Packit |
df99a1 |
class DecodePort;
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
/** DjVuToPS options. Use this class to customize the way
|
|
Packit |
df99a1 |
in which DjVu to PS conversion will be done. You can adjust
|
|
Packit |
df99a1 |
the following things:
|
|
Packit |
df99a1 |
\begin{description}
|
|
Packit |
df99a1 |
\item[Format] ({\em EPS} or {\em PS}). Use the {\em EPS}
|
|
Packit |
df99a1 |
format if you plan to embed the output image into another
|
|
Packit |
df99a1 |
document. Print {\em PS} otherwise.
|
|
Packit |
df99a1 |
\item[Language level] ({\em 1} or {\em 2}). Any PostScript
|
|
Packit |
df99a1 |
printer or interpreter should understand PostScript Level 1
|
|
Packit |
df99a1 |
files. Unfortunately we cannot efficiently compress and encode
|
|
Packit |
df99a1 |
data when generating Level 1 files. PostScript Level 2 allows
|
|
Packit |
df99a1 |
to employ an RLE compression and ASCII85 encoding scheme,
|
|
Packit |
df99a1 |
which makes output files significantly smaller. Most of
|
|
Packit |
df99a1 |
the printers and word processors nowadays support PostScript
|
|
Packit |
df99a1 |
Level 2.
|
|
Packit |
df99a1 |
\item[Orientation] ({\em PORTRAIT} or {\em LANDSCAPE})
|
|
Packit |
df99a1 |
\item[Zoom factor] ({\em FIT_PAGE} or {\em ONE_TO_ONE}).
|
|
Packit |
df99a1 |
{\em ONE_TO_ONE} mode is useful, if you want the output to
|
|
Packit |
df99a1 |
be of the same size as the original image (before compression).
|
|
Packit |
df99a1 |
This requires that the #dpi# setting inside the \Ref{DjVuImage}
|
|
Packit |
df99a1 |
is correct. In most of the cases the {\em FIT_PAGE} zoom is
|
|
Packit |
df99a1 |
would be your best choice.
|
|
Packit |
df99a1 |
\item[Mode] ({\em COLOR}, {\em FORE}, {\em BACK}, or {\em BW})
|
|
Packit |
df99a1 |
Specifies how the \Ref{DjVuImage}s will be rendered (all layers,
|
|
Packit |
df99a1 |
foreground layer, background layer, and the mask respectively)
|
|
Packit |
df99a1 |
\item[Color] ({\em TRUE} or {\em FALSE}). Choosing {\em FALSE}
|
|
Packit |
df99a1 |
converts color images to gray scale.
|
|
Packit |
df99a1 |
\item[Gamma] Printer color correction.
|
|
Packit |
df99a1 |
This parameter ranges from #0.3# to #5.0#.
|
|
Packit |
df99a1 |
\item[sRGB] ({\em TRUE} or {\em FALSE}). Choosing {\em TRUE}
|
|
Packit |
df99a1 |
enables accurate sRGB color calibration. This option
|
|
Packit |
df99a1 |
only works with language level 2. When this is set,
|
|
Packit |
df99a1 |
gamma correction is clamped to #2.2#.
|
|
Packit |
df99a1 |
\item[Number of copies] Specifies how many copies should be
|
|
Packit |
df99a1 |
printed. This does {\bf not} affect the size of the output file.
|
|
Packit |
df99a1 |
\end{description}
|
|
Packit |
df99a1 |
*/
|
|
Packit |
df99a1 |
class Options
|
|
Packit |
df99a1 |
{
|
|
Packit |
df99a1 |
public:
|
|
Packit |
df99a1 |
/** Specifies the rendering mode */
|
|
Packit |
df99a1 |
enum Mode { COLOR, FORE, BACK, BW };
|
|
Packit |
df99a1 |
/** Selects the output format */
|
|
Packit |
df99a1 |
enum Format { PS, EPS };
|
|
Packit |
df99a1 |
/** Specifies the orientation of the output image */
|
|
Packit |
df99a1 |
enum Orientation { PORTRAIT, LANDSCAPE, AUTO };
|
|
Packit |
df99a1 |
/** Specifies the booklet mode */
|
|
Packit |
df99a1 |
enum BookletMode { OFF, RECTO, VERSO, RECTOVERSO };
|
|
Packit |
df99a1 |
private:
|
|
Packit |
df99a1 |
Format format;
|
|
Packit |
df99a1 |
int level;
|
|
Packit |
df99a1 |
Orientation orientation;
|
|
Packit |
df99a1 |
Mode mode;
|
|
Packit |
df99a1 |
int zoom;
|
|
Packit |
df99a1 |
bool color;
|
|
Packit |
df99a1 |
bool calibrate;
|
|
Packit |
df99a1 |
bool text;
|
|
Packit |
df99a1 |
double gamma;
|
|
Packit |
df99a1 |
int copies;
|
|
Packit |
df99a1 |
bool frame;
|
|
Packit |
df99a1 |
bool cropmarks;
|
|
Packit |
df99a1 |
BookletMode bookletmode;
|
|
Packit |
df99a1 |
int bookletmax;
|
|
Packit |
df99a1 |
int bookletalign;
|
|
Packit |
df99a1 |
int bookletfold;
|
|
Packit |
df99a1 |
int bookletxfold;
|
|
Packit |
df99a1 |
public:
|
|
Packit |
df99a1 |
/** Sets output image format to #PS# or #EPS# */
|
|
Packit |
df99a1 |
void set_format(Format format);
|
|
Packit |
df99a1 |
/** Sets PostScript level (#1#, #2#, or #3#) */
|
|
Packit |
df99a1 |
void set_level(int level);
|
|
Packit |
df99a1 |
/** Sets orientation (#LANDSCAPE# or #PORTRAIT#) */
|
|
Packit |
df99a1 |
void set_orientation(Orientation orientation);
|
|
Packit |
df99a1 |
/** Sets \Ref{DjVuImage} rendering mode (#COLOR#, #BW#, #FORE#, #BACK#) */
|
|
Packit |
df99a1 |
void set_mode(Mode mode);
|
|
Packit |
df99a1 |
/** Sets zoom factor. Zoom 0 means fit page. */
|
|
Packit |
df99a1 |
void set_zoom(int zoom);
|
|
Packit |
df99a1 |
/** Affects automatic conversion to GreyScale mode. */
|
|
Packit |
df99a1 |
void set_color(bool color);
|
|
Packit |
df99a1 |
/** Sets gamma correction factor. Ranges from #0.3# to #5.0#. */
|
|
Packit |
df99a1 |
void set_gamma(double gamma);
|
|
Packit |
df99a1 |
/** Sets sRGB color calibration flag. */
|
|
Packit |
df99a1 |
void set_sRGB(bool calibrate);
|
|
Packit |
df99a1 |
/** Specifies the number of copies to be printed. */
|
|
Packit |
df99a1 |
void set_copies(int copies);
|
|
Packit |
df99a1 |
/** Specifies if a gray frame around the image should be printed. */
|
|
Packit |
df99a1 |
void set_frame(bool on);
|
|
Packit |
df99a1 |
/** Specifies if crop marks should be printed. */
|
|
Packit |
df99a1 |
void set_cropmarks(bool on);
|
|
Packit |
df99a1 |
/** Specifies if a shadow text should be printed. */
|
|
Packit |
df99a1 |
void set_text(bool on);
|
|
Packit |
df99a1 |
/** Specifies the bookletmode */
|
|
Packit |
df99a1 |
void set_bookletmode(BookletMode m);
|
|
Packit |
df99a1 |
/** Specifies the maximal number of pages in a booklet */
|
|
Packit |
df99a1 |
void set_bookletmax(int m);
|
|
Packit |
df99a1 |
/** Specifies an offset (points) between
|
|
Packit |
df99a1 |
booklet recto(s) and verso(s). */
|
|
Packit |
df99a1 |
void set_bookletalign(int m);
|
|
Packit |
df99a1 |
/** Specifies the margin (points) required to fold
|
|
Packit |
df99a1 |
the booklet (#fold# in points) and the margin
|
|
Packit |
df99a1 |
increase required for each sheet (#xfold# in millipoints). */
|
|
Packit |
df99a1 |
void set_bookletfold(int fold, int xfold=0);
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
/** Returns output image format (#PS# or #EPS#) */
|
|
Packit |
df99a1 |
Format get_format(void) const {
|
|
Packit |
df99a1 |
return format; }
|
|
Packit |
df99a1 |
/** Returns PostScript level (#1# or #2#) */
|
|
Packit |
df99a1 |
int get_level(void) const {
|
|
Packit |
df99a1 |
return level; }
|
|
Packit |
df99a1 |
/** Returns output image orientation (#PORTRAIT# or #LANDSCAPE#) */
|
|
Packit |
df99a1 |
Orientation get_orientation(void) const {
|
|
Packit |
df99a1 |
return orientation; }
|
|
Packit |
df99a1 |
/** Returns \Ref{DjVuImage} rendering mode
|
|
Packit |
df99a1 |
(#COLOR#, #FORE#, #BACK#, #BW#) */
|
|
Packit |
df99a1 |
Mode get_mode(void) const {
|
|
Packit |
df99a1 |
return mode; }
|
|
Packit |
df99a1 |
/** Returns output zoom factor (#FIT_PAGE# or #ONE_TO_ONE#) */
|
|
Packit |
df99a1 |
int get_zoom(void) const {
|
|
Packit |
df99a1 |
return zoom; }
|
|
Packit |
df99a1 |
/** Returns color printing flag. */
|
|
Packit |
df99a1 |
bool get_color(void) const {
|
|
Packit |
df99a1 |
return color; }
|
|
Packit |
df99a1 |
/** Returns sRGB color calibration flag. */
|
|
Packit |
df99a1 |
bool get_sRGB(void) const {
|
|
Packit |
df99a1 |
return calibrate; }
|
|
Packit |
df99a1 |
/** Returns printer gamma correction factor */
|
|
Packit |
df99a1 |
double get_gamma(void) const {
|
|
Packit |
df99a1 |
return ((calibrate) ? ((double)2.2) : gamma); }
|
|
Packit |
df99a1 |
/** Returns the number of copies, which will be printed by printer
|
|
Packit |
df99a1 |
This parameter does {\bf not} affect the size of output file */
|
|
Packit |
df99a1 |
int get_copies(void) const {
|
|
Packit |
df99a1 |
return copies; }
|
|
Packit |
df99a1 |
/** Returns #TRUE# if there will be a gray frame */
|
|
Packit |
df99a1 |
bool get_frame(void) const {
|
|
Packit |
df99a1 |
return frame; }
|
|
Packit |
df99a1 |
/** Returns #TRUE# if there will be a gray frame */
|
|
Packit |
df99a1 |
bool get_cropmarks(void) const {
|
|
Packit |
df99a1 |
return cropmarks; }
|
|
Packit |
df99a1 |
/** Returns #TRUE# if there will be a shadow text printed */
|
|
Packit |
df99a1 |
bool get_text(void) const {
|
|
Packit |
df99a1 |
return text; }
|
|
Packit |
df99a1 |
/** Returns the booklet mode */
|
|
Packit |
df99a1 |
BookletMode get_bookletmode(void) const {
|
|
Packit |
df99a1 |
return bookletmode; }
|
|
Packit |
df99a1 |
/** Returns the booklet max size */
|
|
Packit |
df99a1 |
int get_bookletmax(void) {
|
|
Packit |
df99a1 |
return bookletmax; }
|
|
Packit |
df99a1 |
/** Returns the booklet recto/verso offset */
|
|
Packit |
df99a1 |
int get_bookletalign(void) {
|
|
Packit |
df99a1 |
return bookletalign; }
|
|
Packit |
df99a1 |
/** Returns the folding margin for sheet number #n#. */
|
|
Packit |
df99a1 |
int get_bookletfold(int n=0) {
|
|
Packit |
df99a1 |
return bookletfold + (n*bookletxfold+500)/1000; }
|
|
Packit |
df99a1 |
/* Constructor */
|
|
Packit |
df99a1 |
Options(void);
|
|
Packit |
df99a1 |
};
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
/** Describes current page processing stage. This is passed to
|
|
Packit |
df99a1 |
the #info_cb()# callback. See \Ref{set_info_cb}() for details. */
|
|
Packit |
df99a1 |
enum Stage { DECODING, PRINTING };
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
private:
|
|
Packit |
df99a1 |
void (*refresh_cb)(void*);
|
|
Packit |
df99a1 |
void *refresh_cl_data;
|
|
Packit |
df99a1 |
void (*prn_progress_cb)(double, void*);
|
|
Packit |
df99a1 |
void *prn_progress_cl_data;
|
|
Packit |
df99a1 |
void (*dec_progress_cb)(double, void*);
|
|
Packit |
df99a1 |
void *dec_progress_cl_data;
|
|
Packit |
df99a1 |
void (*info_cb)(int,int,int,Stage,void*);
|
|
Packit |
df99a1 |
void *info_cl_data;
|
|
Packit |
df99a1 |
unsigned char ramp[256];
|
|
Packit |
df99a1 |
GP<DecodePort> port;
|
|
Packit |
df99a1 |
protected:
|
|
Packit |
df99a1 |
void store_doc_prolog(ByteStream&,int,int,GRect*);
|
|
Packit |
df99a1 |
void store_doc_setup(ByteStream&);
|
|
Packit |
df99a1 |
void store_doc_trailer(ByteStream&);
|
|
Packit |
df99a1 |
void store_page_setup(ByteStream&,int,const GRect&,int align=0);
|
|
Packit |
df99a1 |
void store_page_trailer(ByteStream&);
|
|
Packit |
df99a1 |
void make_gamma_ramp(GP<DjVuImage>);
|
|
Packit |
df99a1 |
void print_image_lev1(ByteStream&,GP<DjVuImage>,const GRect&);
|
|
Packit |
df99a1 |
void print_image_lev2(ByteStream&,GP<DjVuImage>,const GRect&);
|
|
Packit |
df99a1 |
void print_bg(ByteStream&,GP<DjVuImage>,const GRect&);
|
|
Packit |
df99a1 |
void print_fg_3layer(ByteStream&,GP<DjVuImage>,const GRect&,unsigned char*);
|
|
Packit |
df99a1 |
void print_fg_2layer(ByteStream&,GP<DjVuImage>,const GRect&,unsigned char*);
|
|
Packit |
df99a1 |
void print_fg(ByteStream&,GP<DjVuImage>,const GRect&);
|
|
Packit |
df99a1 |
void print_image(ByteStream&,GP<DjVuImage>,const GRect&,GP<DjVuTXT>);
|
|
Packit |
df99a1 |
void parse_range(GP<DjVuDocument>,GUTF8String,GList<int>&);
|
|
Packit |
df99a1 |
GP<DjVuImage> decode_page(GP<DjVuDocument>,int,int,int);
|
|
Packit |
df99a1 |
void process_single_page(ByteStream&,GP<DjVuDocument>,int,int,int,int);
|
|
Packit |
df99a1 |
void process_double_page(ByteStream&,GP<DjVuDocument>,void*,int,int);
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
public:
|
|
Packit |
df99a1 |
/** Options affecting the print result. Please refer to
|
|
Packit |
df99a1 |
\Ref{DjVuToPS::Options} for details. */
|
|
Packit |
df99a1 |
Options options;
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
/** @name Callbacks */
|
|
Packit |
df99a1 |
//@{
|
|
Packit |
df99a1 |
/** Refresh callback is a function, which will be called fairly
|
|
Packit |
df99a1 |
often while the image (document) is being printed. It can
|
|
Packit |
df99a1 |
be used to refresh a GUI, if necessary.
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
@param refresh_cb Callback function to be called periodically
|
|
Packit |
df99a1 |
@param refresh_cl_data Pointer passed to #refresh_cb()# */
|
|
Packit |
df99a1 |
void set_refresh_cb(void (*refresh_cb)(void*), void *refresh_cl_data);
|
|
Packit |
df99a1 |
/** Callback used to report the progress of printing. The progress is a
|
|
Packit |
df99a1 |
double number from 0 to 1. If an existing \Ref{DjVuImage} is printed,
|
|
Packit |
df99a1 |
this callback will be called at least twice: in the beginning and at the
|
|
Packit |
df99a1 |
end of printing. If a \Ref{DjVuDocument} is being printed, this
|
|
Packit |
df99a1 |
callback will be used to report printing progress of every page. To
|
|
Packit |
df99a1 |
learn the number of the page being printed you can use
|
|
Packit |
df99a1 |
\Ref{set_info_cb}() function. See \Ref{set_dec_progress_cb}() to find
|
|
Packit |
df99a1 |
out how to learn the decoding progress.
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
@param cb Callback function to be called
|
|
Packit |
df99a1 |
@param data Pointer passed to #cb()#. */
|
|
Packit |
df99a1 |
void set_prn_progress_cb(void (*cb)(double, void*), void *data);
|
|
Packit |
df99a1 |
/** Callback used to report the progress of decoding. The progress is a
|
|
Packit |
df99a1 |
double number from 0 to 1. This callback is only used when printing a
|
|
Packit |
df99a1 |
\Ref{DjVuDocument} in a multithreaded environment. In all other cases it
|
|
Packit |
df99a1 |
will not be called. Whenever you \Ref{print}() a page range from a
|
|
Packit |
df99a1 |
\Ref{DjVuDocument}, the #DjVuToPS# has to decode the mentioned pages
|
|
Packit |
df99a1 |
before writing them to the output \Ref{ByteStream}. This callback can be
|
|
Packit |
df99a1 |
helpful to find out the status of the decoding. See
|
|
Packit |
df99a1 |
\Ref{set_prn_progress_cb}() to find out how to learn the printing
|
|
Packit |
df99a1 |
progress. See \Ref{set_info_cb}() to learn how to find out the number
|
|
Packit |
df99a1 |
of the page being processed, the total number of pages and the number of
|
|
Packit |
df99a1 |
processed pages.
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
@param cb Callback function to be called
|
|
Packit |
df99a1 |
@param data Pointer passed to #cb()#. */
|
|
Packit |
df99a1 |
void set_dec_progress_cb(void (*cb)(double, void*), void *data);
|
|
Packit |
df99a1 |
/** Callback used to report the current printing stage of a
|
|
Packit |
df99a1 |
\Ref{DjVuDocument}. When printing a \Ref{DjVuDocument} ({\bf not} a
|
|
Packit |
df99a1 |
\Ref{DjVuImage}), the #DjVuToPS# class will decode and output every page
|
|
Packit |
df99a1 |
mentioned in the {\em page range}. Before decoding and outputing, it
|
|
Packit |
df99a1 |
will call this #info_cb()# callback in order to let you know about what
|
|
Packit |
df99a1 |
is going on. This can be quite useful in a GUI program to keep the user
|
|
Packit |
df99a1 |
informed. This function is not called when you print a \Ref{DjVuImage}.
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
Description of the arguments passed to #info_cb#:
|
|
Packit |
df99a1 |
\begin{description}
|
|
Packit |
df99a1 |
\item[page_num] The number of the page being processed
|
|
Packit |
df99a1 |
\item[page_cnt] Counts how many pages have already been processed.
|
|
Packit |
df99a1 |
\item[tot_pages] Counts how many pages will be output enventually.
|
|
Packit |
df99a1 |
\item[stage] Describes the current processing stage
|
|
Packit |
df99a1 |
(#DECODING# or #PRINTING#).
|
|
Packit |
df99a1 |
\end{description}
|
|
Packit |
df99a1 |
@param cb Callback function to be called
|
|
Packit |
df99a1 |
@param data Pointer, which will be passed to #cb()#. */
|
|
Packit |
df99a1 |
void set_info_cb(void (*cb)(int,int,int,Stage,void*), void *data);
|
|
Packit |
df99a1 |
//@}
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
/** Prints the specified \Ref{DjVuImage} #dimg# into the
|
|
Packit |
df99a1 |
\Ref{ByteStream} #str#. The function will first scale
|
|
Packit |
df99a1 |
the image to fit the #img_rect#, then extract #prn_rect#
|
|
Packit |
df99a1 |
from the obtained bitmap and will output it in the
|
|
Packit |
df99a1 |
PostScript format. The function generates a legal PostScript
|
|
Packit |
df99a1 |
(or Encapsulated PostScript) file taking care of all comments
|
|
Packit |
df99a1 |
conforming to Document Structure Conventions v. 3.0.
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
{\bf Warning:} The zoom factor specified in \Ref{Options} does
|
|
Packit |
df99a1 |
not affect the amount of data stored into the PostScript file.
|
|
Packit |
df99a1 |
It will be used by the PostScript code to additionally scale
|
|
Packit |
df99a1 |
the image. We cannot pre-scale it here, because we do not know
|
|
Packit |
df99a1 |
the future resolution of the printer. The #img_rect# and
|
|
Packit |
df99a1 |
#prn_rect# alone define how much data will be sent to printer.
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
Using #img_rect# one can upsample or downsample the image prior
|
|
Packit |
df99a1 |
to sending it to the printer.
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
@param str \Ref{ByteStream} where PostScript output will be sent
|
|
Packit |
df99a1 |
@param dimg \Ref{DjVuImage} to print
|
|
Packit |
df99a1 |
@param img_rect Rectangle to which the \Ref{DjVuImage} will be scaled.
|
|
Packit |
df99a1 |
Note that this parameters defines the amount of data
|
|
Packit |
df99a1 |
that will actually be sent to the printer. The PostScript
|
|
Packit |
df99a1 |
code can futher resize the image according to the
|
|
Packit |
df99a1 |
#zoom# parameter from the \Ref{Options} structure.
|
|
Packit |
df99a1 |
@param prn_rect Part of img_rect to send to printer.
|
|
Packit |
df99a1 |
@param override_dpi Optional parameter allowing you to override
|
|
Packit |
df99a1 |
dpi setting that would otherwise be extracted from #dimg# */
|
|
Packit |
df99a1 |
void print(ByteStream&, GP<DjVuImage> dimg,
|
|
Packit |
df99a1 |
const GRect &prn_rect, const GRect &img_rect,
|
|
Packit |
df99a1 |
int override_dpi=-1 );
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
/** Outputs the specifies pages from the \Ref{DjVuDocument} into the
|
|
Packit |
df99a1 |
\Ref{ByteStream} in PostScript format. The function will generate a
|
|
Packit |
df99a1 |
multipage PostScript document conforming to PS DSC 3.0 by storing into
|
|
Packit |
df99a1 |
it every page mentioned in the #page_range#.
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
If #page_range# is empty, all pages from the \Ref{DjVuDocument} #doc#
|
|
Packit |
df99a1 |
will be printed. The #page_range# is a set of ranges separated by
|
|
Packit |
df99a1 |
commas. Every range has this form: {\em start_page}[-{\em
|
|
Packit |
df99a1 |
end_page}]. {\em end_page} is optional and can be less than the {\em
|
|
Packit |
df99a1 |
start_page}, in which case the pages will be printed in the reverse
|
|
Packit |
df99a1 |
order.
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
Examples:
|
|
Packit |
df99a1 |
\begin{itemize}
|
|
Packit |
df99a1 |
\item {\bf 1-10} - Will print pages 1 to 10.
|
|
Packit |
df99a1 |
\item {\bf 10-1} - Will print pages 1 to 10 in reverse order.
|
|
Packit |
df99a1 |
\item {\bf 1-10,12-20} - Will print pages 1 to 20 with page 11 skipped.
|
|
Packit |
df99a1 |
\end{itemize} */
|
|
Packit |
df99a1 |
void print(ByteStream&, GP<DjVuDocument> doc, GUTF8String page_range);
|
|
Packit |
df99a1 |
void print(ByteStream&, GP<DjVuDocument> doc);
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
/** Default constructor. Initializes the class. */
|
|
Packit |
df99a1 |
DjVuToPS(void);
|
|
Packit |
df99a1 |
};
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
//****************************************************************************
|
|
Packit |
df99a1 |
//******************************** DjVuToPS **********************************
|
|
Packit |
df99a1 |
//****************************************************************************
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
//@}
|
|
Packit |
df99a1 |
// ------------
|
|
Packit |
df99a1 |
|
|
Packit |
df99a1 |
#ifdef HAVE_NAMESPACES
|
|
Packit |
df99a1 |
}
|
|
Packit |
df99a1 |
# ifndef NOT_USING_DJVU_NAMESPACE
|
|
Packit |
df99a1 |
using namespace DJVU;
|
|
Packit |
df99a1 |
# endif
|
|
Packit |
df99a1 |
#endif
|
|
Packit |
df99a1 |
#endif
|