Page 1 of 1

problem with changing printer-prefs

Posted: Sun Oct 08, 2017 6:58 pm
by turbo4.1
i am working on a printing-routine of a program and want to implement the page-format-data of this program. the program makes a
rasterport dump to the printer.
the following is the implementation of the left border, like i found them in the rkrm-devices or on the wiki-page from amiga-documentation.

if (!OpenDevice("printer.device", unit, (struct IORequest *)pio, 0))
{
pd = (struct PrinterData *)pio->iodrp.io_Device;
ped = (struct PrinterExtendedData *)&pd->pd_SegmentData->ps_PED;

/* MERKER to be implemented: printer-prefs übernehmen */

//Set preferences with pageformat
pd->pd_Preferences.XOffset = (BYTE)((mp->mp_BorderLeft / 1024) / 2.54);
pd->pd_Preferences.PrintXOffset = (BYTE)((mp->mp_BorderLeft / 1024) / 2.54);
pd->pd_Preferences.PrintLeftMargin = (BYTE)((mp->mp_BorderLeft / 1024) / 2.54);
pio->ios.io_Command = CMD_WRITE;
pio->ios.io_Data = "\033#1";
pio->ios.io_Length = -1L;
DoIO((struct IORequest *)pio);
//starting graphicdump
pio->iodrp.io_Command = PRD_DUMPRPORT;
...

the problem is, it does not work. the printer always uses the settings from prefs-dialogs and not my changed one. (i test it with a usbprinter and the print to postscript)
what do i wrong?
i use 4.1FE an the sdk 53.29.

Re: problem with changing printer-prefs

Posted: Mon Oct 09, 2017 12:05 am
by tonyw
You have the command CMD_WRITE in the request. That should cause the device driver to write the contents of the data ("\033#1") directly to the printer transparently. It will not affect the driver's stored preferences.

I don't know how to change the stored preferences from outside the driver. Can you provide a link to the Wiki entry? I can't find it to check.

Re: problem with changing printer-prefs

Posted: Mon Oct 09, 2017 1:49 pm
by broadblues
@Tony

The wiki stuff is here:

http://wiki.amigaos.net/wiki/Printer_Device

@turbo4.1

Some questions and observations:

what is the range and type of the value in the is expression?

(BYTE)(mp->mp_BorderLeft / 1024) / 2.54);

PrintLeftMargin is for text only only, ie its a value in characters, so likely will have no effect for graphics settings.
XOffset is related to the mouse pointer and so not relavant to printing

PrintXOffset would seem to be the one you want but it's in 10ths onf an inch, hence my question about range and type of the values above.

Lastly what printer driver are you using with which printer?

Re: problem with changing printer-prefs

Posted: Mon Oct 09, 2017 3:54 pm
by xenic
@broadblues & Tony
turbo4.1 made these statements:
the program makes a rasterport dump to the printer.
i test it with a usbprinter and the print to postscript
I'm not sure the WIKI printer docs even apply to Postscript. Can the Amiga printer.device or drivers convert a rasterport dump to postscript??

Re: problem with changing printer-prefs

Posted: Mon Oct 09, 2017 4:37 pm
by turbo4.1
@tonyw
i am too slow, broadblues already posted the proper link. same listing a find in the RKRM-Devices.

@broadblues
i also think that the PrintXOffset is the correct entry, but i want to be sure, not to change the wrong one ;-)
the formula after the variable calculates the correct value from the intern border-value of the ignition pageformat-dialog.

i test it with "print to postscript" feature of aos4.1FE and with usbprinter.device with the HP_Photosmart driver.

@xenic
yes, it works. i test the printing-routine with this feature to save paper and ink. ;-)

thanks to all for your help, i hope this accelerate the develop of ign b5 :-)

next problem with changing printer-prefs

Posted: Tue Jan 30, 2018 6:18 pm
by turbo4.1
because nobody has a hint for me, i found another solution for changing the printer-prefs, before i open the device. i changed the prefs-file in env:.
it works fine for the postscript-printers, but now i have a problem with the other one.
i use the printer-gfx-prefs element "pg_PrintXOffset" for the left-margin and it works fine.
but the offset for the topedge "pg_PrintYOffset" will be ignored!
i tested this all with printing in a file/image.
how i can i create a top margin?
it is also very interesting, that now input-gadget exist in the prefs-dialog for a top offset, only for the left margin.

Re: next problem with changing printer-prefs

Posted: Thu Feb 01, 2018 4:04 pm
by xenic
turbo4.1 wrote: but the offset for the topedge "pg_PrintYOffset" will be ignored!
i tested this all with printing in a file/image.
how i can i create a top margin?
I don't know if it's the same problem as yours but I've always had a top margin issue with my HP Photosmart printer. I don't know if its a driver issue or the printer itself. When printing a multi-page text file, the top margin on the first page is larger (approx 1 inch) than the subsequent pages (approx 1/2 inch). I've worked around that problem by adding a blank page to the beginning of multi-page text files that gets ejected before printing starts. It's as though the driver or printer forgets the top margin setting between pages.