Loading ...
Sorry, an error occurred while loading the content.

Re: Printing Chinese

Expand Messages
  • Tony Mechelynck
    ... Basically, there are two different printer backends against which Vim can be compiled: you can have Windows printing or postscript printing, but not both.
    Message 1 of 7 , Dec 23, 2008
    • 0 Attachment
      On 23/12/08 08:53, msingtse@... wrote:
      > This is an old problem but only today I am trying to deal with it --
      > without success. The same utf-8 file comprising Chinese can be
      > printed using Windows Notepad, but not my copy of very typical Vim
      > 7.2. I tried to set "printencoding", "printmbcharset" and
      > "printmbfont" but Vim told me these options are not supported (my Vim
      > was complied with "-postscript").
      >
      > I think there must be a way to print Chinese without calling for
      > Notepad? Plus, I cannot use notepad this time because I need syntax
      > highlighting in the hardcopy.

      Basically, there are two different printer backends against which Vim
      can be compiled: you can have Windows printing or postscript printing,
      but not both. I think it is possible to compile Windows Vim with
      +postscript but I don't recommend it; you would need ghostscript or
      something to use :hardcopy then.

      I suppose if you don't try to set all those options, but just use
      ":hardcopy", you don't get the expected results?

      Personally I'm on Linux (i.e., on the other side of the fence) but I
      haven't found out how to print Unicode from Vim. When I need "special"
      characters which aren't in the Latin1 range, I save the file to disk and
      print it using my browser.

      To print with syntax highlighting, first convert to HTML (see ":help
      convert-to-HTML") then open the resulting HTML file in your browser:
      e.g., to open "C:\Documents and Settings\msingtse\My
      Documents\foobar.html" you would point your browser to
      file:///c:/Documents%20and%20Settings/msingtse/My%20Documents/foobar.html --
      with file:/// at the start, forward slashes, and spaces and other
      "special" characters replaced by percent-escaping in hex. If the file
      name contains characters above U+007F, replace them by escaping each
      byte of their UTF-8 representation separately -- the g8 command can help
      you there. Or else, use the "File => Open" dialog if your browser has
      such a menu item.


      Best regards,
      Tony.
      --
      MORTICIAN: What?
      CUSTOMER: Nothing -- here's your nine pence.
      DEAD PERSON: I'm not dead!
      MORTICIAN: Here -- he says he's not dead!
      CUSTOMER: Yes, he is.
      DEAD PERSON: I'm not!
      The Quest for the Holy Grail (Monty
      Python)

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_multibyte" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Agathoklis D. Hatzimanikas
      ... Hi Tony, Would you mind to test the following function, and see if you get the expected result? You will need paps[1], which should be available from your
      Message 2 of 7 , Dec 23, 2008
      • 0 Attachment
        On Tue, Dec 23, at 10:18 Tony Mechelynck wrote:
        >
        > I suppose if you don't try to set all those options, but just use
        > ":hardcopy", you don't get the expected results?
        >
        > Personally I'm on Linux (i.e., on the other side of the fence) but I
        > haven't found out how to print Unicode from Vim. When I need "special"
        > characters which aren't in the Latin1 range, I save the file to disk and
        > print it using my browser.
        >

        Hi Tony,

        Would you mind to test the following function, and see if you get the
        expected result? You will need paps[1], which should be available from
        your favorite distribution, if not, it's just a simple (CMMI)* package
        that requires pango (possible you will need the dev package for pango).


        function! system#print(...) range
        let font = (exists("a:1") && !empty(a:1)) ? "Monospace ".a:1 : "Monospace 14"
        let printer = split(readfile('/etc/printcap')[-1], "|")[0]
        execute a:firstline.','.a:lastline.'write ++enc=utf-8 !paps --font='.font.
        \ '|ps2pdf -sPAPERSIZE=a4 -dOptimize=true -
        \ | lp -d '.printer.' -'
        endfunction


        1. http://paps.sourceforge.net/
        * configure, make, make install

        Regards,
        Ag.

        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_multibyte" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • Agathoklis D. Hatzimanikas
        On Tue, Dec 23, at 11:37 Agathoklis D. Hatzimanikas wrote: Sorry I am just testing it myself too, so I ve missed the quotes, ... --font= .font. Regards, Ag.
        Message 3 of 7 , Dec 23, 2008
        • 0 Attachment
          On Tue, Dec 23, at 11:37 Agathoklis D. Hatzimanikas wrote:

          Sorry I am just testing it myself too, so I've missed the quotes,

          > execute a:firstline.','.a:lastline.'write ++enc=utf-8 !paps --font='.font.
          --font="'.font.'"


          Regards,
          Ag.

          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_multibyte" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • Mansing
          Thank Tony for the explanation and confirmation of Unicode printing issue. I was using exacting the same technique (convert txt to html first) to get Chinese
          Message 4 of 7 , Dec 23, 2008
          • 0 Attachment
            Thank Tony for the explanation and confirmation of Unicode printing issue.  I was using exacting the same technique (convert txt to html first) to get Chinese print out.  But my browser doesn't echo formfeed (ctrl-L) correctly.  So my 'hardcopy' (actually a pdf file via cutepdf/ghostscript combo) came out with wrong page breaks.  I am now having two options: Correct Chinese but wrong page break (via html), or the other way round (with :hardcopy).  Oops, and the third one: Correct Chinese and page bread but no syntax highlighting (via Notepad).

            Seasons greetings!
            mt 081224

            Tony Mechelynck wrote:
            On 23/12/08 08:53, msingtse@... wrote:
              
            . . .
            
            I think there must be a way to print Chinese without calling for
            Notepad?  Plus, I cannot use notepad this time because I need syntax
            highlighting in the hardcopy.
                
            Basically, there are two different printer backends against which Vim 
            can be compiled: you can have Windows printing or postscript printing, 
            but not both. . .
              

            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_multibyte" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---

          • Tony Mechelynck
            ... Hm, what is the expected result? And no, AFAICT, SuSE doesn t distribute paps (at least, searching the 11.1 repositories for it with settings Name
            Message 5 of 7 , Dec 23, 2008
            • 0 Attachment
              On 23/12/08 22:37, Agathoklis D. Hatzimanikas wrote:
              > On Tue, Dec 23, at 10:18 Tony Mechelynck wrote:
              >> I suppose if you don't try to set all those options, but just use
              >> ":hardcopy", you don't get the expected results?
              >>
              >> Personally I'm on Linux (i.e., on the other side of the fence) but I
              >> haven't found out how to print Unicode from Vim. When I need "special"
              >> characters which aren't in the Latin1 range, I save the file to disk and
              >> print it using my browser.
              >>
              >
              > Hi Tony,
              >
              > Would you mind to test the following function, and see if you get the
              > expected result? You will need paps[1], which should be available from
              > your favorite distribution, if not, it's just a simple (CMMI)* package
              > that requires pango (possible you will need the dev package for pango).
              >
              >
              > function! system#print(...) range
              > let font = (exists("a:1")&& !empty(a:1)) ? "Monospace ".a:1 : "Monospace 14"
              > let printer = split(readfile('/etc/printcap')[-1], "|")[0]
              > execute a:firstline.','.a:lastline.'write ++enc=utf-8 !paps --font='.font.
              > \ '|ps2pdf -sPAPERSIZE=a4 -dOptimize=true -
              > \ | lp -d '.printer.' -'
              > endfunction
              >
              >
              > 1. http://paps.sourceforge.net/
              > * configure, make, make install
              >
              > Regards,
              > Ag.

              Hm, what is the expected result? And no, AFAICT, SuSE doesn't distribute
              paps (at least, searching the 11.1 repositories for it with settings
              "Name" "Summary" and "RPM Provides", "contains", and "not
              case-sensitive" yields no results). As for compiling from source, I'm
              doing it for Vim but that's an exception. Other packages I get
              pre-compiled from SuSE or, in the case of Firefox, Thunderbird,
              SeaMonkey and Sunbird, from Mozilla.

              The rare times that I need non-Latin glyphs (as in a paper recently, in
              French with one four-letter Hebrew word in it), printing with SeaMonkey
              is perfectly acceptable to me anyway, until or unless I can make Vim do
              it without help. It also takes care (as in this case) of RTL words in an
              LTR sentence, which Vim cannot show properly on the screen (and I don't
              know what would happen when printing).

              Best regards,
              Tony.
              --
              "For three days after death hair and fingernails continue to grow but
              phone calls taper off."
              -- Johnny Carson

              --~--~---------~--~----~------------~-------~--~----~
              You received this message from the "vim_multibyte" maillist.
              For more information, visit http://www.vim.org/maillist.php
              -~----------~----~----~----~------~----~------~--~---
            • Tony Mechelynck
              ... Ah, I normally don t use form feeds and let the browser figure where to break the pages. One possible way would be to break the file into several documents
              Message 6 of 7 , Dec 23, 2008
              • 0 Attachment
                On 24/12/08 01:20, Mansing wrote:
                > Thank Tony for the explanation and confirmation of Unicode printing
                > issue. I was using exacting the same technique (convert txt to html
                > first) to get Chinese print out. But my browser doesn't echo formfeed
                > (ctrl-L) correctly. So my 'hardcopy' (actually a pdf file via
                > cutepdf/ghostscript combo) came out with wrong page breaks. I am now
                > having two options: Correct Chinese but wrong page break (via html), or
                > the other way round (with :hardcopy). Oops, and the third one: Correct
                > Chinese and page bread but no syntax highlighting (via Notepad).
                >
                > Seasons greetings!
                > mt 081224

                Ah, I normally don't use form feeds and let the browser figure where to
                break the pages. One possible way would be to break the file into
                several documents where the pages break. (Since there is no "intrinsic"
                page break within an HTML document, the texts on my website are divided
                into one distinct HTML page per chapter.)

                Yes, and season's greetings for you too, merry Christmas, happy new
                year, or whatever you feast around the December solstice.


                Best regards,
                Tony.
                --
                Syntactic sugar causes cancer of the semicolon.
                -- Epigrams in Programming, ACM SIGPLAN Sept. 1982

                --~--~---------~--~----~------------~-------~--~----~
                You received this message from the "vim_multibyte" maillist.
                For more information, visit http://www.vim.org/maillist.php
                -~----------~----~----~----~------~----~------~--~---
              Your message has been successfully submitted and would be delivered to recipients shortly.