Forum > Operating Systems

Printing - new papersize creation

(1/2) > >>

drschwarcz:
Hi!

I would need to create size A5 if does not exist in the system, which is half of size A4.

I have no any solution for now.

If someone has experience in printing, then I would really appreciate it.

Thanks in advance.

Op. system: Windows 8.1, or Windows 7

howardpc:
All modern printers support A5 as a paper size (even American ones which default to inches rather than metric and have Letter as default size).
Drop a TPageSetupDialog (rightmost icon on Dialogs tab) on your form, and invoke it say in a button OnClick handler via
--- Code: ---  PageSetupDialog1.Execute;

--- End code ---
at runtime.
In the "Paper" groupbox of the dialog there is a "Size" dropdown which will reveal A5 along with various other settings for your default printer. See image below.

rvk:

--- Quote from: howardpc on September 05, 2014, 11:45:57 pm ---Drop a TPageSetupDialog (rightmost icon on Dialogs tab) on your form, and invoke it say in a button OnClick handler via...
--- End quote ---
Or if you don't want the user of your program to do this manually you can do it in code:

--- Code: ---Printer.PaperSize.PaperName:='A5';

--- End code ---

drschwarcz:
It's clear for me. I do not want to use Dialog, I would like to handle from my application.

...and unfortunately, size A5 is not known by each printer, for instance my printer does not have this size in defaults.

RVK: Yes, I can set the name if it exists.

rvk:

--- Quote from: drschwarcz on September 06, 2014, 12:32:03 am ---...and unfortunately, size A5 is not known by each printer, for instance my printer does not have this size in defaults.

--- End quote ---
There is a topic here where there is some code to add a custom papersize (if A5 does not exists) but it's for Delphi (and no answer for FPC).
It should get you started. (I can't test this myself at the moment).

I take it you get an exception if you try to set A5 and A5 is not defined. You can catch that exception and try to add the custom size and try to set it again. If it fails again your routine should end and not print (because the custom size failed too).

B.T.W. Did you try adding A5 manually as custom papersize in the printer configuration? And did that work when you choose that papername from Lazarus? (Just to make sure that A5 is supported on the printer itself because there might be a reason it's not in the default papersizes.)

Navigation

[0] Message Index

[#] Next page

Go to full version