PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I figure this is something that is setup through browser/OS settings, but is there any way to change the page margins of a webpage using PHP, HTML, etc.? I want a page to print starting at almost the very top of the page. Here is how I have my HTMl currently set:
You have little control over it since the browser and OS have final say as to what margins are used. If you generated a PDF, it's a little bit easier to control, but again, the reader and OS can alter it outside of your own control.
However, the printer will most likely add a small margin anyway... I doubt you can avoid that, even with PDF most home-printers have some sort of minimum margin.
d11wtq wrote:However, the printer will most likely add a small margin anyway... I doubt you can avoid that, even with PDF most home-printers have some sort of minimum margin.
Well, it is possible. There are printers that do that.
P.S I'm not sure he was talking about printing the page on a sheet of paper.
Well, when I print this page out, there is about 3/4" white space on the top and botom of the page and I was wanting to fill that space of possible. Yes, I'm printing out the page to the printer.
I think this will have more to do with the users' browser page setup than how you use CSS. If you set your page setup margins to .25" across the board you will get smaller edges on the paper when printing than if they were set to 1". And I don't think you can write code that will change a user's browser settings (though I could be wrong about that).
That would seem like a security issue there. The CSS helped a little bit though. With the default settings on my Linux machine (Firefox) and on Windows (Firefox and IE), they printed out fine.
My only problem is that I have the page set to the max. Meaning, when it prints out, it's using all the space possible because the page is that long. Also, it can only be one page so that's why Im worried about it. This is going to be used by multiple users so I don't want to make them have to change printer settings just to print it. I think I'm good though. the CSS added a little more room to play with and it's all on 1 page now.
If printing is critical, generate a PDF. It's far easier to control than getting a web page to look right when printed from the multitude of browsers and OS's out there.