mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Fix bug 591177: Printer font is too small to read with webkit as html renderer.
From comment 23: "The PDF in comment 2 is about 8 times smaller than it should be. One possible cause of this bug is if gtk_print_operation_set_unit (op, GTK_UNIT_POINTS) is not called. gtkprint defaults to GTK_UNIT_PIXEL - a useless unit to be using with printers. On Linux GTK_UNIT_PIXEL units are 1 unit = 1/72 inch (the same as GTK_UNIT_POINTS as well as PostScript and PDF units). On Windows GTK_UNIT_PIXEL units are the GDI device units which for printers is the dpi resolution. So for a 600dpi printer 1 unit is 1/600". If the application was developed on Linux and assumes the default gtkprint units are always 1/72" inch the output on Windows using a 600dpi printer will be 72/600 = 0.12 of the size (or approximately 1/8 of the size)." Solution was to use webkit_web_frame_print_full() which allows us to provide our own GtkPrintOperation object with units set to GTK_UNIT_POINTS. Tested on both Linux and Windows. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18720 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
17fa30c6b3
commit
f084ab3020
@ -1,5 +1,5 @@
|
||||
/********************************************************************
|
||||
* gnc-html_webkit.c -- display HTML with some special gnucash tags.*
|
||||
* gnc-html-webkit.c -- gnucash report renderer using webkit *
|
||||
* *
|
||||
* Copyright (C) 2000 Bill Gribble <grib@billgribble.com> *
|
||||
* Copyright (C) 2001 Linas Vepstas <linas@linas.org> *
|
||||
@ -986,30 +986,45 @@ impl_webkit_export_to_file( GncHtml* self, const char *filepath )
|
||||
}
|
||||
}
|
||||
|
||||
#define PRINT_WITH_OP 1
|
||||
|
||||
static void
|
||||
impl_webkit_print( GncHtml* self )
|
||||
{
|
||||
GncHtmlWebkitPrivate* priv;
|
||||
// static void (*webkit_web_frame_print)( WebKitWebFrame* frame ) = NULL;
|
||||
WebKitWebFrame* frame;
|
||||
extern void webkit_web_frame_print( WebKitWebFrame * frame );
|
||||
extern void webkit_web_frame_print( WebKitWebFrame* frame );
|
||||
extern GtkPrintOperationResult webkit_web_frame_print_full( WebKitWebFrame* frame,
|
||||
GtkPrintOperation* op, GtkPrintOperationAction action, GError** error );
|
||||
|
||||
/* HACK ALERT
|
||||
*
|
||||
* The api to print isn't exported, but exists and works, so let's dig for it.
|
||||
*/
|
||||
#if 0
|
||||
if ( webkit_web_frame_print == NULL )
|
||||
{
|
||||
void* handle = dlopen( "/usr/lib/libwebkit-1.0.so", RTLD_LAZY );
|
||||
webkit_web_frame_print = dlsym( handle, "webkit_web_frame_print" );
|
||||
dlclose( handle );
|
||||
}
|
||||
GncHtmlWebkitPrivate* priv;
|
||||
WebKitWebFrame* frame;
|
||||
#if PRINT_WITH_OP
|
||||
GtkPrintOperation* op = gtk_print_operation_new();
|
||||
GError* error = NULL;
|
||||
#endif
|
||||
|
||||
priv = GNC_HTML_WEBKIT_GET_PRIVATE(self);
|
||||
frame = webkit_web_view_get_main_frame( priv->web_view );
|
||||
|
||||
#if PRINT_WITH_OP
|
||||
gtk_print_operation_set_unit( op, GTK_UNIT_POINTS );
|
||||
webkit_web_frame_print_full( frame, op, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, &error );
|
||||
g_object_unref( op );
|
||||
|
||||
if( error != NULL ) {
|
||||
GtkWidget* window = gtk_widget_get_toplevel( GTK_WIDGET(priv->web_view) );
|
||||
GtkWidget* dialog = gtk_message_dialog_new( GTK_WIDGET_TOPLEVEL(window) ? GTK_WINDOW(window) : NULL,
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"%s", error->message );
|
||||
g_error_free( error );
|
||||
|
||||
g_signal_connect( dialog, "response", G_CALLBACK(gtk_widget_destroy), NULL);
|
||||
gtk_widget_show( dialog );
|
||||
}
|
||||
#else
|
||||
webkit_web_frame_print( frame );
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user