From 3ebbde8f3ab397ac0234e652368bd8cbfee47354 Mon Sep 17 00:00:00 2001 From: Siep Kroonenberg Date: Wed, 23 Jul 2008 10:38:37 +0000 Subject: Epspdf::pdf_to_eps header fix for some versions of pdftops git-svn-id: svn://tug.org/texlive/trunk@9720 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/scripts/epspdf/epspdf.rb | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'Master') diff --git a/Master/texmf-dist/scripts/epspdf/epspdf.rb b/Master/texmf-dist/scripts/epspdf/epspdf.rb index fb391b6dde6..632ae6d1541 100755 --- a/Master/texmf-dist/scripts/epspdf/epspdf.rb +++ b/Master/texmf-dist/scripts/epspdf/epspdf.rb @@ -684,7 +684,7 @@ class PsPdf if $settings.pdftops_prog and $settings.use_pdftops cmd = "\"#{$settings.pdftops_prog}\"" + " #{PsPdf.ps_options( sep )}" + - " -eps -f #{page} -l #{page}" + + " -paper match -eps -f #{page} -l #{page}" + " \"#{@path}\" \"#{retVal.path}\"" else cmd = "\"#{$settings.gs_prog}\" -sDEVICE=epswrite" + @@ -696,6 +696,25 @@ class PsPdf write_log cmd # if $DEBUG fail EPSystemError, cmd unless \ system( cmd ) and test( ?s, retVal.path ) +# fix for incorrect DSC header produced by some versions of pdftops: +# if necessary, change line `% Produced by ...' into `%%Produced by ...' +# otherwise the DSC header would be terminated before the bbox comment +# this bug has been reported, but not yet acted upon. +# match first 500 chars against `% Produced by' + fhead = '' + File.open( retVal.path, $R ) do |fl| + fhead = fl.read( 500 ) + end # File + if fhead.match( /[\r\n]% Produced by/ ) + newpath = mktemp( 'eps' ) + write_log "pdftops header fix #{retVal.path} => #{newpath}" + File.open( newpath, $W ) do |fl2| + fl2.write( fhead.sub( /([\r\n])(% Produced by)/, '\1%%Produced by' ) ) + end + sliceFile( retVal.path, newpath, File.size( retVal.path ) - 500, 500, $A ) + retVal.path = newpath + end +# end fix for incorrect DSC header produced by some versions of pdftops retVal.atfront = 1 retVal.find_bb_simple return retVal -- cgit v1.2.3