Commit a3d9b584 authored by Martin Kretzschmar's avatar Martin Kretzschmar

* poppler/PSOutputDev.cc (PSOutputDev): change the constructor to

take paper size and duplex setting parameters.
(init): add paper size and duplex parameters.
(writeDocSetup): add duplex parameter.

* poppler/PSOutputDev.h: update declarations.

* glib/poppler-private.h (struct _PopplerPSFile): store necessary
information to eventually construct a PSOutputDev.

* glib/poppler-page.cc (poppler_page_render_to_ps): initialize the
output dev if it doesn't exist yet.

* glib/poppler-document.cc (poppler_ps_file_new): don't create the
PSOutputDev here, just store filename and page range.
(poppler_ps_file_set_paper_size, poppler_ps_file_set_duplex): new
functions.
(poppler_ps_file_free): free the filename which we strdup now.

* glib/poppler-document.h: add prototypes.
parent 7be920ec
2005-07-27 Martin Kretzschmar <martink@gnome.org>
* poppler/PSOutputDev.cc (PSOutputDev): change the constructor to
take paper size and duplex setting parameters.
(init): add paper size and duplex parameters.
(writeDocSetup): add duplex parameter.
* poppler/PSOutputDev.h: update declarations.
* glib/poppler-private.h (struct _PopplerPSFile): store necessary
information to eventually construct a PSOutputDev.
* glib/poppler-page.cc (poppler_page_render_to_ps): initialize the
output dev if it doesn't exist yet.
* glib/poppler-document.cc (poppler_ps_file_new): don't create the
PSOutputDev here, just store filename and page range.
(poppler_ps_file_set_paper_size, poppler_ps_file_set_duplex): new
functions.
(poppler_ps_file_free): free the filename which we strdup now.
* glib/poppler-document.h: add prototypes.
2005-07-26 Albert Astals Cid <aacid@kde.org>
* qt/test-poppler-qt-cpp: Fix mem leak
......
......@@ -982,16 +982,50 @@ poppler_ps_file_new (PopplerDocument *document, const char *filename,
ps_file = g_new0 (PopplerPSFile, 1);
ps_file->document = (PopplerDocument *) g_object_ref (document);
ps_file->out = new PSOutputDev ((char *)filename,
document->doc->getXRef(),
document->doc->getCatalog(),
first_page + 1,
first_page + 1 + n_pages - 1,
psModePS);
ps_file->filename = g_strdup (filename);
ps_file->first_page = first_page + 1;
ps_file->last_page = first_page + 1 + n_pages - 1;
return ps_file;
}
/**
* poppler_ps_file_set_paper_size:
* @ps_file: a PopplerPSFile which was not yet printed to.
* @width: the paper width in 1/72 inch
* @height: the paper height in 1/72 inch
*
* Set the output paper size. These values will end up in the
* DocumentMedia, the BoundingBox DSC comments and other places in the
* generated PostScript.
*
**/
void
poppler_ps_file_set_paper_size (PopplerPSFile *ps_file,
double width, double height)
{
g_return_if_fail (ps_file->out == NULL);
ps_file->paper_width = width;
ps_file->paper_height = height;
}
/**
* poppler_ps_file_set_duplex:
* @ps_file a PopplerPSFile which was not yet printed to
* @duplex: whether to force duplex printing (on printers which support this)
*
* Enable or disable Duplex printing.
*
**/
void
poppler_ps_file_set_duplex (PopplerPSFile *ps_file, gboolean duplex)
{
g_return_if_fail (ps_file->out == NULL);
ps_file->duplex = duplex;
}
/**
* poppler_ps_file_free:
* @ps_file: a PopplerPSFile
......@@ -1006,6 +1040,7 @@ poppler_ps_file_free (PopplerPSFile *ps_file)
delete ps_file->out;
g_object_unref (ps_file->document);
g_free (ps_file->filename);
g_free (ps_file);
}
......
......@@ -134,11 +134,16 @@ gboolean poppler_fonts_iter_is_subset (PopplerFontsIter *iter);
gboolean poppler_fonts_iter_next (PopplerFontsIter *iter);
/* Export to ps */
PopplerPSFile *poppler_ps_file_new (PopplerDocument *document,
const char *filename,
int first_pages,
int n_pages);
void poppler_ps_file_free (PopplerPSFile *ps_file);
PopplerPSFile *poppler_ps_file_new (PopplerDocument *document,
const char *filename,
int first_pages,
int n_pages);
void poppler_ps_file_set_paper_size (PopplerPSFile *ps_file,
double width,
double height);
void poppler_ps_file_set_duplex (PopplerPSFile *ps_file,
gboolean duplex);
void poppler_ps_file_free (PopplerPSFile *ps_file);
G_END_DECLS
......
......@@ -692,6 +692,16 @@ poppler_page_render_to_ps (PopplerPage *page,
g_return_if_fail (POPPLER_IS_PAGE (page));
g_return_if_fail (ps_file != NULL);
if (!ps_file->out)
ps_file->out = new PSOutputDev (ps_file->filename,
ps_file->document->doc->getXRef(),
ps_file->document->doc->getCatalog(),
ps_file->first_page + 1, ps_file->last_page,
psModePS, (int)ps_file->paper_width,
(int)ps_file->paper_height, ps_file->duplex,
0, 0, 0, 0, gFalse);
ps_file->document->doc->displayPage (ps_file->out, page->index + 1, 72.0, 72.0,
poppler_page_get_rotate (page), gTrue, gFalse);
}
......
......@@ -31,6 +31,12 @@ struct _PopplerPSFile
{
PopplerDocument *document;
PSOutputDev *out;
char *filename;
int first_page;
int last_page;
double paper_width;
double paper_height;
gboolean duplex;
};
struct _PopplerFontInfo
......
......@@ -662,6 +662,7 @@ static void outputToFile(void *stream, char *data, int len) {
PSOutputDev::PSOutputDev(char *fileName, XRef *xrefA, Catalog *catalog,
int firstPage, int lastPage, PSOutMode modeA,
int paperWidthA, int paperHeightA, GBool duplexA,
int imgLLXA, int imgLLYA, int imgURXA, int imgURYA,
GBool manualCtrlA) {
FILE *f;
......@@ -713,12 +714,14 @@ PSOutputDev::PSOutputDev(char *fileName, XRef *xrefA, Catalog *catalog,
init(outputToFile, f, fileTypeA,
xrefA, catalog, firstPage, lastPage, modeA,
imgLLXA, imgLLYA, imgURXA, imgURYA, manualCtrlA);
imgLLXA, imgLLYA, imgURXA, imgURYA, manualCtrlA,
paperWidthA, paperHeightA, duplexA);
}
PSOutputDev::PSOutputDev(PSOutputFunc outputFuncA, void *outputStreamA,
XRef *xrefA, Catalog *catalog,
int firstPage, int lastPage, PSOutMode modeA,
int paperWidthA, int paperHeightA, GBool duplexA,
int imgLLXA, int imgLLYA, int imgURXA, int imgURYA,
GBool manualCtrlA) {
underlayCbk = NULL;
......@@ -738,14 +741,16 @@ PSOutputDev::PSOutputDev(PSOutputFunc outputFuncA, void *outputStreamA,
init(outputFuncA, outputStreamA, psGeneric,
xrefA, catalog, firstPage, lastPage, modeA,
imgLLXA, imgLLYA, imgURXA, imgURYA, manualCtrlA);
imgLLXA, imgLLYA, imgURXA, imgURYA, manualCtrlA,
paperWidthA, paperHeightA, duplexA);
}
void PSOutputDev::init(PSOutputFunc outputFuncA, void *outputStreamA,
PSFileType fileTypeA, XRef *xrefA, Catalog *catalog,
int firstPage, int lastPage, PSOutMode modeA,
int imgLLXA, int imgLLYA, int imgURXA, int imgURYA,
GBool manualCtrlA) {
GBool manualCtrlA, int paperWidthA, int paperHeightA,
GBool duplexA) {
Page *page;
PDFRectangle *box;
......@@ -757,8 +762,8 @@ void PSOutputDev::init(PSOutputFunc outputFuncA, void *outputStreamA,
xref = xrefA;
level = globalParams->getPSLevel();
mode = modeA;
paperWidth = globalParams->getPSPaperWidth();
paperHeight = globalParams->getPSPaperHeight();
paperWidth = paperWidthA;
paperHeight = paperHeightA;
imgLLX = imgLLXA;
imgLLY = imgLLYA;
imgURX = imgURXA;
......@@ -838,7 +843,7 @@ void PSOutputDev::init(PSOutputFunc outputFuncA, void *outputStreamA,
writePS("%%EndProlog\n");
writePS("%%BeginSetup\n");
}
writeDocSetup(catalog, firstPage, lastPage);
writeDocSetup(catalog, firstPage, lastPage, duplexA);
if (mode != psModeForm) {
writePS("%%EndSetup\n");
}
......@@ -1003,7 +1008,8 @@ void PSOutputDev::writeXpdfProcset() {
}
void PSOutputDev::writeDocSetup(Catalog *catalog,
int firstPage, int lastPage) {
int firstPage, int lastPage,
GBool duplexA) {
Page *page;
Dict *resDict;
Annots *annots;
......@@ -1038,8 +1044,7 @@ void PSOutputDev::writeDocSetup(Catalog *catalog,
if (mode != psModeForm) {
if (mode != psModeEPS && !manualCtrl) {
writePSFmt("%d %d %s pdfSetup\n",
paperWidth, paperHeight,
globalParams->getPSDuplex() ? "true" : "false");
paperWidth, paperHeight, duplexA ? "true" : "false");
}
#if OPI_SUPPORT
if (globalParams->getPSOPI()) {
......
......@@ -52,6 +52,8 @@ public:
// Open a PostScript output file, and write the prolog.
PSOutputDev(char *fileName, XRef *xrefA, Catalog *catalog,
int firstPage, int lastPage, PSOutMode modeA,
int paperWidthA = -1, int paperHeightA = -1,
GBool duplexA = gTrue,
int imgLLXA = 0, int imgLLYA = 0,
int imgURXA = 0, int imgURYA = 0,
GBool manualCtrlA = gFalse);
......@@ -60,6 +62,8 @@ public:
PSOutputDev(PSOutputFunc outputFuncA, void *outputStreamA,
XRef *xrefA, Catalog *catalog,
int firstPage, int lastPage, PSOutMode modeA,
int paperWidthA = -1, int paperHeightA = -1,
GBool duplexA = gTrue,
int imgLLXA = 0, int imgLLYA = 0,
int imgURXA = 0, int imgURYA = 0,
GBool manualCtrlA = gFalse);
......@@ -93,7 +97,7 @@ public:
void writeXpdfProcset();
// Write the document-level setup.
void writeDocSetup(Catalog *catalog, int firstPage, int lastPage);
void writeDocSetup(Catalog *catalog, int firstPage, int lastPage, GBool duplexA);
// Write the setup for the current page.
void writePageSetup();
......@@ -196,7 +200,8 @@ private:
PSFileType fileTypeA, XRef *xrefA, Catalog *catalog,
int firstPage, int lastPage, PSOutMode modeA,
int imgLLXA, int imgLLYA, int imgURXA, int imgURYA,
GBool manualCtrlA);
GBool manualCtrlA, int paperWidthA, int paperHeightA,
GBool duplexA);
void setupResources(Dict *resDict);
void setupFonts(Dict *resDict);
void setupFont(GfxFont *font, Dict *parentResDict);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment