Home > Blockchain >  How to generate asci file to virtual pdf printer in vb.net
How to generate asci file to virtual pdf printer in vb.net

Time:07-29

How to generate asci file to virtual pdf printer in vb.net. I tried with the virtual printer "microsoft print to pdf" it didn't work. I also found the link below but I don't understand whether it can used with the language of the vb.net program. Please the best solution.

enter image description here

Using NotePad has some differences but you require setting printer defaults so I have a printer called A4Lpdf which uses the driver and a fixed output and Write can be in colour whereas Notepad is any font as long as its Black. notepad /pt "..\desktop\document.asc" "A4LPDF"

enter image description here

Later Edit

On supplying a minimal sample of your ascii.PRN file it is clearer that your input is like Epson Control codes and simple conversion to PDF is usually a disaster.

So here is a snip from an adobe print to pdf, where the two most obvious fails are underline and italic but everything is wrong as its not an image of the ink head output.

enter image description here

This is condensed mode
T h i s i s d o u b l e - w i d t h
T h i s is elite m o d e
T h i s i s e m p h a s i z e d m o d e
T h i s i s i t a l i c t y p e
T h i s i s d o u b l e - s t r i k e m o d e
This is under line mode
T h i s s u p e r s c r i p t
T h i s i s s u b s c r i p t 

Thus we see the codes are not applied to the PDF format the same as to a matrix printer.

Potential Solutions

Either find an Epson PRN to PDF application, there are a few, (but never found a perfect one, especially for graphics art output). The codes are here enter image description here

{\rtf1\ansi\deff0\nouicompat{\fonttbl{\f0\fnil\fcharset0 Perfect DOS VGA 437 Win;}{\f1\fnil\fcharset0 System;}}
{\*\generator Riched20 10.0.22000}\viewkind4\uc1 
\pard\b\f0\fs14\lang2057                                                                        24 May 22\par
\par
                                                                    KANA                     \par
                                                                                             \par
                                                                                             \par
                                                                                             \par
  PG: 1                                        \fs28 SI12202041\f1\fs21                         \par
\f0\fs14\par
\par
\par
\par
     1      25 Pcs   USB CABLE                                    260.000,00     6.500.000,00\par
\par
\par
\par
\par
\par
\par
\par
\par
\par
\par
\par
\par
\par
\par
\par
\par
                                                                                  6.500.000,00\page\f1\fs21\par
}

Its all down to finding the correct font metrics, since line printers were non-proportional fonts, but the line spaces are the fly in the ointment, they need to be pitch perfect. Thus you will need to write or find a font that EXACTLY matches the source printer styles of 10.5 points by 12cpi and 21 pts x 6 cpi (nominal) then tune them. Above is using a rough DOS VGA screen font but then I needed to adjust scales as I apply it as 7 and 14 to emulate the printers 10.5 and 21 by 70%.

It is a sloppy first shot that could be cleaned up, the key points are that RTF units are doubled expected eg 14 units = 7 pts and the language is a mix between others so \par = paragraph or line feed and the font I used is not the best but was quick to find and double click to install.

You need to read the byte codes then ignore or convert into rtf so ignoring the start printer code, replace with the string I give above using your choice of installed font name for replacing the font control codes, then convert line feeds to \par etc.

This could all be scripted in a console batch file or any language, if you store a common header (or preset pre-pends) then just change the body line by line with \par and finally add } as the trailer.

  • Related