| 1 | package Games::Sudoku::Pdf; | ||
| 2 | |||
| 3 | 2 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 2 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | our $VERSION = '0.06'; | ||
| 7 | |||
| 8 | require 5.006; | ||
| 9 | |||
| 10 | 0 | ▶ | use PDF::API2 2.000; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 11 | use PDF::Table v0.9.3; | ||
| 12 | use Time::Local qw( timelocal ); | ||
| 13 | $| = 1; | ||
| 14 | |||
| 15 | ########################################################### | ||
| 16 | my $PDF_API2_IS_OLD = _make_version_comparable($PDF::API2::VERSION) < 2.042 ? 1 : 0; | ||
| 17 | my $PDF_TABLE_IS_OLD = _make_version_comparable($PDF::Table::VERSION) < 1.001 ? 1 : 0; | ||
| 18 | # Both modules had some fairly recent api changes. Switches were tested to work with | ||
| 19 | # PDF::API2 2.000 and 2.045 | ||
| 20 | # PDF::Table 0.9.3 and 1.005 | ||
| 21 | ########################################################### | ||
| 22 | |||
| 23 | sub new { | ||
| 24 | my $class = shift; | ||
| 25 | |||
| 26 | bless _init({ | ||
| 27 | pageFormat => 'A4', | ||
| 28 | puzzlesPerPage => '2x2', | ||
| 29 | pageOrientation => '', | ||
| 30 | appendFile => '', | ||
| 31 | extraRegion => 'n', | ||
| 32 | title => '', | ||
| 33 | author => '', | ||
| 34 | subject => '', | ||
| 35 | keywords => '', | ||
| 36 | |||
| 37 | quiet => 0, | ||
| 38 | textFont => 'Helvetica-Oblique', | ||
| 39 | textEncoding => undef, | ||
| 40 | @_, | ||
| 41 | }), $class | ||
| 42 | } | ||
| 43 | |||
| 44 | sub add_puzzle { | ||
| 45 | # add a table object with the puzzle to the pdf | ||
| 46 | my $self = shift; | ||
| 47 | my %puzzle = @_; | ||
| 48 | |||
| 49 | my $clues = $puzzle{clues} or return 0; | ||
| 50 | my $str_len = length($clues); | ||
| 51 | unless ($str_len == 81) { | ||
| 52 | warn "parameter 'clues' must be a string of 81 characters (has $str_len)"; | ||
| 53 | return 0; | ||
| 54 | } | ||
| 55 | $clues =~ s/[^1-9]/ /g; | ||
| 56 | |||
| 57 | my $jigsaw; | ||
| 58 | if ($puzzle{jigsaw}) { | ||
| 59 | $str_len = length($puzzle{jigsaw}); | ||
| 60 | unless ($str_len == 81) { | ||
| 61 | warn "parameter 'jigsaw' must be a string of 81 characters (has $str_len)"; | ||
| 62 | return 0; | ||
| 63 | } | ||
| 64 | $jigsaw = _create_matrix($puzzle{jigsaw}); | ||
| 65 | } | ||
| 66 | |||
| 67 | my $x_region = lc ($puzzle{extraRegion} || $self->{extraRegion} || 'n'); | ||
| 68 | |||
| 69 | my $pdf = $self->{pdf}; | ||
| 70 | my $pos = $self->{nextPosOnPage}++; | ||
| 71 | |||
| 72 | my $page; | ||
| 73 | if ($pos) { | ||
| 74 | # continue on current page | ||
| 75 | $page = $self->{page}; | ||
| 76 | |||
| 77 | } else { | ||
| 78 | # continue on a new page | ||
| 79 | $page = $self->{page} = $pdf->page(); | ||
| 80 | |||
| 81 | my $pages_in_file; | ||
| 82 | if ($PDF_API2_IS_OLD) { | ||
| 83 | $page->mediabox(@{$self->{pageSize}}); | ||
| 84 | $pages_in_file = $pdf->pages(); | ||
| 85 | } else { | ||
| 86 | $page->size($self->{pageSize}); | ||
| 87 | $pages_in_file = $pdf->page_count(); | ||
| 88 | } | ||
| 89 | $self->{pagesAdded}++; | ||
| 90 | print "\nadding page ", $self->{pagesAdded}, "\n" unless $self->{quiet}; | ||
| 91 | |||
| 92 | my $text = $page->text(); | ||
| 93 | $text->font($self->{font}, 12); | ||
| 94 | $text->translate($self->{pageWidth} - 12, 24); | ||
| 95 | |||
| 96 | if ($PDF_TABLE_IS_OLD) { | ||
| 97 | $text->text_right('page ' . $pages_in_file); | ||
| 98 | } else { | ||
| 99 | $text->text('page ' . $pages_in_file, align => 'right'); | ||
| 100 | } | ||
| 101 | } | ||
| 102 | |||
| 103 | print "\radding puzzle ", $pos + 1 unless $self->{quiet}; | ||
| 104 | my $card = _create_matrix($clues); | ||
| 105 | |||
| 106 | my $area_colors; | ||
| 107 | if ($x_region eq 'n' && $jigsaw) { | ||
| 108 | $area_colors = $self->_get_area_colors($jigsaw, $self->{puzzleCount} + 1); | ||
| 109 | } | ||
| 110 | |||
| 111 | my $cell_props = []; | ||
| 112 | for (my $i = 0; $i < @$card; $i++) { | ||
| 113 | my $row = $card->[$i]; | ||
| 114 | for (my $j = 0; $j < @$row; $j++) { | ||
| 115 | $cell_props->[$i][$j] = $self->_get_cell_prop($i, $j, $x_region, $jigsaw, $area_colors); | ||
| 116 | } | ||
| 117 | } | ||
| 118 | |||
| 119 | my $settings = $self->{tableSettings}; | ||
| 120 | my $factor = $self->{factor}; | ||
| 121 | my $pos_data = $self->{positionData}[$pos]; | ||
| 122 | my ($x, $y) = @$pos_data; | ||
| 123 | |||
| 124 | my $pdftable = new PDF::Table; | ||
| 125 | |||
| 126 | my ($end_page, $pages_spanned, $table_bot_y) = $pdftable->table( | ||
| 127 | $pdf, | ||
| 128 | $page, | ||
| 129 | $card, | ||
| 130 | x => $x, | ||
| 131 | ($PDF_TABLE_IS_OLD ? 'start_y' : 'y') => $y, | ||
| 132 | cell_props => $cell_props, | ||
| 133 | %$settings | ||
| 134 | ); | ||
| 135 | |||
| 136 | if ($pages_spanned > 1) { | ||
| 137 | warn "\aTable overflow!\n"; | ||
| 138 | } | ||
| 139 | |||
| 140 | my ($content, $cell_size); | ||
| 141 | if ($PDF_API2_IS_OLD) { | ||
| 142 | $content = $page->gfx(); | ||
| 143 | } else { | ||
| 144 | $content = $page->graphics(); | ||
| 145 | } | ||
| 146 | if ($PDF_TABLE_IS_OLD) { | ||
| 147 | $cell_size = $settings->{row_height}; | ||
| 148 | } else { | ||
| 149 | $cell_size = $settings->{min_rh}; | ||
| 150 | } | ||
| 151 | |||
| 152 | if ($jigsaw) { | ||
| 153 | _draw_jigsaw_lines($content, $x, $y, $jigsaw, $settings->{w}, $cell_size, $factor); | ||
| 154 | } else { | ||
| 155 | _draw_straight_lines($content, $x, $y, $settings->{w}, $cell_size, $factor); | ||
| 156 | } | ||
| 157 | |||
| 158 | if ($puzzle{bottomLine}) { | ||
| 159 | my $text = $end_page->text(); | ||
| 160 | $text->font($self->{font}, 12 * $factor); | ||
| 161 | $text->translate($x, $table_bot_y - 14 * $factor); | ||
| 162 | $text->text( $puzzle{bottomLine} ); | ||
| 163 | } | ||
| 164 | if ($self->{nextPosOnPage} == $self->{puzzlesPerPage}) { | ||
| 165 | $self->{nextPosOnPage} = 0; | ||
| 166 | } | ||
| 167 | $self->{puzzleCount}++; | ||
| 168 | } | ||
| 169 | |||
| 170 | sub read_input_file { | ||
| 171 | my $self = shift; | ||
| 172 | my $file = shift() or die "The file to read from must be given as first argument to read_input_file().\n"; | ||
| 173 | my %options = @_; | ||
| 174 | my $puzzle_numbers = $options{slice}; | ||
| 175 | |||
| 176 | my (@puzzle_numbers, $next_puzzle_number); | ||
| 177 | if ($puzzle_numbers) { | ||
| 178 | @puzzle_numbers = sort {$a <=> $b} @$puzzle_numbers; | ||
| 179 | $next_puzzle_number = shift @puzzle_numbers; | ||
| 180 | } | ||
| 181 | |||
| 182 | my $puzzles_in_file = 0; | ||
| 183 | my $line_handler = $options{lineHandler} || sub { | ||
| 184 | my $line = shift; | ||
| 185 | $line =~ /^([0-9. ]{81})(?:[\|:,;\t]([1-9]{81})?)?(?:[\|:,;\t]([nNxXhHpPcCdDaAgG])?)?(?:[\|:,;\t](.+)?)?/ or return 0; | ||
| 186 | $puzzles_in_file++; | ||
| 187 | |||
| 188 | if ($puzzle_numbers) { | ||
| 189 | $puzzles_in_file == $next_puzzle_number or return 0; | ||
| 190 | } | ||
| 191 | |||
| 192 | return { | ||
| 193 | clues => $1, | ||
| 194 | bottomLine => ($4 || sprintf "puzzle # %d", ($next_puzzle_number || $puzzles_in_file)), | ||
| 195 | extraRegion => $3, | ||
| 196 | jigsaw => $2, | ||
| 197 | } | ||
| 198 | }; | ||
| 199 | |||
| 200 | my $hdl; | ||
| 201 | if (ref($file) eq 'GLOB') { | ||
| 202 | $hdl = $file; | ||
| 203 | } else { | ||
| 204 | open $hdl, '<', $file or die "$file: $!\n"; | ||
| 205 | $file =~ s|.*\/||; | ||
| 206 | } | ||
| 207 | |||
| 208 | my $pc = 0; | ||
| 209 | |||
| 210 | while (<$hdl>) { | ||
| 211 | chomp(); | ||
| 212 | my $puzzle = &$line_handler($_) or next; | ||
| 213 | $self->add_puzzle(%$puzzle); | ||
| 214 | $pc++; | ||
| 215 | if ($puzzle_numbers) { | ||
| 216 | $next_puzzle_number = shift(@puzzle_numbers) or last; | ||
| 217 | } | ||
| 218 | } | ||
| 219 | if (ref($file) eq 'GLOB') { | ||
| 220 | CORE::close $hdl; | ||
| 221 | print "\n$pc out of $puzzles_in_file puzzles processed from file handle\n" unless $self->{quiet}; | ||
| 222 | |||
| 223 | } else { | ||
| 224 | # if we got a handle, the user might want to keep it open | ||
| 225 | print "\n$pc out of $puzzles_in_file puzzles processed from file $file\n" unless $self->{quiet}; | ||
| 226 | } | ||
| 227 | } | ||
| 228 | |||
| 229 | sub page_break { | ||
| 230 | my $self = shift; | ||
| 231 | $self->{nextPosOnPage} = 0; | ||
| 232 | } | ||
| 233 | |||
| 234 | sub close { | ||
| 235 | my $self = shift; | ||
| 236 | |||
| 237 | printf "\n%d pages with %d sudoku added.\n", $self->{pagesAdded}, $self->{puzzleCount} unless $self->{quiet}; | ||
| 238 | |||
| 239 | my $file = (shift() || $self->{appendFile}) or die "No filename for pdf output provided during ->close().\n"; | ||
| 240 | |||
| 241 | if ($PDF_API2_IS_OLD) { | ||
| 242 | $self->{pdf}->info(ModDate => 'D:' . _format_time_w_zone_offset()); | ||
| 243 | $self->{pdf}->saveas($file); | ||
| 244 | $self->{pdf}->release(); | ||
| 245 | } else { | ||
| 246 | $self->{pdf}->modified('D:' . _format_time_w_zone_offset()); | ||
| 247 | $self->{pdf}->save($file); | ||
| 248 | $self->{pdf}->close(); | ||
| 249 | } | ||
| 250 | $self->{pdf} = undef; | ||
| 251 | |||
| 252 | print "$file written\n" unless $self->{quiet}; | ||
| 253 | } | ||
| 254 | |||
| 255 | ######################################################################### | ||
| 256 | |||
| 257 | sub _init { | ||
| 258 | my $params = shift; | ||
| 259 | |||
| 260 | $params->{creator} = __PACKAGE__ . ' v. ' . $VERSION; | ||
| 261 | |||
| 262 | my $pdf; | ||
| 263 | if ($params->{appendFile}) { | ||
| 264 | $pdf = PDF::API2->open($params->{appendFile}); | ||
| 265 | } else { | ||
| 266 | $pdf = PDF::API2->new(); | ||
| 267 | } | ||
| 268 | |||
| 269 | if ($PDF_API2_IS_OLD) { | ||
| 270 | $params->{font} = $pdf->corefont($params->{textFont}, -encode => $params->{textEncoding}); | ||
| 271 | my %info_hash = (); | ||
| 272 | foreach my $kw (qw(creator title author subject keywords)) { | ||
| 273 | $info_hash{ucfirst $kw} = $params->{$kw} if $params->{$kw}; | ||
| 274 | } | ||
| 275 | $info_hash{CreationDate} = 'D:' . _format_time_w_zone_offset(); | ||
| 276 | $pdf->info(%info_hash); | ||
| 277 | |||
| 278 | } else { | ||
| 279 | $params->{font} = $pdf->font($params->{textFont}, -encode => $params->{textEncoding}); | ||
| 280 | $pdf->created('D:' . _format_time_w_zone_offset()); | ||
| 281 | $params->{creator} and $pdf->creator($params->{creator}); | ||
| 282 | $params->{title} and $pdf->title($params->{title}); | ||
| 283 | $params->{author} and $pdf->author($params->{author}); | ||
| 284 | $params->{subject} and $pdf->subject($params->{subject}); | ||
| 285 | $params->{keywords} and $pdf->keywords($params->{keywords}); | ||
| 286 | } | ||
| 287 | $params->{pdf} = $pdf; | ||
| 288 | |||
| 289 | my $media_size = [PDF::API2::Util::page_size($params->{pageFormat})]; | ||
| 290 | $media_size->[2] && $media_size->[3] or die "could not determine the page size!"; | ||
| 291 | |||
| 292 | if ($params->{pageOrientation}) { | ||
| 293 | if (($params->{pageOrientation} eq 'landscape' and $media_size->[2] < $media_size->[3]) | ||
| 294 | || ($params->{pageOrientation} eq 'portrait' and $media_size->[2] > $media_size->[3])) { | ||
| 295 | # rotate media | ||
| 296 | my $temp = $media_size->[3]; | ||
| 297 | $media_size->[3] = $media_size->[2]; | ||
| 298 | $media_size->[2] = $temp; | ||
| 299 | } | ||
| 300 | } | ||
| 301 | |||
| 302 | $params->{pageWidth} = $media_size->[2]; | ||
| 303 | $params->{pageHeight} = $media_size->[3]; | ||
| 304 | $params->{pageSize} = $media_size; | ||
| 305 | |||
| 306 | my $puzzles_per_page = $params->{puzzlesPerPage}; | ||
| 307 | |||
| 308 | my ($h_puzzles_per_page, $v_puzzles_per_page); | ||
| 309 | |||
| 310 | if ($puzzles_per_page =~ /^(\d+)x(\d+)$/i) { | ||
| 311 | $h_puzzles_per_page = $1; | ||
| 312 | $v_puzzles_per_page = $2; | ||
| 313 | $params->{puzzlesPerPage} = $1 * $2; | ||
| 314 | } elsif ($puzzles_per_page eq '1') { | ||
| 315 | $h_puzzles_per_page = 1; | ||
| 316 | $v_puzzles_per_page = 1; | ||
| 317 | } elsif ($puzzles_per_page eq '2') { | ||
| 318 | $h_puzzles_per_page = 1; | ||
| 319 | $v_puzzles_per_page = 2; | ||
| 320 | } elsif ($puzzles_per_page eq '3') { | ||
| 321 | $h_puzzles_per_page = 2; | ||
| 322 | $v_puzzles_per_page = 1; | ||
| 323 | } elsif ($puzzles_per_page eq '4') { | ||
| 324 | $h_puzzles_per_page = 2; | ||
| 325 | $v_puzzles_per_page = 2; | ||
| 326 | } else { | ||
| 327 | my $page_ratio = $params->{pageHeight} / $params->{pageWidth}; | ||
| 328 | my $v_pages = $params->{puzzlesPerPage} / $page_ratio; | ||
| 329 | die "You might rather want to specify 'puzzlesPerPage' as a layout, like e.g. '2x3' (WxH)\n"; | ||
| 330 | } | ||
| 331 | |||
| 332 | _add_table_settings($params); | ||
| 333 | _add_table_properties($params); | ||
| 334 | _add_table_positions($params, $h_puzzles_per_page, $v_puzzles_per_page); | ||
| 335 | |||
| 336 | $params->{puzzleCount} = | ||
| 337 | $params->{pagesAdded} = | ||
| 338 | $params->{nextPosOnPage} = 0; | ||
| 339 | |||
| 340 | return $params | ||
| 341 | } | ||
| 342 | |||
| 343 | sub _add_table_settings { | ||
| 344 | my ($params) = shift; | ||
| 345 | |||
| 346 | # intialization of parameters for the PDF::Table->table() method | ||
| 347 | # some values will get overwritten during init() ! | ||
| 348 | my $font = $PDF_API2_IS_OLD ? | ||
| 349 | $params->{pdf}->corefont('Helvetica-Bold') : $params->{pdf}->font('Helvetica-Bold'); | ||
| 350 | |||
| 351 | $params->{tableSettings} = $PDF_TABLE_IS_OLD ? { | ||
| 352 | start_h => 280, # with 279, the table will be broken up, even when exactly 279 gets returned on a dry run (ink => 0) | ||
| 353 | w => 279, | ||
| 354 | |||
| 355 | next_h => 500, | ||
| 356 | next_y => 700, | ||
| 357 | |||
| 358 | border => 1, | ||
| 359 | padding_top => 1.5, | ||
| 360 | padding_bottom => 7.5, | ||
| 361 | row_height => 31, | ||
| 362 | font => $font, | ||
| 363 | font_size => 22, | ||
| 364 | column_props => [ | ||
| 365 | (({min_w => 31, justify => 'center'}) x 9) | ||
| 366 | ], | ||
| 367 | |||
| 368 | } : { | ||
| 369 | h => 280, # with 279, the table will be broken up, even when exactly 279 gets returned on a dry run (ink => 0) | ||
| 370 | w => 279, | ||
| 371 | |||
| 372 | next_h => 500, | ||
| 373 | next_y => 700, | ||
| 374 | |||
| 375 | border_w => 1, | ||
| 376 | # following 2 values should omit the table's outer borders, but don't work | ||
| 377 | #h_border_w => 0, | ||
| 378 | #v_border_w => 0, | ||
| 379 | padding => 0, | ||
| 380 | padding_top => 1.5, | ||
| 381 | min_rh => 31, | ||
| 382 | font => $font, | ||
| 383 | font_size => 22, | ||
| 384 | # global size and justify came stepwise in recent versions | ||
| 385 | #size => join(' ', ((31) x 9)), | ||
| 386 | #justify => 'center', | ||
| 387 | column_props => [ | ||
| 388 | (({min_w => 31, justify => 'center'}) x 9) | ||
| 389 | ], | ||
| 390 | }; | ||
| 391 | } | ||
| 392 | |||
| 393 | sub _add_table_positions{ | ||
| 394 | my ($params, $h_puzzles_per_page, $v_puzzles_per_page) = @_; | ||
| 395 | |||
| 396 | my $trim = 12; | ||
| 397 | my $trim_top = 30; | ||
| 398 | my $trim_bottom = 35; | ||
| 399 | my $h_spacing = 12; | ||
| 400 | # the preset values estimate 2x2 puzzles, calculate a min vertical space by scaling fontsize + padding | ||
| 401 | my $v_spacing = 2 * ($params->{tableSettings}{font_size} + 3) / $v_puzzles_per_page; | ||
| 402 | my $h_size = ($params->{pageWidth} - 2 * $trim - (($h_puzzles_per_page - 1) * $h_spacing)) / $h_puzzles_per_page; | ||
| 403 | my $v_size = (($params->{pageHeight} - ($trim_top + $trim_bottom)) - ($v_puzzles_per_page * $v_spacing)) / $v_puzzles_per_page; | ||
| 404 | |||
| 405 | my ($table_size, $cell_size); | ||
| 406 | if ($h_size < $v_size) { | ||
| 407 | $cell_size = int $h_size / 9; | ||
| 408 | } else { | ||
| 409 | $cell_size = int $v_size / 9; | ||
| 410 | } | ||
| 411 | $table_size = $cell_size * 9; | ||
| 412 | |||
| 413 | $h_spacing = $h_puzzles_per_page > 1 ? | ||
| 414 | int ($params->{pageWidth} - 2 * $trim - ($h_puzzles_per_page * $table_size)) / ($h_puzzles_per_page - 1) | ||
| 415 | : 0; | ||
| 416 | $v_spacing = $v_puzzles_per_page > 1 ? | ||
| 417 | int (($params->{pageHeight} - ($trim_top + $trim_bottom)) - ($v_puzzles_per_page * $table_size)) / ($v_puzzles_per_page) | ||
| 418 | : 0; | ||
| 419 | |||
| 420 | my @positions = (); | ||
| 421 | my $x = $trim; | ||
| 422 | my $y = $params->{pageHeight} - $trim_top; | ||
| 423 | for (my $r = 0; $r < $v_puzzles_per_page; $r++) { | ||
| 424 | $x = $trim; | ||
| 425 | for (my $c = 0; $c < $h_puzzles_per_page; $c++) { | ||
| 426 | push @positions, [ | ||
| 427 | $x, $y, | ||
| 428 | ]; | ||
| 429 | $x += ($table_size + $h_spacing); | ||
| 430 | } | ||
| 431 | $y -= ($table_size + $v_spacing); | ||
| 432 | } | ||
| 433 | $params->{positionData} = \@positions; | ||
| 434 | $params->{factor} = _scale_table($params->{tableSettings}, $table_size, $cell_size); | ||
| 435 | |||
| 436 | return $params | ||
| 437 | } | ||
| 438 | |||
| 439 | sub _scale_table { | ||
| 440 | my ($settings, $table_size, $cell_size) = @_; | ||
| 441 | |||
| 442 | my $factor = $table_size / $settings->{w}; | ||
| 443 | return 1 if $factor == 1; | ||
| 444 | |||
| 445 | if ($PDF_TABLE_IS_OLD) { | ||
| 446 | $settings->{start_h} = $table_size + 1; | ||
| 447 | $settings->{w} = $table_size; | ||
| 448 | $settings->{row_height} = $cell_size; | ||
| 449 | $settings->{border} *= $factor; | ||
| 450 | $settings->{font_size} *= $factor; | ||
| 451 | $settings->{padding_top} *= $factor if $settings->{padding_top}; | ||
| 452 | $settings->{padding_bottom} *= $factor if $settings->{padding_bottom}; | ||
| 453 | $settings->{column_props} = [ | ||
| 454 | (({min_w => $cell_size, justify => 'center'}) x 9) | ||
| 455 | ], | ||
| 456 | |||
| 457 | } else { | ||
| 458 | $settings->{h} = $table_size + 1; | ||
| 459 | $settings->{w} = $table_size; | ||
| 460 | $settings->{min_rh} = $cell_size; | ||
| 461 | $settings->{border_w} *= $factor; | ||
| 462 | $settings->{font_size} *= $factor; | ||
| 463 | $settings->{padding_top} *= $factor if $settings->{padding_top}; | ||
| 464 | $settings->{column_props} = [ | ||
| 465 | (({min_w => $cell_size, justify => 'center'}) x 9) | ||
| 466 | ], | ||
| 467 | } | ||
| 468 | return $factor | ||
| 469 | } | ||
| 470 | |||
| 471 | sub _add_table_properties { | ||
| 472 | my $params = shift; | ||
| 473 | |||
| 474 | $params->{patternProp} = { | ||
| 475 | # color of extraRegion | ||
| 476 | background_color => '#6666ff', | ||
| 477 | }; | ||
| 478 | |||
| 479 | $params->{greyProp} = { | ||
| 480 | # color of odd 3x3 boxes | ||
| 481 | # '#e6e6e6' is to light, almost invisible in print! | ||
| 482 | background_color => '#d0d0d0', | ||
| 483 | }; | ||
| 484 | |||
| 485 | $params->{whiteProp} = { | ||
| 486 | # default cell color (undefined would be transparent) | ||
| 487 | background_color => '#ffffff', | ||
| 488 | }; | ||
| 489 | |||
| 490 | $params->{colorPattern} = { | ||
| 491 | # colors used in c-variant | ||
| 492 | '00' => '#ff6666', # red | ||
| 493 | '01' => '#808080', # dark grey | ||
| 494 | '02' => '#66ff66', # green | ||
| 495 | '10' => '#c0c0c0', # light grey | ||
| 496 | '11' => '#66ffff', # light blue | ||
| 497 | '12' => '#b266ff', # purple | ||
| 498 | '20' => '#ffff66', # yellow | ||
| 499 | '21' => '#ff66ff', # magenta | ||
| 500 | '22' => '#ffffff', # white | ||
| 501 | }; | ||
| 502 | |||
| 503 | $params->{areaColors} = { | ||
| 504 | # color sets used in jigsaw puzzles without extraRegion | ||
| 505 | '3' => [ | ||
| 506 | '#ffab99', # red | ||
| 507 | '#99ff99', # green | ||
| 508 | '#99bcff', # light blue | ||
| 509 | ], | ||
| 510 | '4' => [ | ||
| 511 | '#fff199', # yellow | ||
| 512 | '#99ff99', # green | ||
| 513 | '#99bcff', # light blue | ||
| 514 | '#ffab99', # red | ||
| 515 | ], | ||
| 516 | }; | ||
| 517 | |||
| 518 | return $params | ||
| 519 | } | ||
| 520 | |||
| 521 | ######################################################################### | ||
| 522 | |||
| 523 | sub _create_matrix { | ||
| 524 | # put the string of 81 chars into a 9x9 array | ||
| 525 | my $line = shift() or return undef; | ||
| 526 | |||
| 527 | my @numbers = split //, $line; | ||
| 528 | |||
| 529 | my @matrix = (); | ||
| 530 | while (@numbers) { | ||
| 531 | push @matrix, [ splice @numbers, 0, 9 ]; | ||
| 532 | } | ||
| 533 | |||
| 534 | \@matrix | ||
| 535 | } | ||
| 536 | |||
| 537 | sub _is_pattern_area { | ||
| 538 | my $self = shift; | ||
| 539 | my ($r, $c, $v) = @_; | ||
| 540 | |||
| 541 | if ($v eq 'n') { | ||
| 542 | # standard | ||
| 543 | return 0; | ||
| 544 | } elsif ($v eq 'x') { | ||
| 545 | # x-sudoku | ||
| 546 | return (($r == $c) || ($r == 8 - $c)) ? $self->{patternProp} : 0; | ||
| 547 | } elsif ($v eq 'h') { | ||
| 548 | # hyper | ||
| 549 | return ($r=~/^[123567]$/ && $c=~/^[123567]$/) ? $self->{patternProp} : 0; | ||
| 550 | } elsif ($v eq 'p') { | ||
| 551 | # percent | ||
| 552 | return (($r == 8 - $c) || ($r=~/^[123]$/ && $c=~/^[123]$/) || ($r=~/^[567]$/ && $c=~/^[567]$/)) ? $self->{patternProp} : 0; | ||
| 553 | } elsif ($v eq 'd') { | ||
| 554 | # center dot | ||
| 555 | return ($r=~/^[147]$/ && $c=~/^[147]$/) ? $self->{patternProp} : 0; | ||
| 556 | } elsif ($v eq 'a') { | ||
| 557 | # asterisk | ||
| 558 | my $cmp = $r.$c; | ||
| 559 | return ($cmp =~ /^(14|22|26|41|44|47|62|66|74)$/) ? $self->{patternProp} : 0; | ||
| 560 | } elsif ($v eq 'g') { | ||
| 561 | # girandola | ||
| 562 | my $cmp = $r.$c; | ||
| 563 | return ($cmp =~ /^(00|08|14|41|44|47|74|80|88)$/) ? $self->{patternProp} : 0; | ||
| 564 | } elsif ($v eq 'c') { | ||
| 565 | # color | ||
| 566 | return { | ||
| 567 | background_color => $self->{colorPattern}{$r%3 . $c%3} | ||
| 568 | }; | ||
| 569 | } else { | ||
| 570 | die "don't know about pattern '$v'"; | ||
| 571 | } | ||
| 572 | } | ||
| 573 | |||
| 574 | sub _is_grey_block { | ||
| 575 | my ($r, $c) = @_; | ||
| 576 | return (($r>2 && $r<6) xor ($c>2 && $c<6)); | ||
| 577 | } | ||
| 578 | |||
| 579 | sub _get_cell_prop { | ||
| 580 | my $self = shift; | ||
| 581 | my ($i, $j, $variant, $grid, $area_colors) = @_; | ||
| 582 | |||
| 583 | if (my $prop = $self->_is_pattern_area($i, $j, $variant)) { | ||
| 584 | return $prop; | ||
| 585 | |||
| 586 | } elsif (! $grid) { | ||
| 587 | return _is_grey_block($i, $j) ? $self->{greyProp} : $self->{whiteProp}; | ||
| 588 | |||
| 589 | } elsif ($variant eq 'n') { | ||
| 590 | return { | ||
| 591 | background_color => $area_colors->{$grid->[$i][$j]}, | ||
| 592 | }; | ||
| 593 | } | ||
| 594 | |||
| 595 | return $self->{whiteProp}; | ||
| 596 | } | ||
| 597 | |||
| 598 | # determining the colors for jigsaw lines puzzles is anything but trivial, | ||
| 599 | # at least if we want to use as little colors as possible. | ||
| 600 | sub _get_area_colors { | ||
| 601 | my $self = shift; | ||
| 602 | my $areas = shift() or return undef; | ||
| 603 | my $puzzle_number = shift(); | ||
| 604 | |||
| 605 | my $adjoins_with = {}; | ||
| 606 | my $size = @$areas; | ||
| 607 | for (my $i = 0; $i < $size; $i++) { | ||
| 608 | for (my $j = 0; $j < $size; $j++) { | ||
| 609 | my $a = $areas->[$i][$j]; | ||
| 610 | |||
| 611 | if ($j < $size - 1) { | ||
| 612 | my $r = $areas->[$i][$j+1]; | ||
| 613 | if ($r != $a) { | ||
| 614 | $adjoins_with->{$a}{$r} = 1; | ||
| 615 | $adjoins_with->{$r}{$a} = 1; | ||
| 616 | } | ||
| 617 | } | ||
| 618 | |||
| 619 | if ($i < $size - 1) { | ||
| 620 | my $d = $areas->[$i+1][$j]; | ||
| 621 | if ($d != $a) { | ||
| 622 | $adjoins_with->{$a}{$d} = 1; | ||
| 623 | $adjoins_with->{$d}{$a} = 1; | ||
| 624 | } | ||
| 625 | } | ||
| 626 | } | ||
| 627 | } | ||
| 628 | |||
| 629 | my $area_to_color = {}; | ||
| 630 | my $assigned_colors = {}; | ||
| 631 | my $max_color = 0; | ||
| 632 | my $most_neighbours = 0; | ||
| 633 | # sort areas by number of neighbours, descending | ||
| 634 | # secondary sort by area index, else don't use the minimal number of colors | ||
| 635 | foreach my $area (sort { | ||
| 636 | scalar(keys %{$adjoins_with->{$b}}) <=> scalar(keys %{$adjoins_with->{$a}}) | ||
| 637 | || $a <=> $b | ||
| 638 | } keys %$adjoins_with) { | ||
| 639 | $most_neighbours ||= $area; | ||
| 640 | |||
| 641 | foreach my $color (0 .. 3) { | ||
| 642 | my $conflict = 0; | ||
| 643 | foreach my $neighbour (keys %{$adjoins_with->{$area}}) { | ||
| 644 | my $c = $area_to_color->{$neighbour}; | ||
| 645 | if (defined($c) && $c == $color) { | ||
| 646 | $conflict = 1; | ||
| 647 | last; | ||
| 648 | } | ||
| 649 | } | ||
| 650 | unless ($conflict) { | ||
| 651 | $area_to_color->{$area} = $color; | ||
| 652 | if ($color > $max_color) { | ||
| 653 | $max_color = $color; | ||
| 654 | } | ||
| 655 | last; | ||
| 656 | } | ||
| 657 | } | ||
| 658 | } | ||
| 659 | my $colors_used = $max_color + 1; | ||
| 660 | if ($colors_used == 2) { | ||
| 661 | warn "[puzzle #$puzzle_number] only 2 colors needed: replacing color of area $most_neighbours with 3rd color\n"; | ||
| 662 | $area_to_color->{$most_neighbours} = 2; | ||
| 663 | $colors_used = 3; | ||
| 664 | |||
| 665 | } elsif ($colors_used != 3 && $colors_used != 4) { | ||
| 666 | die "\nfatal: an unprepared number $colors_used of colors are used:\n"; | ||
| 667 | } | ||
| 668 | |||
| 669 | foreach my $a (keys %$area_to_color) { | ||
| 670 | $area_to_color->{$a} = $self->{areaColors}{$colors_used}[$area_to_color->{$a}]; | ||
| 671 | } | ||
| 672 | |||
| 673 | return $area_to_color; | ||
| 674 | } | ||
| 675 | |||
| 676 | sub _draw_straight_lines { | ||
| 677 | my ($content, $x, $y, , $table_size, $cell_size, $factor) = @_; | ||
| 678 | |||
| 679 | if ($PDF_API2_IS_OLD) { | ||
| 680 | $content->linewidth(3 * $factor); | ||
| 681 | $content->linecap(2); | ||
| 682 | } else { | ||
| 683 | $content->line_width(3 * $factor); | ||
| 684 | $content->line_cap(2); | ||
| 685 | } | ||
| 686 | |||
| 687 | # 4 vertical lines | ||
| 688 | $content->move($x, $y); | ||
| 689 | $content->vline($y-$table_size); | ||
| 690 | $content->move($x+($cell_size*3), $y); | ||
| 691 | $content->vline($y-$table_size); | ||
| 692 | $content->move($x+($cell_size*6), $y); | ||
| 693 | $content->vline($y-$table_size); | ||
| 694 | $content->move($x+$table_size, $y); | ||
| 695 | $content->vline($y-$table_size); | ||
| 696 | |||
| 697 | # 4 horizontal lines | ||
| 698 | $content->move($x, $y); | ||
| 699 | $content->hline($x+$table_size); | ||
| 700 | $content->move($x, $y-($cell_size*3)); | ||
| 701 | $content->hline($x+$table_size); | ||
| 702 | $content->move($x, $y-($cell_size*6)); | ||
| 703 | $content->hline($x+$table_size); | ||
| 704 | $content->move($x, $y-$table_size); | ||
| 705 | $content->hline($x+$table_size); | ||
| 706 | |||
| 707 | $content->stroke(); | ||
| 708 | } | ||
| 709 | |||
| 710 | sub _draw_jigsaw_lines { | ||
| 711 | my ($content, $x, $y, $grid, $table_size, $cell_size, $factor) = @_; | ||
| 712 | |||
| 713 | if ($PDF_API2_IS_OLD) { | ||
| 714 | $content->linewidth(3 * $factor); | ||
| 715 | $content->linecap(2); | ||
| 716 | } else { | ||
| 717 | $content->line_width(3 * $factor); | ||
| 718 | $content->line_cap(2); | ||
| 719 | } | ||
| 720 | |||
| 721 | # outer lines | ||
| 722 | $content->move($x, $y); | ||
| 723 | $content->vline($y-$table_size); | ||
| 724 | $content->move($x+$table_size, $y); | ||
| 725 | $content->vline($y-$table_size); | ||
| 726 | $content->move($x, $y); | ||
| 727 | $content->hline($x+$table_size); | ||
| 728 | $content->move($x, $y-$table_size); | ||
| 729 | $content->hline($x+$table_size); | ||
| 730 | |||
| 731 | $content->stroke(); | ||
| 732 | |||
| 733 | # jigsaw lines | ||
| 734 | if ($PDF_API2_IS_OLD) { | ||
| 735 | $content->linecap(0); | ||
| 736 | } else { | ||
| 737 | $content->line_cap(0); | ||
| 738 | } | ||
| 739 | |||
| 740 | for (my $i = 0; $i < 9; $i++) { | ||
| 741 | my $my = $y - ($i*$cell_size); | ||
| 742 | for (my $j = 0; $j < 9; $j++) { | ||
| 743 | my $mx = $x + ($j*$cell_size); | ||
| 744 | my $this_area = $grid->[$i][$j]; | ||
| 745 | |||
| 746 | if ($i < 8) { | ||
| 747 | if ($grid->[$i+1][$j] != $this_area) { | ||
| 748 | $content->move($mx, $my-$cell_size); | ||
| 749 | $content->hline($mx+$cell_size); | ||
| 750 | } | ||
| 751 | } | ||
| 752 | |||
| 753 | if ($j < 8) { | ||
| 754 | if ($grid->[$i][$j+1] != $this_area) { | ||
| 755 | $content->move($mx+$cell_size, $my); | ||
| 756 | $content->vline($my-$cell_size); | ||
| 757 | } | ||
| 758 | } | ||
| 759 | } | ||
| 760 | } | ||
| 761 | |||
| 762 | $content->stroke(); | ||
| 763 | } | ||
| 764 | |||
| 765 | sub _format_time_w_zone_offset { | ||
| 766 | my $epoch = shift() || time(); | ||
| 767 | |||
| 768 | my $offset_sec = $epoch - timelocal( gmtime $epoch ); | ||
| 769 | my $sign = ($offset_sec =~ s/^-//) ? '-' : ($offset_sec > 0 ) ? '+' : 'Z'; | ||
| 770 | |||
| 771 | my $offset = ''; | ||
| 772 | if ($offset_sec > 0) { | ||
| 773 | my $offset_hrs = int $offset_sec / 3600; | ||
| 774 | my $offset_min = int( ($offset_sec % 3600) / 60); | ||
| 775 | $offset = sprintf '%02d\'%02d', $offset_hrs, $offset_min; | ||
| 776 | # Time offset ought to be: [-+Z] (hh') (mm') | ||
| 777 | # API2 until v2.041 gave a correct format example in the pod, but no validation took place. | ||
| 778 | # From v2.042 - 2.044 introduced a (faulty) date validation which _required_ a _leading_ | ||
| 779 | # apostrophe with offset minutes but croaked on the trailing offset mm' apostrophe. | ||
| 780 | # Now both apostrophes are optional since v2.045. | ||
| 781 | if ($PDF::API2::VERSION < 2.042 || $PDF::API2::VERSION > 2.044) { | ||
| 782 | # (no validation || 'tolerant' validation) => pass correct format | ||
| 783 | $offset .= "'"; | ||
| 784 | } | ||
| 785 | } # or else just return Z(ulu), to avoid any confusion | ||
| 786 | |||
| 787 | my @lt = localtime($epoch); | ||
| 788 | return sprintf('%d%02d%02d%02d%02d%02d%s%s', | ||
| 789 | $lt[5]+1900, $lt[4]+1, @lt[3,2,1,0], $sign, $offset) | ||
| 790 | } | ||
| 791 | |||
| 792 | sub _make_version_comparable { | ||
| 793 | my $v = shift; | ||
| 794 | $v =~ s/^(v?[0-9]+(?:\.[0-9]+)).*$/$1/; | ||
| 795 | if ($v =~ s/^v//) { | ||
| 796 | $v =~ s/^\./\.0/; | ||
| 797 | } | ||
| 798 | return $v | ||
| 799 | } | ||
| 800 | |||
| 801 | 1; | ||
| 802 | |||
| 803 | =encoding UTF-8 | ||
| 804 | |||
| 805 | =head1 NAME | ||
| 806 | |||
| 807 | Games::Sudoku::Pdf - Produce pdf files from your digital Sudoku sources or collections. | ||
| 808 | |||
| 809 | =head1 DESCRIPTION | ||
| 810 | |||
| 811 | An easy way to create pdf files of 9x9 Sudoku puzzles from various sources, which you can give to your friends or print out and pencil solve at the beach. | ||
| 812 | Sixteen variants of 9x9 Sudoku are supported. (See the output of scripts/example.pl.) | ||
| 813 | Just specify how many puzzles (columns x rows) to arrange per page and the positioning and scaling will be adapted automatically. | ||
| 814 | |||
| 815 | =head1 SYNOPSIS | ||
| 816 | |||
| 817 | my $writer = Games::Sudoku::Pdf->new(%options); | ||
| 818 | |||
| 819 | $writer->add_puzzle( | ||
| 820 | clues => '.9.46.....85...4.7..........3.2.8.4...9...1...6.1.4.5..........3.4...92.....49.8.', | ||
| 821 | jigsaw => '111222333141122333141226663441522563745555563745885966744488969777889969777888999', | ||
| 822 | extraRegion => 'g', | ||
| 823 | bottomLine => 'jigsaw #5 from Daisy (very hard!)', | ||
| 824 | ); | ||
| 825 | |||
| 826 | $writer->read_input_file('./all-17-clues-sudoku.txt', slice => [5..9, 7..25]); | ||
| 827 | |||
| 828 | $writer->close(); | ||
| 829 | |||
| 830 | >sudoku2pdf my_sudokus.txt > my_sudokus.pdf | ||
| 831 | |||
| 832 | =head1 METHODS | ||
| 833 | |||
| 834 | =head2 new() | ||
| 835 | |||
| 836 | Games::Sudoku::Pdf->new( %options ) | ||
| 837 | |||
| 838 | Returns the writer object. The following options are available: | ||
| 839 | |||
| 840 | =head3 pageFormat default 'A4' | ||
| 841 | |||
| 842 | Find possible values in L<PDF::API2::Resource::PaperSizes>. | ||
| 843 | |||
| 844 | =head3 pageOrientation | ||
| 845 | |||
| 846 | Possible values are 'portrait' or 'landscape'. | ||
| 847 | Default is the resp. format's definiton in L<PDF::API2::Resource::PaperSizes>. | ||
| 848 | |||
| 849 | =head3 puzzlesPerPage default 4 (resolved to '2x2') | ||
| 850 | |||
| 851 | Specifies the number of Sudoku per page, their size and positions. | ||
| 852 | You will probably want to give the WxH notation. | ||
| 853 | If you specify e.g. '1x5', 5 small Sudoku will be placed at the left side, leaving place for your manual notes to the right. | ||
| 854 | Once you specify 2 or more columns, they will get equally distributed from left to right. | ||
| 855 | |||
| 856 | =head3 appendFile | ||
| 857 | |||
| 858 | You can specify path and name of any existing pdf file, to which the new pages shall be appended. | ||
| 859 | |||
| 860 | =head3 title, author, subject, keywords | ||
| 861 | |||
| 862 | Any of these four optional values will be written to the pdf meta data fields. | ||
| 863 | |||
| 864 | =head3 extraRegion default none | ||
| 865 | |||
| 866 | For Sudoku sporting an 'extra region' (X-, Hyper-, Percent- ...) this parameter can be given globally here, | ||
| 867 | or for each puzzle L<added|/"add_puzzle()">. | ||
| 868 | The following variants are recognized: | ||
| 869 | |||
| 870 | =over 4 | ||
| 871 | |||
| 872 | =item x X-Sudoku | ||
| 873 | |||
| 874 | =item h Hyper Sudoku | ||
| 875 | |||
| 876 | =item p Percent Sudoku | ||
| 877 | |||
| 878 | =item c Color Sudoku | ||
| 879 | |||
| 880 | Just one fixed version is currently possible (colors 1-9): | ||
| 881 | |||
| 882 | +-------------------+ | ||
| 883 | | 1 2 3 1 2 3 1 2 3 | | ||
| 884 | | 4 5 6 4 5 6 4 5 6 | | ||
| 885 | | 7 8 9 7 8 9 7 8 9 | | ||
| 886 | | 1 2 3 1 2 3 1 2 3 | | ||
| 887 | | 4 5 6 4 5 6 4 5 6 | | ||
| 888 | | 7 8 9 7 8 9 7 8 9 | | ||
| 889 | | 1 2 3 1 2 3 1 2 3 | | ||
| 890 | | 4 5 6 4 5 6 4 5 6 | | ||
| 891 | | 7 8 9 7 8 9 7 8 9 | | ||
| 892 | +-------------------+ | ||
| 893 | |||
| 894 | =item d Center Dot Sudoku | ||
| 895 | |||
| 896 | =item a Asterisk Sudoku | ||
| 897 | |||
| 898 | =item g Girandola Sudoku | ||
| 899 | |||
| 900 | =back | ||
| 901 | |||
| 902 | For an overview take a look at the script and output of L<scripts/example.pl>. | ||
| 903 | |||
| 904 | =head2 add_puzzle() | ||
| 905 | |||
| 906 | $writer->add_puzzle(%options) | ||
| 907 | |||
| 908 | Adds the next puzzle to the pdf. The options are: | ||
| 909 | |||
| 910 | =head3 clues mandatory | ||
| 911 | |||
| 912 | A string of 81 characters, the common Sudoku exchange format. Given clues as numbers 1-9, empty cells denoted by C<.>, C<0>, C<space> or any non-digit. | ||
| 913 | |||
| 914 | =head3 jigsaw optional | ||
| 915 | |||
| 916 | Instead of regular 3x3 boxes with straight sides, the puzzle can be broken up into irregular shapes. | ||
| 917 | These may be provided by a string of 81 characters with the numbers 1-9 whose positions form 9 contiguous areas in the puzzle matrix. | ||
| 918 | Refer to L<example.pl>. | ||
| 919 | |||
| 920 | =head3 extraRegion default none | ||
| 921 | |||
| 922 | A single letter of xhpcdag, as described in L<extraRegion|/"extraRegion default none"> above. | ||
| 923 | |||
| 924 | =head3 bottomLine default none | ||
| 925 | |||
| 926 | A short string which will be put beneath the puzzle. | ||
| 927 | You may want to provide the puzzle's source, its estimated difficulty, a number or anything else. | ||
| 928 | Because we use the pdf corefonts, only latin1 is supported. | ||
| 929 | |||
| 930 | It is up to you and your Sudoku sources, that the given clues together with the other optional parameters provided | ||
| 931 | defines a proper puzzle with exactly one solution. | ||
| 932 | |||
| 933 | =head2 read_input_file() | ||
| 934 | |||
| 935 | $writer->read_input_file($input_file, %options) | ||
| 936 | |||
| 937 | A convenience method to slurp an entire text file with your puzzle collection. | ||
| 938 | The $input_file may be a file name or an open handle. The %options are: | ||
| 939 | |||
| 940 | =head3 slice optional | ||
| 941 | |||
| 942 | An array reference that contains the numbers of the puzzle lines that will be processed. | ||
| 943 | Only lines starting with a string of 81 givens are counted. Or, if you provided a L<lineHandler|/"lineHandler optional">, for which the handler returned a hashref. | ||
| 944 | |||
| 945 | =head3 lineHandler optional | ||
| 946 | |||
| 947 | A reference to your custom subroutine thats given the chomp-ed line and has to return a hashref that will be fed to L<add_puzzle()|/"add_puzzle()">. | ||
| 948 | If the return value is false, the line is skipped. | ||
| 949 | |||
| 950 | If no custom line handler is provided, lines are expected to follow the format | ||
| 951 | |||
| 952 | <81 char givens> [<delim> [<81 char jigsaw>] [<delim> [<1 char extraRegion>] [<delim> [<bottomLine>]]]] | ||
| 953 | |||
| 954 | Delimiters can be C<'|', ':', ',', ';', E<lt>tabE<gt>>. | ||
| 955 | For any standard Sudoku, the givens alone are sufficient. | ||
| 956 | See the 4 parameter's descriptions to L<add_puzzle()|/"add_puzzle()">. | ||
| 957 | |||
| 958 | Note: If this somewhat limited input format does not suit you, take a look at the commandline script L<sudoku2pdf|/"sudoku2pdf">. | ||
| 959 | |||
| 960 | =head2 page_break() | ||
| 961 | |||
| 962 | $writer->page_break() | ||
| 963 | |||
| 964 | Continue adding puzzles on a new page with otherwise unchanged settings. | ||
| 965 | There will be B<no> empty pages inserted by repeated calls. | ||
| 966 | |||
| 967 | =head2 close() | ||
| 968 | |||
| 969 | $writer->close( $output_file ) | ||
| 970 | |||
| 971 | Writes the pdf to file and frees memory. | ||
| 972 | The $output_file may be omitted if an L<'appendFile'|/"appendFile"> was specified in L<new()|/"new()"> and if that file is supposed to be replaced. | ||
| 973 | B<Any existing files will get overwritten without a warning!> | ||
| 974 | |||
| 975 | =head1 SCRIPTS | ||
| 976 | |||
| 977 | =head2 sudoku2pdf | ||
| 978 | |||
| 979 | After installation of Games::Sudoku::Pdf this command line script should be in your path. | ||
| 980 | Flexible input options are available. Invoke C<E<gt>sudoku2pdf -h> for details. | ||
| 981 | |||
| 982 | =head1 DEPENDENCIES | ||
| 983 | |||
| 984 | =over 4 | ||
| 985 | |||
| 986 | =item * L<PDF::API2> | ||
| 987 | |||
| 988 | =item * L<PDF::Table> | ||
| 989 | |||
| 990 | =item * L<Time::Local> | ||
| 991 | |||
| 992 | =back | ||
| 993 | |||
| 994 | =head1 SEE ALSO | ||
| 995 | |||
| 996 | L<Games::Sudoku::PatternSolver::Generator>, L<Games::Sudoku::Html> | ||
| 997 | |||
| 998 | =head1 COPYRIGHT AND LICENSE | ||
| 999 | |||
| 1000 | The following copyright notice applies to all the files provided in | ||
| 1001 | this distribution, including binary files, unless explicitly noted | ||
| 1002 | otherwise. | ||
| 1003 | |||
| 1004 | This software is copyright (c) 2024 by Steffen Heinrich | ||
| 1005 | |||
| 1006 | This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. | ||
| 1007 | |||
| 1008 | =cut | ||