set papersize Printing with Ghostscript.NET - printing

I'm printing some pdf's using Ghostscript.NET
this is my config.
List<string> switches = new List<string>
{
"-empty",
"-dPrinted",
"-dFirstPage=1",
"-dLastPage=1",
"-dPrinted",
"-dBATCH",
"-dNOPAUSE",
"-dNOSAFER",
"-dNumCopies=1",
"-sDEVICE=mswinpr2",
#"-sFONTPATH=" + System.Environment.GetFolderPath(System.Environment.SpecialFolder.Fonts),
"-sOutputFile=%printer%" + printQueue.FullName,
"-f",
inputFile
};
It works pretty well but my paper size is a custom paper 6.5in x 8.5in, my problem is when I print silent to my ricoh printer, try to print in letter.
How can i do to set my paper size in my switches or force the printer to render it properly.
If i print manually must select the paper and bin manually and all print's perfect.

The mswinpr2 device uses Windows to do the printing, in particular the media size is set by the printer canvas.
So the answer is to set the default media selection of your printer to the required media size before you start printing.

You can set the paper size with "-sPAPERSIZE=a4" you can see Paper sizes known to Ghostscript.
or you can set it by height and width
"-dDEVICEWIDTHPOINTS=w"
"-dDEVICEHEIGHTPOINTS=h"
Where w be the desired paper width and h be the desired paper height in points (units of 1/72 of an inch).

Related

print full page in windows

fist off, if there is an exchange place more suitable for the question, please address me.
I'm designing some labels in gimp.
I created a A4 300dpi document and created the artwork, arranged them to use all the page. To measure the labels I create a rectangle with the "rectangle selection tool" and there one can inspect the size in cm:
I printed straight from gimp and to my surprise, the printed labels where smaller than designed. I assumed somehow someone along the line added margins to my already A4 document..
I tried saving to PDF and then printing the PDF, very similar results.
I'd say the difference is around 5%
What would be the appropriated method for printing exactly at the size I created the document ignoring any margins ??
I'm using Windows 10, HP ENVY 5010 and Gimp 2.10

How to centre media on Zebra QLN220 printers

The media Im printing on is 40mm and the Zebra QLN220 is set to 48mm which means some of the text is cut off how do i adjust this?
Thanks
If you are printing using ZPL commands the code to add would be:
^xa^PW320^xz
The printhead is 8 dots per millimeter. The PW sets the print width in dots. 8*40 = 320
If you are using a driver, CPCL, or line mode you need to look up how to change the print width for those methods.

Printer paper size in Firemonkey

I am trying to allow the user to select an appropriate paper size for their printer within my own print settings dialog. Does anyone know a workable solution - preferably cross platform but otherwise OSX.
If I use a TPageSetupDialog then when executed it produces an error in the PASever window of Invalidpmobject although the dialog shows but doesn't seem to affect the current printers paper size. There doesn't seem to be any proerties to see what the user selected either.
I need to set the paper size without actually printing as the user needs to be able to adjust things with the new paper size first.
I finally figured out the problem so here is the solution for anyone else with the problem:
Use TPageSetupDialog but you must set valid pagewidth and pageheight values for the current printer before calling it - otherwise you get an error reported in PAServer window and the printer selection box will be set to "any printer" instead of the current printer name.
Unfortunately you cannot derive the paper size directly from the printer pagewidth and resolution because it reports printable area not paper size. So I set a default of A4 whenever the user chooses another printer. I guess you could set the nearest standard paper size to the calculated value from printer.pagewidth/printer.activeprinter.activedpi.x if you want to take care of printers that do not support A4.
The other point to note is that the default page sizes in the TPageSetupDialog component are wrong. Set the units to mm and use width 210000 and height 297000 (note 10 times bigger than the default values) for A4 size that most printers should support.

Keeping custom figure font size when using print()

I am running a self written script which plots and saves a large number (over 100) of graphs and I have set the axis text to 18pt using
set(0,'defaultAxesFontSize',18);
The figures are saved as .fig using the savefig() command and the font size is correct. But when I save them as .jpg (to be included in a LaTeX report) using print(name, '-djpeg') the font size is the regular default size (guessing about 10pt). If I open one of the .fig files and do File > Save as, the resulting .jpg file has the desired font size.
How can I solve this in the command line?
EDIT:
I have tried using saveas(gcf, name, 'jpg') as well but the result is the same.
EDIT 2:
Here is a minimal example
set(0,'defaultAxesFontSize',18);
x = linspace(0, 2*pi);
plot(x, sin(x))
title('Sine')
xlabel('x')
ylabel('y')
legend('y = sin(x)')
fig = strcat('Sine')
savefig(fig)
print(fig, '-djpeg')
Tanks
Kajsa
I needed to set the paper position mode to auto to make the print the same size as the figure on screen.
This does that for all figures
set(0,'defaultAxesFontSize',18);
set(0,'DefaultFigurePaperPositionMode','auto')
x = linspace(0, 2*pi);
figure(1)
plot(x, sin(x))
title('Sine')
xlabel('x')
ylabel('y')
legend('y = sin(x)')
fig = strcat('Sine')
savefig(fig)
print(fig, '-djpeg')
Works great.

Creating ZPL template for Zebra Printer ZP450ctp

This is the first time I've worked with ZPL code. I'm printing on a 200dpi ZP450ctp printer onto labels that are 2inx1in. The .zpl below is way to big but I thought I had it set right. Is anyone familiar with the .zpl language?
^XA~TA000~JSN^LT0^MNW^MTT^PON^PMN^LH0,0^JMA^PR2,2~SD15^JUS^LRN^CI0^XZ
^XA
^MMT
^PW1200
^LL0600
^LS0
^FT131,350^A0N,333,331^FH\^FDA12345^FS
^BY4,3,70^FT717,533^BCN,,Y,N
^FD>:A>51234>65^FS
^FT138,539^A0N,58,57^FH\^FDThis is a description^FS
^PQ1,0,1,Y^XZ
To start with your print width would then be 400 and label length would be 100. If you are using web based media you do not need to have these in your ZPL (remove the ^PW and ^LL).
Then you need to set the values right. Character height and with in your ^A0 command would make each character 1.5 inches.
^XA
^MMT
^FO10,10^A0N,80,80^FH\^FDA12345^FS
^BY4,3,50^FO10,130^BCN,,Y,N
^FD>:A>51234>65^FS
^FO10,95^A0N,30,30^FH\^FDThis is a description^FS
^XZ
Try the above it should get you closer to what you need. You want to adjust the ^FO commands to adjust the location of the objects, and adjust the pair of numbers after the ^AON, to adjust the font size.

Resources