From 41a6f0f2902b79df03ced7409cb563a744fa36b1 Mon Sep 17 00:00:00 2001 From: Takuji Tanaka Date: Fri, 10 May 2013 16:01:27 +0000 Subject: convbkmk 0.08 git-svn-id: svn://tug.org/texlive/trunk@30370 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/scripts/uptex/convbkmk.rb | 115 ++++++++++++++++++++++------ 1 file changed, 91 insertions(+), 24 deletions(-) (limited to 'Master/texmf-dist/scripts') diff --git a/Master/texmf-dist/scripts/uptex/convbkmk.rb b/Master/texmf-dist/scripts/uptex/convbkmk.rb index f78583d546b..2c566fe6301 100755 --- a/Master/texmf-dist/scripts/uptex/convbkmk.rb +++ b/Master/texmf-dist/scripts/uptex/convbkmk.rb @@ -3,13 +3,67 @@ =begin -convbkmk Ver.0.07 += convbkmk Ver.0.08 -= License + 2013.05.11 + Takuji Tanaka + KXD02663 (at) nifty.ne.jp +(()) + + +== Abstract + +((*convbkmk*)) is a tiny utility for making correct bookmarks in pdf files +typesetted by platex/uplatex with the hyperref package. +platex/uplatex + hyperref outputs data of bookmarks +in their internal encodings (EUC-JP, Shift_JIS or UTF-8). +On the other hand, the PostScript/PDF format requests that +the data is written in a certain syntax with UTF-16 or PDFDocEncoding. +Thus, data conversion is required to create correct bookmarks. +((*convbkmk*)) provides a function of +the encoding conversion and formatting the bookmark data. + +== Requirement + +ruby 1.8.3 or later + +== Examples + +platex (internal kanji code: euc) + hyperref + dvips : + $ platex doc00.tex + $ platex doc00.tex + $ dvips doc00.dvi + $ convbkmk.rb -e doc00.ps + $ ps2pdf doc00-convbkmk.ps + +platex (internal kanji code: sjis) + hyperref + dvipdfmx : + $ platex doc01.tex + $ platex doc01.tex + $ convbkmk.rb -s -o doc01.out + $ platex doc01.tex + $ dvipdfmx doc01.dvi + +uplatex + hyperref + dvips : + $ uplatex doc02.tex + $ uplatex doc02.tex + $ dvips doc02.dvi + $ convbkmk.rb doc02.ps + $ ps2pdf doc02-convbkmk.ps + +uplatex + hyperref + dvipdfmx : + $ uplatex doc03.tex + $ uplatex doc03.tex + $ convbkmk.rb -o doc03.out + $ uplatex doc03.tex + $ dvipdfmx doc03.dvi + +More examples are included in the uptex source archive. + +== License convbkmk -Copyright (c) 2009-2012 Takuji Tanaka +Copyright (c) 2009-2013 Takuji Tanaka Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -29,29 +83,35 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -= History - -2009.08.02 0.00 Initial version. -2011.05.02 0.01 Bug fix: BOM was not correct. -2012.05.08 0.02 Bug fix: for a case of dvips with -z option and Ruby1.8. - Add conversion of /Creator and /Producer . -2012.05.12 0.03 Suppress halfwidth -> fullwidth katakana conversion - and MIME decoding in Ruby1.8. -2012.06.01 0.04 Support escape sequences: \n, \r, \t, \b, \f, \\, - \ddd (octal, PDFDocEncoding) and \0xUUUU (Unicode UTF-16BE). - Support sequences of end of line: - '\' or other followed by "\n", "\r\n" or "\r" . - Set file IO to binary mode. -2012.07.26 0.05 Add -o option to support conversion of OUT files - generated by dvipdfmx. -2012.08.07 0.06 Bug fix: Ver.0.05 does not work with Ruby1.9 -2012.09.17 0.07 Bug fix: An infinite loop occurs in Ver.0.05, 0.06 - with -g option in some cases. - Add reference for PDFDocEncoding. +== History + +: 2009.08.02 0.00 + * Initial version. +: 2011.05.02 0.01 + * Bug fix: BOM was not correct. +: 2012.05.08 0.02 + * Bug fix: for a case of dvips with -z option and Ruby1.8. + * Add conversion of /Creator and /Producer . +: 2012.05.12 0.03 + * Suppress halfwidth -> fullwidth katakana conversion and MIME decoding in Ruby1.8. +: 2012.06.01 0.04 + * Support escape sequences: \n, \r, \t, \b, \f, \\, \ddd (octal, PDFDocEncoding) and \0xUUUU (Unicode UTF-16BE). + * Support sequences of end of line: '\' or other followed by "\n", "\r\n" or "\r" . + * Set file IO to binary mode. +: 2012.07.26 0.05 + * Add -o option to support conversion of OUT files generated by dvipdfmx. +: 2012.08.07 0.06 + * Bug fix: Ver.0.05 does not work with Ruby1.9. +: 2012.09.17 0.07 + * Bug fix: An infinite loop occurs in Ver.0.05, 0.06 with -g option in some cases. + * Add reference for PDFDocEncoding. +: 2013.05.11 0.08 + * Add -O option: overwrite output files onto input files instead of creating foo-convbkmk.ps . + * Make comments rd/rdtool friendly. =end -Version = "0.07" +Version = "0.08" require "optparse" @@ -196,6 +256,11 @@ OptionParser.new do |opt| Opts[:mode] = 'out' require "fileutils" } + opt.on('-O', '--overwrite', + 'overwrite output files') {|v| + Opts[:mode] = 'overwrite' + require "fileutils" + } opt.banner += " file0.ps [file1.ps ...]\n" \ + opt.banner.sub('Usage:',' ') + " < in_file.ps > out_file.ps\n" \ + opt.banner.sub('Usage:',' ') + ' -o file0.out [file1.out ...]' @@ -429,7 +494,9 @@ else file_treatment(ifile, ofile, enc) } } - FileUtils.mv(fout, fin) if Opts[:mode] == 'out' + if (Opts[:mode] == 'out' || Opts[:mode] == 'overwrite') + FileUtils.mv(fout, fin) + end } end -- cgit v1.2.3