AddPage(); #--- Comment $pdf->SetFont( 'Courier' , '' , 750 / 60 ); $comment = 'This page contains 25 scrambles for .'; $pdf->Cell( 0, 5, 'This page contains 25 scrambles for .', '', 1, "L" ); $pdf->Cell( 0, 5, 'Each scramble has 40 moves shown on two lines.', '', 1, "L" ); $pdf->Cell( 0, 5, '', '', 1, "L" ); #--- Print 50 scramble lines (25 scrambles) for( $s=1; $s<26; $s++ ){ #--- Print the scramble number. $pdf->SetFont( 'Courier' , '' , 750 / 40 ); $pdf->Cell( 0, 10, $s, 'T', 0, "L" ); #--- Initialize face chooser. $f = rand( 0, 2 ); #--- Top and bottom line of the scramble foreach( array( 'T', 'B' ) as $border ){ #--- Get the scramble line and adjust the font size. $scramble = scrambleLine(); $pdf->SetFont( 'Courier' , '' , 750 / strlen($scramble) ); $pdf->Cell( 0, 5, $scramble, $border, 1, "R" ); } } } #--- Output the PDF document. $pdf->Output( "scramble3x3ruf.pdf", "I" ); #------------------------------------------------------------------------- function scrambleLine () { #------------------------------------------------------------------------- global $f; $faces = array( 'r', 'u', 'f' ); $dirs = array( "", "'", "2" ); foreach( range( 1, 20 ) as $t ){ #--- Determine face to turn. $f = ( $f + rand( 1, 2 ) ) % 3; #--- Add the turn. $out .= $faces[$f] . $dirs[rand(0,2)] . ' '; } return trim( $out ); } ?>