In documenting as many texexec switches as I can find, I ran across this buglet: $ texexec --pages=1 --pdfcopy --scale=2 xyz.pdf ... ! Number too big. \@@efscale ->2222222222 22222222222222222222222222222222222222222222222222222... The culprit is line 431 of texexec.rb (v6.2.0): scale = (scale * 1000).to_i if scale.to_i < 10 where the (scale * 1000) should be (scale.to_i * 1000), otherwise ruby is doing like Python: with scale as a string, the * 1000 replicates it 1000 times! While looking at the code, I wondered about the next few lines: f << "\\definepapersize\n" f << " [copy]\n" f << " [width=\\figurewidth,\n" f << " height=\\figureheight]\n" Shouldn't the width be \\figurewidth * (scale/1000), and the same idea for height? Otherwise scale=2000 will expand the figures beyond the page size. -Sanjoy `Our society is run by insane people for insane objectives.' (John Lennon)
Sanjoy Mahajan wrote:
In documenting as many texexec switches as I can find, I ran across this buglet:
$ texexec --pages=1 --pdfcopy --scale=2 xyz.pdf .... ! Number too big. \@@efscale ->2222222222 22222222222222222222222222222222222222222222222222222...
The culprit is line 431 of texexec.rb (v6.2.0):
scale = (scale * 1000).to_i if scale.to_i < 10
where the (scale * 1000) should be (scale.to_i * 1000), otherwise ruby is doing like Python: with scale as a string, the * 1000 replicates it 1000 times okay: begin scale = (scale.to_i * 1000).to_i if scale.to_i < 10 rescue scale = 1000 end
!
While looking at the code, I wondered about the next few lines:
f << "\\definepapersize\n" f << " [copy]\n" f << " [width=\\figurewidth,\n" f << " height=\\figureheight]\n"
Shouldn't the width be \\figurewidth * (scale/1000), and the same idea for height? Otherwise scale=2000 will expand the figures beyond the page size.
\getfiguredimensions a few lines earlier will calculate the scaled width which is then used Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Hans,
\getfiguredimensions a few lines earlier will calculate the scaled width which is then used
I ran a test: ================================================================== $ cat xyz.mp beginfig(1) draw unitsquare scaled 2in; endfig; end $ mpost xyz ... $ mptopdf xyz.1 ... $ texexec --pdfcopy --scale=3000 --result=one xyz-1.pdf ... $ pdfinfo xyz-1.pdf /* original dimensions are 2in * 2in, plus 0.5bp margin */ Creator: TeX Producer: pdfeTeX-1.30.6 CreationDate: Wed Nov 29 07:49:43 2006 Page size: 144.5 x 144.5 pts $ pdfinfo one.pdf /* it's still 2in*2in despite the scale=3000 */ Creator: ConTeXt - 2006.11.22 11:02 Producer: pdfeTeX-1.30.6 CreationDate: Wed Nov 29 07:50:14 2006 Page size: 144.5 x 144.5 pts /* Also, the square is invisible, because it extends beyond the page. Using scale=600 also leaves the page size unchanged, but the square is now visible. */ ============================================================== The problem is that \getfiguredimensions doesn't yet know the scale. Here's the lines from texexec.rb that write to the temporary source file. The first use of the ruby 'scale' variable is in \copypages, but the \getfiguredimensions has already happened. f << "\\starttext\n" files.each do |filename| result = @commandline.checkedoption('result','texexec') if (filename !~ /^texexec/io) && (filename !~ /^#{result}/) then report("copying file: #{filename}") f << "\\getfiguredimensions\n" f << " [#{filename}]\n" f << " [page=1" f << ",\n size=trimbox" if trim f << "]\n" f << "\\definepapersize\n" f << " [copy]\n" f << " [width=\\figurewidth,\n" f << " height=\\figureheight]\n" f << "\\setuppapersize\n" f << " [copy][copy]\n" f << "\\setuplayout\n" f << " [page]\n" f << "\\setupexternalfigures\n" f << " [directory=]\n" f << "\\copypages\n" f << " [#{filename}]\n" f << " [scale=#{scale},\n" f << " marking=on,\n" if @commandline.option('markings') f << " size=trimbox,\n" if trim f << " offset=#{paperoffset}]\n" end end f << "\\stoptext\n" f.close -Sanjoy `Never underestimate the evil of which men of power are capable.' --Bertrand Russell, _War Crimes in Vietnam_, chapter 1.
participants (2)
-
Hans Hagen
-
Sanjoy Mahajan