Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

printing to Postscript from vim

I have problem with printing to postscript from Vim.

I'm, using utf-8 encoding with czech characters like 'ščřž' but in the output I get upside question mark instead of the correct characters.

vim --version

VIM - Vi IMproved 7.2

+iconv +multi_byte +postscript

printer settings:

set printoptions=paper:A4,duplex:off,collate:n,syntax:n

printer font: courier

like image 304
Milan Leszkow Avatar asked Mar 31 '10 08:03

Milan Leszkow


2 Answers

Rkulla, that's wrong. As regards your message, I've understood that if we don't set 'printencoding' vim will convert our message (utf-8) to 'latin1' and because of that we have problems. I think that's not true.

I printed file (with Cyrillic symbols) in vim with printencoding=utf-8 by :hardcopy I also get reverse question mark instead of the correct symbols. My settings: 1) printfont = utf-8 2) encoding = utf-8 3) fileencoding = utf-8. I think problem in PostScript. If you try to print something (for example with Cyrillic symbols) in console/terminal (not GUI) by lp/lpr you will get incorrect symbols (in place where Cyrillic). That's conversion problems from non-ASCII text to PostScript in terminal. Vim use printexpr and has default: printexpr=system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error. I don't know how to fix that. I read that's general Unix/Linux problems. But you should try rewrite printexpr for using a2ps, enscript or similar.

like image 53
Mephi_stofel Avatar answered Oct 04 '22 18:10

Mephi_stofel


Send the buffer to the browser by converting to HTML, then print from there:

:TOhtml | w | !open -a Safari %

For example I have this in vim: enter image description here

If I type

:ha

I get this: enter image description here

But when I send it to the browser I get this (with color scheme!):

enter image description here

I have this in my .vimrc, which deletes the new html buffer and stored file:

nnoremap <F2> <ESC> :TOhtml <bar> w <bar> !open -a Safari % <CR> <bar> ZQ <CR> <bar> execute '!rm %:p.html' <CR>
like image 24
Riaz Rizvi Avatar answered Oct 04 '22 18:10

Riaz Rizvi