challenge Hello, world! PDF版

Hello, world!シリーズの続編です。 「Hello, world!」となるべく大きく書かれた1ページのPDFを出力してください。

Posted feedbacks - PostScript

shだったりps{2,to}pdfだったり使ってるのでちとアレですが、A4いっぱいのこんにちはなのでご容赦ください。。。

gs付属のps2pdfと、Mac OS Xのpstopdfで動作確認しました。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/sh
large_hello() {
  cat <<'EOHELLO'
%!
/inch {72 mul} bind def
/sheetheight 11.64 inch def
/sheetwidth   8.27 inch def

/hello     (Hello, world!) def
/hellolen  hello length    def
/fontsz    10 def
/Helvetica fontsz selectfont
/capheightratio 0.8 def

0 0 moveto
sheetwidth  hello stringwidth pop div
sheetheight fontsz capheightratio mul div
scale
hello show

showpage
EOHELLO
}
large_hello | {
  outfile=large-hello.pdf
  if type -p pstopdf >/dev/null; then
    pstopdf /dev/stdin -o $outfile
  elif type -p ps2pdf >/dev/null; then
    ps2pdf /dev/stdin $outfile
  else
    echo 'converter not found...'
    exit 1
  fi
}

Index

Feed

Other

Link

Pathtraq

loading...