Change the page margins on print

The subject line says all:

how can I change the printable area size (changing the page margins) ?

I want to print with a Landscape orientation and I want to set the right margin equal to the left margin (who is not the case by default).

[quote=133120:@Emile Schwarz]The subject line says all:

how can I change the printable area size (changing the page margins) ?

I want to print with a Landscape orientation and I want to set the right margin equal to the left margin (who is not the case by default).[/quote]

I suppose you are not talking about HTMLViewer which has it’s own print routine.

Normally, the printer graphic object handed by PrinterDialog has its dimensions set according to the user preferences. In other words, if the user chooses landscape, g.width will be larger than g.height. So you have to build your print method accordingly.

Margins are in fact what you make of them by positioning the drawing onto the graphics object.

I have not tested it, but I believe instead of a simple graphics object, you could do something like this for portrait

dim proum as PrinterSetup dim p as picture(612x792) //Letter size, A4 is 596x843 p.graphics = OpenPrinterDialog(proum)
That allows you to have a picture object you can manipulate, scale in another picture, and drawpicture back into p.graphics.

Michel,


from Set page margins.

Setting Landscape or not is not the problem.

What I really want is to be able, in Landscape mode to set the left and right margins with the same values. Making a print Landscape rotates the page and keep the large bottom margin as now the Landscape right margin.

The example (MS pages / images) displays how to change (a bit) all four margins who is the best options. I recall that in Word, one can set its own page margins values.

Standard Xojo margins are: Left, Right and Top share the same value (Portrait) and bottom is taller.

[quote=133167:@Emile Schwarz]Michel,


from Set page margins.

Setting Landscape or not is not the problem.

What I really want is to be able, in Landscape mode to set the left and right margins with the same values. Making a print Landscape rotates the page and keep the large bottom margin as now the Landscape right margin.

The example (MS pages / images) displays how to change (a bit) all four margins who is the best options. I recall that in Word, one can set its own page margins values.

Standard Xojo margins are: Left, Right and Top share the same value (Portrait) and bottom is taller.[/quote]

From what I can see between the HP 1500 laser printer and HP Envy D410 jet printer I have, the standard Mac OS X printer dialog does not provide any way to set the margins. So you will have to manage them within your application, like Microsoft does.

Fine ! BTW: how can I do that ?

Depends what you want to print and how you want to print it.

Basically, you can think of the printer graphics object as a big picture into which you will be doing what you do to create a picture drawstring, drawpicture, drawrect, drawinto… You are in full control of the layout pretty much the same way you would do it for a window.

You can also use the StyledTextPrinter feature of a TextArea, which may be easier sometimes. You can even Drawinto controls into the printer graphics object, but resolution will be vastly inferior to current printers which are usually at 600 dpi minimum.

False: I have no control on the printing area (vs physical page) and that is the subject of the conversation.

What I mean is in order to print you draw onto the graphics printer object, so you decide in fact where goes what.

[quote=133120:@Emile Schwarz]The subject line says all:

how can I change the printable area size (changing the page margins) ?

I want to print with a Landscape orientation and I want to set the right margin equal to the left margin (who is not the case by default).[/quote]

How do you print at present ? Have some code ?

Have you tried this. If all the margins are 1 inch and your printer is working at 300 dpi that would make the very top left default coordinate of 0,0 print 1 inch from the top and left. If you use the coordinate of -150,-150 wouldn’t that then print 1/2 inch from top and left? You just have to be sure that you don’t pick a point that your printer cannot print as a lot of printers have minimum margins that they can achieve. That is, the can not print to the very edge of the paper on all four sides.

On Windows, at least, you can effectively ignore the margins and print wherever you want. I don’t know if that works on the other platforms, though.

It does.

Fantastic !

Now the OSes lies to the developers / standard users !

For me a Printable Area is an area on the paper (or PDF in this very case) where you can print. In that logic, trying to print on the margins will not be shown. Thus my question.

Thank you all, I will check that this afternoon when I will be able to check that.

In the mean time, I have added and debugged the code to print my ListBox contents…

BTW: I saw two times the same variable name (the loop indice) in the debugger: in fact, it was: LoopIdx and Loopdx !
I really need to change my glasses (or get an eye replacement for a better one).

Dim g As Graphics Dim p As PrinterSetup p = New PrinterSetup If p.PageSetupDialog Then g = OpenPrinterDialog(p) If g <> Nil Then g.DrawString("The quick brown fox jumps over the lazy dog", 50, 50) End If End If

About the print resolution:

printing to pdf at “standard resolution” produce vector characters, so I do not need to change the printing resolution. For the graphics, I do not have checked (print to pdf) or I forgot.

In a “in production” application, I print to pdf (or the user print to laser printer) text only, and the result is excellent.

This does not help because I already does that.

[quote=133386:@Emile Schwarz]For me a Printable Area is an area on the paper (or PDF in this very case) where you can print. In that logic, trying to print on the margins will not be shown. Thus my question.
[/quote]

You have to distinguish between the printer printable area, which means where it can actually put ink on paper, and printing zone, which is determined by margins you define in your program. It is quite similar to physical paper : one can indeed write in the margins. And since paper does not have printable area, up to the very edge.

[quote=133389:@Emile Schwarz]About the print resolution:

printing to pdf at “standard resolution” produce vector characters, so I do not need to change the printing resolution. For the graphics, I do not have checked (print to pdf) or I forgot.[/quote]

It has been my experience that printing text with fonts, Xojo prints at maximum resolution without need to set it yourself. You can see it from the sample you posted.

I wanted to know if you did not print from a TextArea, which is different.

What I wrote previously stands : nothing is automatic when printing with that method. You got to position every field the way you did at 50,50 in your example. That is what I meant “you are in control”. Actually, you got to do everything, like you would by positioning labels dynamically on a page.

The left margin is easy, since all you got to do is to set width+margin. The right margin is trickier, since you must weigh the length of strings on the right and their alignment manually not to exceed the margin. I have an application that print chechs, and believe me, I have used quite a few sheets of paper before being able to post to the MAS :wink:

There is a tip, though, which may help you position accurately your DrawString for printing : create a page the size of the print object (g). You can get the size by g.Width and g.Height.

On that page, position labels with the proper font size and mockup data until you are satisfied with the result. Then you get where to print by something like :

PrintLeft = Label.Left+3 PrintTop = Label.Top+Label.Height/2 g.Forecolor = Label.TextColor g.TextSize = Label.Textsize g. TextFont = Label.TextFont

g.drawstring(Label.Text,PrintLeft,PrintTop)

Printer printable area
Isn’t all currently on sale ink printers available able to print borderless ?

Sorry for the TextArea / ListBox / Whatever: it is a case where I wrote one part and keep in my mind the other part of the question.

I was thinking at ListBox printing. And by printing, I meant “print to pdf".

Let me thank one more time the guy who shared the trick to bypass the PopupMenu selector when I pront to pdf: it allows me to not waste my time at debug time.

The last time I printed to real printer was in 1999-2002 time frame: I’ve made a simple application that used drag and drop and print dragged small images in pages (computing the number of images on the width and height of the page), used the file name as images “caption”.
[The pages goes to the top (inside) of Box where I placed comic books before a relocation. Fortunately, I had many cover scans. The project was fun to do, not the relocation !]

Back to ListBox printing:

The ListBox have two columns --> I set the page orientation to Landscape and TextSize to 9 (I think), TextFont to “Trebushet MS”.

Footer and header are used,

No line number is used, but it can be.

I set a background (light grey) on every odd lines

Column 0 is an URL
Column 1 is a description (and is always small: a newspaper journal name)

At last, no image, no complex math, some variables to reset to 0 / change their values to the start values for a new page.

I spent too much time writing it because I wanted to have done it “before I started it”, so I get many errors (many errors). That is what happens when we think “this is simply too easy to doo, it will takes minutes” and the history would prove the contrary…

In fact, the logic have to be clear in mind, (write it to paper so it will not be forgotten / you keed focused on it) then followed “à la lettre” and take your time to implement it using a simple text file loaded in the ListBox !

Next challenge: check it under Windows and make it working !

[quote=133590:@Emile Schwarz]>Printer printable area
Isn’t all currently on sale ink printers available able to print borderless ?
[/quote]

Even borderless or PDF does require to know the size of the area where the printing goes to print adequately.

[quote]Back to ListBox printing:
…/…
[/quote]
I am sorry, but what is it exactly you want to do ? You go at length about the listbox design. If what you want to do is to get that in the PDF, simply use DrawInto.