Bugzilla – Attachment 63218 Details for
Bug 18541
Patron card creator: Add a grid to support layout design
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18541 - Patron card creator: Add a grid to support layout design
Bug-18541---Patron-card-creator-Add-a-grid-to-supp.patch (text/plain), 9.59 KB, created by
Marc Véron
on 2017-05-07 07:49:07 UTC
(
hide
)
Description:
Bug 18541 - Patron card creator: Add a grid to support layout design
Filename:
MIME Type:
Creator:
Marc Véron
Created:
2017-05-07 07:49:07 UTC
Size:
9.59 KB
patch
obsolete
>From 54b66cd7cb33118ba940044ade1ecc0ce0b67f8b Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Marc=20V=C3=A9ron?= <veron@veron.ch> >Date: Thu, 4 May 2017 17:36:24 +0200 >Subject: [PATCH] Bug 18541 - Patron card creator: Add a grid to support layout > design > >Add a layout grid to patron card creator to figure out the positions of text >fields, barcode and images. > >To test: >- Apply on top of patch 18465 >- Go to Home > Tools > Patron card creator >- Edit or create a layout >- Turn on new choice 'Guide grid' in section 'General settings' >- Leave 'Units' unchanged >- Crate a PDF using 'Card batches' >- Notice that card is printed with a layout grid that reflects selected unit > with each 5th and 10th line in different color, unit description displayed > bottom left, card dimensions displayed bottom right in small print inside the > layout grid >- Print PDF. Set printer settings in Adobe Reader or other PDF printing > software to 'Actual size' to prevent scaling to printer's printable > region >- Mesure out printed PDF and verify that grid corresponds to selecte unit. >- Go back to layout definition and choose an other unit, repeat steps > to verify that grid respects selected unit. >- Go back to layout definition, turn grid off, create PDF, verify that grid > does not display in PDF > >Note for testers / QAers: Position of card elements (text, image...) do not >respect the unit, this will be fixed in Bug 18550 >--- > C4/Patroncards/Patroncard.pm | 89 +++++++++++++++++++++- > .../prog/en/modules/patroncards/edit-layout.tt | 10 +++ > patroncards/create-pdf.pl | 5 +- > patroncards/edit-layout.pl | 2 + > 4 files changed, 103 insertions(+), 3 deletions(-) > >diff --git a/C4/Patroncards/Patroncard.pm b/C4/Patroncards/Patroncard.pm >index 7678ac0..f13d137 100644 >--- a/C4/Patroncards/Patroncard.pm >+++ b/C4/Patroncards/Patroncard.pm >@@ -24,7 +24,7 @@ use autouse 'Data::Dumper' => qw(Dumper); > use Text::Wrap qw(wrap); > #use Font::TTFMetrics; > >-use C4::Creators::Lib qw(get_font_types); >+use C4::Creators::Lib qw(get_font_types get_unit_values); > use C4::Creators::PDF qw(StrWidth); > use C4::Patroncards::Lib qw(unpack_UTF8 text_alignment leading box get_borrower_attributes); > >@@ -32,6 +32,17 @@ use C4::Patroncards::Lib qw(unpack_UTF8 text_alignment leading box get_borrower_ > sub new { > my ($invocant, %params) = @_; > my $type = ref($invocant) || $invocant; >+ >+ my $units = get_unit_values(); >+ my $unitvalue = 1; >+ my $unitdesc = ''; >+ foreach my $un (@$units){ >+ if ($un->{'type'} eq $params{'layout'}->{'units'}) { >+ $unitvalue = $un->{'value'}; >+ $unitdesc = $un->{'desc'}; >+ } >+ } >+ > my $self = { > batch_id => $params{'batch_id'}, > #card_number => $params{'card_number'}, >@@ -41,6 +52,8 @@ sub new { > height => $params{'height'}, > width => $params{'width'}, > layout => $params{'layout'}, >+ unitvalue => $unitvalue, >+ unitdesc => $unitdesc, > text_wrap_cols => $params{'text_wrap_cols'}, > barcode_height_scale => $params{'layout'}->{'barcode'}[0]->{'height_scale'} || 0.01, > barcode_width_scale => $params{'layout'}->{'barcode'}[0]->{'width_scale'} || 0.8, >@@ -69,6 +82,7 @@ sub draw_barcode { > sub draw_guide_box { > my ($self, $pdf) = @_; > warn sprintf('No pdf object passed in.') and return -1 if !$pdf; >+ > my $obj_stream = "q\n"; # save the graphic state > $obj_stream .= "0.5 w\n"; # border line width > $obj_stream .= "1.0 0.0 0.0 RG\n"; # border color red >@@ -79,6 +93,79 @@ sub draw_guide_box { > $pdf->Add($obj_stream); > } > >+sub draw_guide_grid { >+ my ($self, $pdf) = @_; >+ warn sprintf('No pdf object passed in.') and return -1 if !$pdf; >+ >+ # Set up the grid in user defined units. >+ # Each 5th and 10th line get separate values >+ >+ my $obj_stream = "q\n"; # save the graphic state >+ my $x = $self->{'llx'}; >+ my $y = $self->{'lly'}; >+ >+ my $cnt = 0; >+ for ( $x = $self->{'llx'}/$self->{'unitvalue'}; $x <= ($self->{'llx'} + $self->{'width'})/$self->{'unitvalue'}; $x++) { >+ my $xx = $x*$self->{'unitvalue'}; >+ my $yy = $y + $self->{'height'}; >+ if ( ($cnt % 10) && ! ($cnt % 5) ) { >+ $obj_stream .= "0.0 1.0 0.0 RG\n"; >+ $obj_stream .= "0 w\n"; >+ } elsif ( $cnt % 5 ) { >+ $obj_stream .= "0.0 1.0 1.0 RG\n"; >+ $obj_stream .= "0 w\n"; >+ } else { >+ $obj_stream .= "0.0 0.0 1.0 RG\n"; >+ $obj_stream .= "0 w\n"; >+ } >+ $cnt ++; >+ >+ $obj_stream .= "$xx $y m\n"; >+ $obj_stream .= "$xx $yy l\n"; >+ >+ $obj_stream .= "s\n"; >+ } >+ >+ $x = $self->{'llx'}; >+ $y = $self->{'lly'}; >+ $cnt = 0; >+ for ( $y = $self->{'lly'}/$self->{'unitvalue'}; $y <= ($self->{'lly'} + $self->{'height'})/$self->{'unitvalue'}; $y++) { >+ >+ my $xx = $x + $self->{'width'}; >+ my $yy = $y*$self->{'unitvalue'}; >+ >+ if ( ($cnt % 10) && ! ($cnt % 5) ) { >+ $obj_stream .= "0.0 1.0 0.0 RG\n"; >+ $obj_stream .= "0 w\n"; >+ } elsif ( $cnt % 5 ) { >+ $obj_stream .= "0.0 1.0 1.0 RG\n"; >+ $obj_stream .= "0 w\n"; >+ } else { >+ $obj_stream .= "0.0 0.0 1.0 RG\n"; >+ $obj_stream .= "0 w\n"; >+ } >+ $cnt ++; >+ >+ $obj_stream .= "$x $yy m\n"; >+ $obj_stream .= "$xx $yy l\n"; >+ $obj_stream .= "s\n"; >+ } >+ >+ $obj_stream .= "Q\n"; # restore the graphic state >+ $pdf->Add($obj_stream); >+ >+ # Add info about units >+ my $strbottom = "0/0 $self->{'unitdesc'}"; >+ my $strtop = sprintf('%.2f', $self->{'width'}/$self->{'unitvalue'}) .'/'. sprintf('%.2f', $self->{'height'}/$self->{'unitvalue'}); >+ my $font_size = 6; >+ $pdf->Font( 'Courier' ); >+ $pdf->FontSize( $font_size ); >+ my $strtop_len = $pdf->StrWidth($strtop) * 1.5; >+ $pdf->Text( $self->{'llx'} + 2, $self->{'lly'} + 2, $strbottom ); >+ $pdf->Text( $self->{'llx'} + $self->{'width'} - $strtop_len , $self->{'lly'} + $self->{'height'} - $font_size , $strtop ); >+} >+ >+ > sub draw_text { > my ($self, $pdf, %params) = @_; > warn sprintf('No pdf object passed in.') and return -1 if !$pdf; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-layout.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-layout.tt >index 5b078eb..bd856c7 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-layout.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-layout.tt >@@ -176,6 +176,16 @@ > <input type="radio" name="guide_box" id="guide_box" value="0" checked="checked" />Off > [% END %] > </li> >+ <li> >+ <label for="guide_grid">Guide grid:</label> >+ [% IF ( guide_grid ) %] >+ <input type="radio" name="guide_grid" id="guide_grid" value="1" checked="checked" />On >+ <input type="radio" name="guide_grid" id="guide_grid" value="0" />Off >+ [% ELSE %] >+ <input type="radio" name="guide_grid" id="guide_grid" value="1" />On >+ <input type="radio" name="guide_grid" id="guide_grid" value="0" checked="checked" />Off >+ [% END %] >+ </li> > </ol> > </fieldset> > </li> >diff --git a/patroncards/create-pdf.pl b/patroncards/create-pdf.pl >index 9f21a50..7b3e7bc 100755 >--- a/patroncards/create-pdf.pl >+++ b/patroncards/create-pdf.pl >@@ -155,8 +155,9 @@ foreach my $item (@{$items}) { > text_wrap_cols => 30, #FIXME: hardcoded, > ); > >- $patron_card->draw_guide_box($pdf) if $print_layout_xml->{'guide_box'}; >- $patron_card->draw_barcode($pdf) if $print_layout_xml->{'barcode'}; >+ $patron_card->draw_guide_box($pdf) if $layout_xml->{'guide_box'}; >+ $patron_card->draw_guide_grid($pdf) if $layout_xml->{'guide_grid'}; >+ $patron_card->draw_barcode($pdf) if $layout_xml->{'barcode'}; > > # Do image foo and place binary image data into layout hash > my $image_data = {}; >diff --git a/patroncards/edit-layout.pl b/patroncards/edit-layout.pl >index fb495b1..d244640 100755 >--- a/patroncards/edit-layout.pl >+++ b/patroncards/edit-layout.pl >@@ -156,6 +156,7 @@ if ($op eq 'edit') { > layout_name => $layout->get_attr('layout_name'), > page_side => ($layout_xml->{'page_side'} eq 'F' ? 0 : 1), > guide_box => $layout_xml->{'guide_box'}, >+ guide_grid => $layout_xml->{'guide_grid'}, > units => $units, > @barcode, > barcode_type => _set_selected($layout_xml->{'barcode'}->[0]->{'type'}, $barcode_types), >@@ -218,6 +219,7 @@ elsif ($op eq 'save') { > $layout->{'units'} = $cgi->param($parameter) if $parameter eq 'units'; > $layout->{'page_side'} = $cgi->param($parameter) if $parameter eq 'page_side'; > $layout->{'guide_box'} = $cgi->param($parameter) if $parameter eq 'guide_box'; >+ $layout->{'guide_grid'} = $cgi->param($parameter) if $parameter eq 'guide_grid'; > } > } > $layout->{'text'} = $text_lines; >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 18541
:
63127
|
63130
|
63162
|
63217
|
63218
|
63263
|
63280
|
66873
|
66876
|
66877
|
66878
|
66887
|
66910