#!/usr/bin/perl #########################################################3 print "Script \t\"pdftohtmlB \" \n\t(Convert: PDF -> HTML)\n\nAuthor: Bruno Roth (roth\@lit.inpe.br)\n\n\n"; print "USE:\n\tpdftohtmlB PDF DEVICE RESOLUTION PAGE_SIZE_HTML [IMG|NOIMG]\n\n"; print "OPTIONS:\n"; print "\tPDF: \t\tfile\n"; print "\tDEVICE: \tpngmono pnggray png16 png256 png16m jpeg jpeggray \n"; print "\tRESOLUTION: \tpixels/inch resolution\n"; print "\tPAGE_SIZE_HTML: page (HTML) size in pixels\n"; print "\tIMG | NOIMG: \"Create/Not create\" device image\n"; #print "\tUPDATE_DEVICE_IMG: update device image#\n"; print "\n\nEX:\n\tpdftohtmlB file.pdf jpeg 100 500x0 IMG \n\n\n"; if(@ARGV != 5){ exit; } ########################################################3 #Configure $namepdf="../@ARGV[0]"; $basenamefig = "./p"; if (grep(/png/,@ARGV[1])){ $fig="png"; } else{ $fig="jpg"; } @reshtml = split(/x/,@ARGV[3]); $width=@reshtml[0];#842; $height=@reshtml[1];#595; $dpi=@ARGV[2]; @namepdfTMPL = split(/\./,@ARGV[0]); $namepdfTMP = @namepdfTMPL[0]; $dirhtml="html$namepdfTMP"; #print @ARGV[0],$namepdf,$basenamefig,$fig,$width,$height,$dirhtml; #exit; ########################################################################### mkdir($dirhtml,0777); chdir($dirhtml); #################### if (!@ARGV[5]=="0"){ system("/usr/bin/gs -r$dpi -dNOPAUSE -dBATCH -sDEVICE=@ARGV[1] -sOutputFile=$basenamefig@ARGV[5].$fig -dFirstPage=@ARGV[5] -dLastPage=@ARGV[5] $namepdf"); exit(); } ###################### $cont = -1; $beginHtml=" "; $endHtml="
"; $beginFigure = "
"; #$endFigure= "\" border=\"0\" align=\"middle\">"; $htmlcss=" body { background-color: white; } "; #################### system("/bin/echo \"$htmlcss\" > html.css"); ###################### #################### #system("/usr/bin/gs -r$dpi -dNOPAUSE -dBATCH -sDEVICE=@ARGV[1] -sOutputFile=$basenamefig\%d.$fig $namepdf"); if (!grep(/NOIMG/,@ARGV[4])){ system("/usr/bin/gs -r$dpi -dNOPAUSE -dBATCH -sDEVICE=@ARGV[1] -sOutputFile=$basenamefig\%d.$fig $namepdf"); } ###################### @filespng = qx!ls *.$fig!; $firstpage = -1; $lastpage = scalar(@filespng)-2; while($line = <@filespng>){ print "PAGE: $cont\n"; open(OUT,">$basenamefig$cont.html"); print OUT $beginHtml,"\n"; print OUT ""; print OUT "PAG: $cont

"; #print OUT "NAVEGAÇÃO:
"; print OUT "[INICIO]
"; $tmp = scalar($cont) + 50; if ($tmp>$lastpage){$tmp=$lastpage;} print OUT "[+50]
"; $tmp = scalar($cont) + 10; if ($tmp>$lastpage){$tmp=$lastpage;} print OUT "[+10]
"; $tmp = scalar($cont) + 5; if ($tmp>$lastpage){$tmp=$lastpage;} print OUT "[+05]
"; $tmp = scalar($cont) + 1; if ($tmp>$lastpage){$tmp=$lastpage;} print OUT "[+01]
"; $tmp = scalar($cont) - 1; if ($tmp<$firstpage){$tmp=$firstpage;} print OUT "[-01]
"; $tmp = scalar($cont) - 5; if ($tmp<$firstpage){$tmp=$firstpage;} print OUT "[-05]
"; $tmp = scalar($cont) - 10; if ($tmp<$firstpage){$tmp=$firstpage;} print OUT "[-10]
"; $tmp = scalar($cont) - 50; if ($tmp<$firstpage){$tmp=$firstpage;} print OUT "[-50]
"; print OUT "[FIM]
"; print OUT "
"; #print OUT "[@ARGV[0]]
"; print OUT "[PDF]
"; #for($cont2=1 ; $cont2 <= scalar(@filespng) ; $cont2++){ # print OUT "[$cont2] "; #} $contAux = $cont+2; print OUT ""; print OUT "",$beginFigure,$basenamefig,$contAux,".",$fig,$endFigure,"","\n",; print OUT $endHtml; close(OUT); $cont = $cont + 1; } exit;