Printing: Margin and Paper Size settings

Hello XOJOers.

I’ve been working for a Long time on a certain Project which involves a Receipt Printer from Epson. I got it to work fine with Reports, but I still have issues with the Printing itself. To print I Need to open a Dialog first where the user can set the margins and paper size en then the Printer Dialog. This sucks when printing a receipt. The margins of this receipt are Always 0 and the Paper Size is Always the same. How can I edit the margins? I took a look at some Solutions here on this Forum but I didn’t find a solution that worked for us.

Is there any easy way to configure the margins? We’ve been taking a look at MBS windowsprintermbs class too, but this seems only to be usefull for us by Setting a new Default Printer when it is a receipt print.

How can I Change those Margins that I don’t have to enter them every time?


[code] Dim ps As New PrinterSetup

Dim rpt As New report_cash
Dim g As graphics

ps.MaxHorizontalResolution = -1
ps.MaxVerticalResolution = -1

ps.SetupString = wndHauptfenster.printsettings

Call ps.PageSetupDialog
g = OpenPrinter(ps)

If rpt.Run(wnd_quittung.list_quittung, ps) Then
If rpt.Document <> Nil Then
wndHauptfenster.printsettings = ps.SetupString
End If
End If[/code]

No code ?

Read there:

[quote=475391:@Emile Schwarz]No code ?

Read there:[/quote]

You can’t use PrinterSetup to modify the margins. The Code is exactly like the example.

A paste of that example is welcome, please.

The provided link gos to this part of the LR Page:

This code restores the page setup settings stored in a String variable called "settings" and then displays the Page Setup dialog box with those settings: Var pageSetup As PrinterSetup pageSetup = New PrinterSetup pageSetup.Settings = s If pageSetup.ShowPageSetupDialog Then s = pageSetup.Settings End If

So, you can store that into a prefs file with code to check the current printer (you have to write this part), then read and restore the settings from the prefs file for the next print.

In answer to:

Now, I never printed a ticket to a ticket printer, so I know nothing aout setting margins there and I believe you when you said this is not possible.

Are-you still trying to print a Ticket from a ListBox ?

BTW: did you noticed you have Left and PageLeft in the page (Same for other Top, Width, Height, …).
Sometimes the command you seek does not have the name you think it have to be named…
One set of commands have the physical paper page, the second is for the printing area (thus Margin with a different design/name).