Commit 4963332c authored by Adrian Johnson's avatar Adrian Johnson

pdftocairo: add -printdlg output option for win32

when set the win32 print dialog is displayed before printing
parent d8fe025c
......@@ -48,7 +48,7 @@ case "$host_os" in
;;
mingw*)
os_win32=yes
win32_libs="-lgdi32 -lwinspool"
win32_libs="-lgdi32 -lwinspool -lcomdlg32"
create_shared_lib="-no-undefined"
auto_import_flags="-Wl,--enable-auto-import"
......
This diff is collapsed.
......@@ -4,18 +4,16 @@
#include "goo/gtypes_p.h"
#include "goo/GooString.h"
#ifdef CAIRO_HAS_WIN32_SURFACE
#include <cairo-win32.h>
void win32GetFitToPageTransform(cairo_matrix_t *m);
cairo_surface_t *win32BeginDocument(GooString *inputFileName, GooString *outputFileName,
double w, double h,
GooString *printer,
GooString *printOpt,
GBool setupdlg,
GBool duplex);
void win32SetupPrinter(GooString *printer, GooString *printOpt,
GBool duplex, GBool setupdlg);
void win32ShowPrintDialog(GBool *expand, GBool *noShrink, GBool *noCenter,
GBool *usePDFPageSize, GBool *allPages,
int *firstPage, int *lastPage, int maxPages);
cairo_surface_t *win32BeginDocument(GooString *inputFileName, GooString *outputFileName);
void win32BeginPage(double *w, double *h, GBool changePageSize, GBool useFullPage);
void win32EndPage(GooString *imageFileName);
void win32EndDocument();
......
......@@ -82,11 +82,6 @@ Generates a TIFF file(s)
.BI \-pdf
Generates a PDF file
.TP
.BI \-print
(Windows only) Prints to a system printer. See also \-printer and \-printeropt.
If an output file is not specified, the output will be sent to the printer.
The output file '-' can not be used with this option.
.TP
.BI \-ps
Generate a PS file
.TP
......@@ -99,6 +94,15 @@ to specify a single page. The page size options (\-origpagesizes,
.BI \-svg
Generate a SVG (Scalable Vector Graphics) file
.TP
.BI \-print
(Windows only) Prints to a system printer. See also \-printer and \-printeropt.
If an output file is not specified, the output will be sent to the printer.
The output file '-' can not be used with this option.
.TP
.BI \-printdlg
(Windows only) Prints to a system printer. Displays the print dialog to allow
the print options to be modified before printing.
.TP
.BI \-f " number"
Specifies the first page to convert.
.TP
......
......@@ -80,6 +80,7 @@ static GBool ps = gFalse;
static GBool eps = gFalse;
static GBool pdf = gFalse;
static GBool printToWin32 = gFalse;
static GBool printdlg = gFalse;
static GBool svg = gFalse;
static GBool tiff = gFalse;
......@@ -160,6 +161,8 @@ static const ArgDesc argDesc[] = {
#ifdef CAIRO_HAS_WIN32_SURFACE
{"-print", argFlag, &printToWin32, 0,
"print to a Windows printer"},
{"-printdlg", argFlag, &printdlg, 0,
"show Windows print dialog and print"},
{"-printer", argGooString, &printer, 0,
"printer name or use default if this option is not specified"},
{"-printopt", argGooString, &printOpt, 0,
......@@ -541,7 +544,7 @@ static void beginDocument(GooString *inputFileName, GooString *outputFileName, d
}
#ifdef CAIRO_HAS_WIN32_SURFACE
if (printToWin32)
surface = win32BeginDocument(inputFileName, outputFileName, w, h, &printer, &printOpt, setupdlg, duplex);
surface = win32BeginDocument(inputFileName, outputFileName);
#endif
}
}
......@@ -857,13 +860,14 @@ int main(int argc, char *argv[]) {
(eps ? 1 : 0) +
(pdf ? 1 : 0) +
(printToWin32 ? 1 : 0) +
(printdlg ? 1 : 0) +
(svg ? 1 : 0);
if (num_outputs == 0) {
fprintf(stderr, "Error: one of the output format options (-png, -jpeg, -ps, -eps, -pdf, -print, -svg) must be used.\n");
fprintf(stderr, "Error: one of the output format options (-png, -jpeg, -ps, -eps, -pdf, -print, -printdlg, -svg) must be used.\n");
exit(99);
}
if (num_outputs > 1) {
fprintf(stderr, "Error: use only one of the output format options (-png, -jpeg, -ps, -eps, -pdf, -print, -svg).\n");
fprintf(stderr, "Error: use only one of the output format options (-png, -jpeg, -ps, -eps, -pdf, -printdlg, -print, -svg).\n");
exit(99);
}
if (png || jpeg || tiff)
......@@ -947,6 +951,9 @@ int main(int argc, char *argv[]) {
else
usePDFPageSize = gFalse;
if (printdlg)
printToWin32 = gTrue;
globalParams = new GlobalParams();
if (quiet) {
globalParams->setErrQuiet(quiet);
......@@ -1046,6 +1053,24 @@ int main(int argc, char *argv[]) {
lastPage = firstPage;
}
#ifdef CAIRO_HAS_WIN32_SURFACE
if (printdlg) {
GBool allPages = gFalse;
if (firstPage == 1 && lastPage == doc->getNumPages())
allPages = gTrue;
win32ShowPrintDialog(&expand, &noShrink, &noCenter,
&usePDFPageSize, &allPages,
&firstPage, &lastPage, doc->getNumPages());
if (allPages) {
firstPage = 1;
lastPage = doc->getNumPages();
}
} else if (printToWin32) {
win32SetupPrinter(&printer, &printOpt,
duplex, setupdlg);
}
#endif
// Make sure firstPage is always used so that beginDocument() is called
if ((printOnlyEven && firstPage % 2 == 0) || (printOnlyOdd && firstPage % 2 == 1))
firstPage++;
......
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