Changeset 19734 for other-projects
- Timestamp:
- 2009-06-03T14:17:20+12:00 (15 years ago)
- Location:
- other-projects/trunk/realistic-books
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
other-projects/trunk/realistic-books/CASCADE-MAKE.sh
r19253 r19734 35 35 /bin/cp src/pdf2realbook.pl "$RBHOME_INSTALLED/bin/script/." 36 36 chmod a+x "$RBHOME_INSTALLED/bin/script/pdf2realbook.pl" 37 38 # Configure CGI files 39 40 rbfile="cgi-bin/rbsite.cfg" 41 echo "Setting rbhome to $REALISTIC_BOOKS_HOME in $rbfile" 42 cat "$rbfile.in" \ 43 | sed "s@\*\*RBHOME\*\*@$REALISTIC_BOOKS_HOME@g" \ 44 > "$rbfile" 45 46 perlbin=`which perl 2>/dev/null` 47 if [ $? == "0" ] ; then 48 cgifile="cgi-bin/make-realbook.cgi" 49 echo "Setting PERLBIN to $perlbin in $cgifile" 50 cat "$cgifile.in" \ 51 | sed "s@\*\*PERLBIN\*\*@$perlbin@g" \ 52 > "$cgifile" 53 else 54 echo "Unable to find perl on PATH. Failed to set PERLBIN in $cgifile" 55 fi 56 37 57 fi 38 58 -
other-projects/trunk/realistic-books/src/pdf2realbook.pl
r19628 r19734 112 112 my ($filename) = @_; 113 113 114 my $cmd = "pdf2swf --info $filename";114 my $cmd = "pdf2swf --info \"$filename\""; 115 115 if ($ENV{'RBOS'} =~ /^windows$/i) { 116 $cmd .= " 2>nul l";116 $cmd .= " 2>nul"; 117 117 } 118 118 else { … … 120 120 } 121 121 122 122 123 my @output_lines = split(/\n/,`$cmd`); 123 124 124 my $last_line = pop(@output_lines); 125 126 # Watch out for trailing \n 127 $last_line = pop(@output_lines) if ($last_line =~ m/^$/); 128 129 my ($num_pages) = ($last_line =~ m/^page=(\d+)/); 130 131 return $num_pages; 125 my $curr_page = 0; 126 my $total_width = 0; 127 my $total_height = 0; 128 129 my $double_check = 0; 130 foreach my $line (@output_lines) { 131 next if ($line =~ m/^$/); 132 133 if ($line =~ m/^page=(\d+)\s+width=(\d+\.?\d*)\s+height=(\d+\.?\d*)$/) { 134 $curr_page = $1; 135 my $width = $2; 136 my $height = $3; 137 $total_width += $width; 138 $total_height += $height; 139 } 140 $double_check++; 141 } 142 143 #my $last_line = pop(@output_lines); 144 145 ## Watch out for trailing \n 146 #$last_line = pop(@output_lines) if ($last_line =~ m/^$/); 147 148 #my ($num_pages) = ($last_line =~ m/^page=(\d+)/); 149 my $num_pages = $curr_page; 150 151 if ($double_check != $num_pages) { 152 print STDERR "Warning: inconsistency found in page count: $double_check vs $num_pages\n"; 153 print STDERR "Setting to $double_check\n"; 154 $num_pages = $double_check; 155 } 156 157 my $avg_width = $total_width / $num_pages; 158 my $avg_height = $total_height / $num_pages; 159 160 return ($num_pages,$avg_width,$avg_height); 161 132 162 } 133 163 … … 137 167 my ($full_folder_name,$folder_root,$filename) = @_; 138 168 139 my $num_pages = pdf2swf_info($filename); 169 my ($num_pages,$width,$height) = pdf2swf_info($filename); 170 140 171 print STDOUT "Total page: $num_pages\n"; 141 172 142 173 my $html_input = "<HTML>\n<title>$folder_root</title>\n<Description>\n"; 143 $html_input = "$html_input<!-- Please do not remove Filename and PageFolder metadata -->\n"; 144 $html_input = "$html_input<Metadata name=\"Filename\">$folder_root</Metadata>\n"; 145 $html_input = "$html_input<Metadata name=\"PageFolder\">.</Metadata>\n"; 146 $html_input = "$html_input<Metadata name=\"StartNumbering\">1</Metadata>\n"; 147 $html_input = "$html_input</Description>\n"; 174 $html_input .= "<!-- Please do not remove Filename and PageFolder metadata -->\n"; 175 $html_input .= " <Metadata name=\"Filename\">$folder_root</Metadata>\n"; 176 $html_input .= " <Metadata name=\"PageFolder\">.</Metadata>\n"; 177 $html_input .= " <Metadata name=\"StartNumbering\">1</Metadata>\n"; 178 $html_input .= " <Metadata name=\"pagedim\">${width}x${height}</Metadata>\n"; 179 $html_input .= "</Description>\n"; 148 180 149 181 for (my $i=1; $i<=$num_pages; $i++) { … … 152 184 my $frontFile = "$full_folder_name"; 153 185 my $output_file = catfile($frontFile,$backFile); 154 my $imgfile = `pdf2swf -p $i -s insertstop -s zoom=100 $filename -o $output_file`; 186 my $cmd = "pdf2swf -p $i -s insertstop -s zoom=100 \"$filename\" -o \"$output_file\""; 187 ## $cmd .= " 2>1"; 188 189 my $imgfile = `$cmd`; 155 190 156 191 print STDOUT "creating page $i\n";
Note:
See TracChangeset
for help on using the changeset viewer.