开发者

Printing an envelope from a web page

Is there a way to specify the media type / page size to be used when the user prints a web page? Also, can I lay out text so it will be printed at specific positions?

For example, I’d like to render an a开发者_开发技巧ddress on a web page that the user can then print on a letter-size envelope.

Thanks!

EDIT

By media type, I meant the type of print media, such as letter-size, legal-size, #10 envelope, etc.


I think the bottom line is best use a PDF. Sadly, Browsers suck very much at printing.

Is there a way to specify the media type / page size to be used when the user prints a web page?

You can specify a CSS style sheet to apply only to printing using media="print". As to the page size, there is no reliable way of specifying that. You will have to rely on the user to do this for you.

Also, you will have to rely on the user to remove the header and footer that most browsers add to the printed result.

Also, can I lay out text so it will be printed at specific positions?

In theory, yes. You can use physical unit values cm or in to position elements on the page. I'm not sure whether these work with 100% reliability though, because printer specific margins may change the result - you'd have to test.


You may want to try using CSS for different mediatypes, though I don't know if this will give you the precise control you're asking for.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜