Thank you very much Neil Kenig, the PyMuPDF library will completely meet my
needs and seems super easy to use.
In 15 minutes of tests, I managed to process one of the fields and the
management of the step between the boxes (one letter per box).

Many thanks also to you Tim Roberts for the initial answer as well as
co-opting Neil's answer.

Going through PDF rather than attacking the Windows printing API will
probably save me a lot of time as well as a few gray hairs (more).

Thank you again for your participation and your answers to my question,
it's so nice.

Kind regards,

Antoine

Le mar. 8 nov. 2022 à 07:10, <python-win32-requ...@python.org> a écrit :

> Send python-win32 mailing list submissions to
>         python-win32@python.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         https://mail.python.org/mailman/listinfo/python-win32
> or, via email, send a message with subject or body 'help' to
>         python-win32-requ...@python.org
>
> You can reach the person managing the list at
>         python-win32-ow...@python.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of python-win32 digest..."
>
>
> Today's Topics:
>
>    1. Re: Windows printing with the use of Device Context (Neil Kenig)
>    2. Re: Windows printing with the use of Device Context (Tim Roberts)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 8 Nov 2022 01:25:57 +0000
> From: Neil Kenig <neil.ke...@modahealth.com>
> To: "python-win32@python.org" <python-win32@python.org>
> Subject: Re: [python-win32] Windows printing with the use of Device
>         Context
> Message-ID:
>         <
> dm8pr08mb7494ea822d5915bbce8f9785e0...@dm8pr08mb7494.namprd08.prod.outlook.com
> >
>
> Content-Type: text/plain; charset="utf-8"
>
> You may want to try https://pypi.org/project/PyMuPDF/.   It's relatively
> easy to create a blank PDF and then insert text of a given font and size at
> precise locations on the page.  PDF files use points (1/72nd of an inch)
> for both font sizes and location on a page and will print properly
> regardless of the printer's resolution (assuming the stock size is the
> same, e.g. US Letter or A4).  You can then print the PDF and if the
> preprinted stock is loaded into the printer, you should get the desired
> result.
>
> Neil Kenig
> Print Software Engineer (Document Services)
>
> -----Original Message-----
> From: python-win32 <python-win32-bounces+neil.kenig=
> modahealth....@python.org> On Behalf Of Tim Roberts
> Sent: Monday, November 7, 2022 3:50 PM
> To: python-win32@python.org
> Subject: Re: [python-win32] Windows printing with the use of Device Context
>
> EXTERNAL MESSAGE - TREAT LINKS/FILES WITH CARE
>
> Antoine FINET wrote:
> >
> > I would like to print information at the correct coordinates on a pre
> > printed form.
> >
> > If I understood correctly my readings, the coordinates given to a
> > "TextOut" Printer Device Context depend on the resolution of the
> > printer. Am I right?
>
> Yes, but the exact same thing is true of on-screen windows.  You can use
> GetDeviceCaps(hdc, LOGPIXELSX) to get the pixels per inch resolution.
> There's also a LOGPIXELSY, but unless you have a 40-year-old graphics
> adapter, they are the same.  The DeviceCapabilities API returns a DEVMODE
> structure that has detailed information about the printer.
>
>
> > I don't have another printer to test but my underlying question is :
> > does the coordinates depend on the printer?
>
> Absolutely, yes.  Modern printers can be 300, 600, or 1200 dots per inch.
> Label printers can use even wilder values.
>
> --
> Tim Roberts, t...@probo.com
> Providenza & Boekelheide, Inc.
>
>
> ------------------------------
>
> Message: 2
> Date: Mon, 7 Nov 2022 23:04:07 -0800
> From: Tim Roberts <t...@probo.com>
> To: "python-win32@python.org" <python-win32@python.org>
> Subject: Re: [python-win32] Windows printing with the use of Device
>         Context
> Message-ID: <3d2a8c7f-e017-7b83-8d5f-d8d2b6c89...@probo.com>
> Content-Type: text/plain; charset=UTF-8; format=flowed
>
> On 11/7/22 5:25 PM, Neil Kenig wrote:
>
> > You may want to try https://pypi.org/project/PyMuPDF/.   It's
> relatively easy to create a blank PDF and then insert text of a given font
> and size at precise locations on the page.  PDF files use points (1/72nd of
> an inch) for both font sizes and location on a page and will print properly
> regardless of the printer's resolution (assuming the stock size is the
> same, e.g. US Letter or A4).  You can then print the PDF and if the
> preprinted stock is loaded into the printer, you should get the desired
> result.
>
> This is excellent advice, and it has the huge advantage of being
> cross-platform.? The Windows printing API is, in my expert opinion,
> peculiar and finicky.
>
> --
> Tim Roberts, t...@probo.com
> Providenza & Boekelheide, Inc.
>
>
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> python-win32 mailing list
> python-win32@python.org
> https://mail.python.org/mailman/listinfo/python-win32
>
>
> ------------------------------
>
> End of python-win32 Digest, Vol 233, Issue 3
> ********************************************
>
_______________________________________________
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32

Reply via email to