Printing problem .. yes another one ...

Hi,
it seems i was finally able to print cross platform Win/Mac at the same resolution using the trick :
ps.MaxHorizontalResolution = -1
ps.MaxVerticalResolution = -1

now i’ve another problem. I need to place some box in a very specific position but if i adjust the coordinates for Windows they don’t work when i print on the mac and vice versa.
That is because PageLeft and PageTop are different when printing on Mac and Win even on the same printer.

Now that i know which are the PageLeft and PageTop on MY printer i could adjust my code for that values but i cannot know which values will have my customer on his printer and i would like to be more “generic” as possible.

For example right now on my Mac :
PageLeft is -150
PageTop is -150

On Windows
PageLeft is -100
PageTop is -83

I can easely adjust the print in this particular case BUT i would like to do it so it will always works without knowing the value of PageLeft for Win and for Mac.

How can i do ?

Thanks
Mattia

PageLeft is : [quote]The offset distance (in pixels) from the left margin of the printable area to the left edge of the physical page, i.e., the left margin.[/quote]
so it is normal it depends of the printer and the printer driver.
you should print relatively to the margins, not to the whole page.

[quote=374738:@Jean-Yves Pochez]PageLeft is :
so it is normal it depends of the printer and the printer driver.
you should print relatively to the margins, not to the whole page.[/quote]

Could you please give me an example of code where printing from mac and windows place a Box in the same position in the page ?

In your application, you’d need to read the values from the PrinterSetup object and calculate the positions accordingly. If you hard code the values it won’t work.

Basically as @Jean-Yves Pochez says, these values are not only different for each printer, but they can be different for paper sizes and different yet again for different versions of the printer driver. It’s also possible in some cases for the user to be able to override the printer margins, thus resulting in different values once again.

Lets say you want to print a 1" Square offset by 3" on both axis, THIS CODE WAS SIMPLY TYPED IN AND IS USED FOR ILLUSTRATIVE PURPOSES ONLY.

const anInch = 72 g.drawrect ( anInch * 3 ) + printerSetup.pageLeft, ( anInch * 3 ) + printerSetup.pageTop, anInch, anInch

Make sure you use the same printerSetup object as to what you pass the Printer dialog.

[quote=374808:@Sam Rowlands]In your application, you’d need to read the values from the PrinterSetup object and calculate the positions accordingly. If you hard code the values it won’t work.

Basically as @Jean-Yves Pochez says, these values are not only different for each printer, but they can be different for paper sizes and different yet again for different versions of the printer driver. It’s also possible in some cases for the user to be able to override the printer margins, thus resulting in different values once again.

Lets say you want to print a 1" Square offset by 3" on both axis, THIS CODE WAS SIMPLY TYPED IN AND IS USED FOR ILLUSTRATIVE PURPOSES ONLY.

const anInch = 72 g.drawrect ( anInch * 3 ) + printerSetup.pageLeft, ( anInch * 3 ) + printerSetup.pageTop, anInch, anInch

Make sure you use the same printerSetup object as to what you pass the Printer dialog.[/quote]

I’m sorry Sam but this doesn’t solve my problem. If i use your code on Windows and Mac it does print a square of the same size in both WIndows and Mac but it is mispositioned.
To be clear :
If i overlap the 2 pages i’ve printed the box doesn’t overlap. On the mac printed page is more left and top than the windows printed paged.

I need the square (or the text) to be positioned exatly the same on both operating system printed page that’s because i’m printing invoices on paper that already have logos and boxes where i have to put only the text. If i caliber the print to work on Mac it doesn’t work on windows and if it works on Windows it misplaced on mac.

That’s my problem

It’s about now that you should start considering offering the user a simple screen to adjust the left and top offsets so that they can line things up themselves.
Perhaps also with your ‘own’ margin settings

Then add their values to all your x and y co-ordinates.
I dont think you can reliably cater for the user modifying the margins , and cater for every possible printer.
There is (IME) a big difference between the usable area of a sheet of A4 between an HP deskjet printer and a laser printer

Mattia,

are you able to print two pages from the same OS where the square is printed at the same location ?

OK, this was in the 90s (nearly 30 years ago), but I had this kind of troubles then, but it was the way the printer worked, then.

Also, what is the ? between the pages printed by the two OS ? is the difference in the printing position really hurts / is unacceptable ? (More that 2 or 3 mm ?)

Can’t you add a (or remove) a value to the printing depending on the running OS (#If TargetCocoa <then remove or add 15 pixels for example>) ?

Just some ideas.

[quote=375104:@Emile Schwarz]Mattia,

are you able to print two pages from the same OS where the square is printed at the same location ?

OK, this was in the 90s (nearly 30 years ago), but I had this kind of troubles then, but it was the way the printer worked, then.

Also, what is the ? between the pages printed by the two OS ? is the difference in the printing position really hurts / is unacceptable ? (More that 2 or 3 mm ?)

Can’t you add a (or remove) a value to the printing depending on the running OS (#If TargetCocoa <then remove or add 15 pixels for example>) ?

Just some ideas.[/quote]

Hi Emile,
thanks for your ideas.
I had the same idea about adding or removing a value to “calibrate” the print based on the OS but i’m afraid that if something change (os version, printer driver) that value will not be valid anymore. Is a specific hotfix but i think there should be a generic way of printing so that is “universal”. Xojo allows us to compile cross platform so that’s what i’m trying to obtain here.

The Mac os print layout is different from the windows layout of about 6mm. It woudn’t be much but as i said i need to print in very specific box who are already printed in the paper that my customer use.
Also there are 2 logos in the page already printed in the paper and i have to write around them and 6mm is just too much and the text goes over the logos.

I agree, 6 mm is too much.

My advice is: do not wait for a patch from Xojo: they have so many things to do on their plate !

Maybe until then, Xojo have time to release a patch from their own