Question: I have printer TSC TE 210. I created virtual printer on a RedMon port and installed TSC driver on it. I am able to generate printfile.prn file using redmon (redirecting output to python, that will edit the data and create .prn file), that has TSPL commands it it, e.g.: SIZE 97.6 mm, 50 mm GAP 3 mm, 0 mm DIRECTION 0,0 REFERENCE 0,0 OFFSET 0 mm SET PEEL OFF SET CUTTER OFF SET PARTIAL_CUTTER OFF SET TEAR ON CLS BITMAP 361,170,50,32,1,˙đ˙˙˙˙˙˙˙đ˙˙ü ˙˙˙˙˙˙ TEXT 586,152,"2",180,1,1,1,"1234AA" PRINT 1,1  Everything is good. I can edit the TSPL commands, add something etc, and then send it to real printer using copy printfile.prn /B "TSC TE210" (on windows) It works, because the generated .prn file has TSPL commands, and I am also sending TSPL commands to the printer for real printing. The problem is, I would like to create also PDF. I am able to do it! Also use redmon, but instead of forwarding it to python script, I used PostScript, that can indeed generate the pdf file. This virtual printer used PostScript driver. However, how to generate both files (.prn having TSPL), and .pdf file in the same time? I want to be super user friendly, print it once, and generate TSPL and pdf in the same time. What is limiting me? The thing I mentioned - using first approach, the virtual printer has to have TSC driver installed, that is why it generated TSPL commands. Second virtual printer has PS driver installed, that is why it generated PostScript file, that can be changed into PDF. But I can not have both driver installed on the same RedMon virtual printer. Any idea how to do it? I know I can create a script, that just take TSPL commands from the first approach, and somehow create PDF step by step. But that is really much work. I can probably create just PDF using PostScript, and try to work only with PDF, when everything is edited, try to print PDF on thermal printer, but thermal printers really dont like PDF, since the size of labels is not A4. And I would love to keep the native TSPL format for easier edits. Any solution, where I can use same data to create TSPL and PDF in one run? TLTR: I can create TSPL or PDF files using RedMon, but can not do both in the same run. Any trick that could do it? EDIT 2.4.2025: I was able to create python script that will visualize the TSPL bitmap using plt library. Thanks to the @K J answer, I understood that I have to scale the width by 8. However, only one of the 4 bitmaps looks good. Also I dont know how to make them visible together: import numpy as np import matplotlib.pyplot as plt from PIL import Image import re bitmap_parameters = [] bitmap_lines = [] with open("TSPL.prn", "rb") as f: for line in f.readlines(): if line.startswith(b"BITMAP"): match = re.match(br'BITMAP (\d{1,5}),(\d{1,5}),(\d{1,5}),(\d{1,5}),(\d{1,5}),', line) if match: bitmap_parameters.append(match.groups()) bitmap_lines.append( re.sub(br'BITMAP \d{1,5},\d{1,5},\d{1,5},\d{1,5},\d{1,5},', b'', line) ) fig, axes = plt.subplots(1, len(bitmap_lines)) if len(bitmap_lines) == 1: axes = [axes] for i in range(len(bitmap_lines)): bitmap_bytes = bitmap_lines[0] width, height = int(bitmap_parameters[i][2]), int(bitmap_parameters[i][3]) width *= 8 bitmap = np.frombuffer(bitmap_bytes, dtype=np.uint8) bitmap = np.unpackbits(bitmap)[:width * height] try: bitmap = bitmap.reshape((height, width)) except: print("error") continue axes[i].imshow(bitmap, cmap="gray", interpolation="nearest") axes[i].axis("off") plt.show()  Result: 

Answer: This is a good question and from long discussions we get to the hub of an XY problem. Only one print type (text, vector or raster) at a time, can be one applications printout. In this case the desire is Textual TSPL (203 DPI: 1 mm = 8 dots) and vector PDF 1000 sub units = 1/72" (printer point). PDF is not a good source format as many source constructs that are needed are discarded. Thus the simpler conversion will be TSPL to PDFL. The way to convert one format to another is first replace similar functions in large blocks. The header in a TSPL file is something like:  So the first challenge is positional units are counted as 8 per mm and the direction in this case is upside down, plus compared to most conventions inverted. This poses needing programming to convert such placements and bitmaps. I am working on what text syntax is needed for the programming as it does not matter if C++#.js or Python.py in PDF term it is simply "ANSI" binary text as byte streams. Without correction for scale and colours the result of bitmaps would seem oddly oversized, rotated and negative, however that is easily fixable in terms of simple text values.  So at this stage we can replace the text header from this: SIZE 97.6 mm, 50 mm GAP 3 mm, 0 mm DIRECTION 0,0 REFERENCE 0,0 OFFSET 0 mm SET PEEL OFF SET CUTTER OFF SET PARTIAL_CUTTER OFF SET TEAR ON CLS BITMAP 25,50,92,112,1, ÿÿÿÿ  To something like this where we use the common up and downscale by 8 dots. Basically we multiply the 92 x 8 = /Width 736 ! First we set the page (object 3) to 97.6 x 8 = 781 width and 50 x 8 high = 400 dots, and reserve objects 5,6 & 7 for the 3 bitmaps. %PDF-1.6 %ÅÑ§¡ 1 0 obj <</Type/Catalog/Pages 2 0 R>> endobj 2 0 obj <</Type/Pages/Count 1/Kids[3 0 R]>> endobj 3 0 obj <</Type/Page/Parent 2 0 R/MediaBox[0 0 781 400]/UserUnit 0.3545/Contents 4 0 R /Resources<</XObject<</Im1 5 0 R/Im2 6 0 R/Im3 7 0 R>>>>/Rotate 180>> endobj 4 0 obj <</Length 103>> stream q 736 0 0 112 25 50 cm /Im1 Do Q q 400 0 0 32 361 170 cm /Im2 Do Q q 736 0 0 168 25 210 cm /Im3 Do Q endstream endobj 5 0 obj <</Type/XObject/Subtype/Image/BitsPerComponent 1/ColorSpace[/Indexed/DeviceRGB 1<000000FFFFFF>]/Width 736/Height 112/Length 10304>> stream ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿ... 10 KB image endstream endobj 6 0 obj similar but different width to 5 (1600 bytes) stream ÿÿÿÿÿÿÿÿÿÿ... 1.56 KB image endstream endobj 7 0 obj similar but different width to 5 (15456 bytes) stream ÿÿÿÿÿÿÿÿÿÿ... 15 KB image endstream endobj  Changing colours is fairly simple as we just say black is white: /ColorSpace[/Indexed/DeviceRGB 1<000000FFFFFF>]  We can also set a page scale to roughly 203.10 units per inch and rotate by 180. /Rotate 180/Type/Page/UserUnit 0.3545 (this addition requires we update header to 1.6)   So far so good the images are well placed  Just to round up on the final result: When the bitmaps have been placed, each object will have a decimal based starting address which we use for the trailer index. The easiest way if using a command line to write the PDF is measure file byte length "position" after each step and before the next and keep an array of those end/start points! The numbers need to account for the variable entries so if there were 3 images as object 5, 6 & 7 then the last object will have been 7 0 obj but in this format the Xref table always starts with a blank 65536 f \n entry. The line end is either \r\n or a spaced  \n to ensure index lines are always 20 characters ! So in this case the xref starts with 0 8 and ends with a similar <</Size 8/Root 1 0 R>> also you need to change the startxref decimal address value to the start position of xref ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ endstream endobj xref 0 8 0000000000 65536 f 0000000015 00000 n 0000000060 00000 n 0000000111 00000 n 0000000277 00000 n 0000000429 00000 n 0000010898 00000 n 0000012661 00000 n trailer <</Size 8/Root 1 0 R>> startxref 28283 %%EOF