From c25404775a2cb6d6ec89bada81a9bf578eefd867 Mon Sep 17 00:00:00 2001 From: Joshua Pinter Date: Mon, 5 Oct 2015 12:17:02 -0600 Subject: [PATCH] Override styles when printing to ensure good output. After **numerous** trials and errors with the help from @kumailht we finally were able to override some settings when printing GridForms to ensure the forms look as good on paper as they do on the screen. To ensure these styles are activated (i.e. the media type is set to print) use the following in the wkhtmltopdf command line: --print-media-type If using `wicked_pdf` to generate PDFs in Rails, you can use `print_media_type: true` configuration option. --- gridforms/gridforms.sass | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/gridforms/gridforms.sass b/gridforms/gridforms.sass index 5054280..4b0dd3b 100644 --- a/gridforms/gridforms.sass +++ b/gridforms/gridforms.sass @@ -126,6 +126,25 @@ &:hover background: lighten($field-focus-color, 5%) cursor: text + + // Overide styles when printing to ensure good looking output. + @media print + [data-row-span] + display: table + height: 56px + page-break-inside: avoid + + [data-field-span] + border-right: 1px solid #333333 + display: table-cell + float: none + + &.focus, + &:hover + background: none + + label:first-child + letter-spacing: 0 // Create row spans for n columns in the grid @for $grid_i from 1 through $max-columns