5

I create simple page which I want to print from a browser. I put all whistles I was able to find to center my title and picture.

<html>
<head>
    <link rel="stylesheet" href="print.css" type="text/css" media="print" />
    <!-- print.css is empty -->
</head>
<body style="text-align: center; margin: 0 auto;">
    <div>
        <div style="font-size:48pt">
            Pretty Long-Long-Long Title
        </div>
        <img src="content/images/sample.jpg" style="width:80%"/>
    </div>
</body>
</html>

The page looks fine and centered in all browsers.
The page is printed fine (centered) in IE and Firefox, but in Chrome the whole body box is left-justified and much smaller than page width.
Is there any whistels that would help to print centered title/image from Chrome?


Problem solved.
The problem was in Chrome itself. To be more exact, in Print Preview which uses Chrome PDF Writer plug-in. Looks like the Chrome PDF Writer does not recognize page size and does not have any Page Setup settings. I disabled Chrome's Print Preview, installed Adobe's PDF Printer, and everything prints OK with my original code fragment.

VikVik
  • 1,045
  • 2
  • 11
  • 15

1 Answers1

3

try this

<body>
    <div align="center" style="text-align:center;">
        <div style="font-size:48pt">
            Pretty Long-Long-Long Title
        </div>
        <img src="content/images/sample.jpg" style="width:80%"/>
    </div>
</body>

either

<div align="center" style="text-align:center;">

or

<div style="text-align:center;margin:0 auto;">

worked for me in chrome, printed to a pdf

Kraz
  • 6,910
  • 6
  • 42
  • 70
  • #1 makes title to left-justified #2 bahaves the same way as my original. Maybe there are some Chrome settings I'm not aware of? – VikVik Jun 10 '11 at 19:50
  • I supposed Chrome extracted the body content, so any style applied to it would be removed. I can't confirm it is exactly this, but it seems so. – Kraz Jun 10 '11 at 20:06