Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
See more:
I want to open a new page which will be considered as a print preview window with some content. I am using window.open method giving it some size. I need this window to be of A4 size landscape/portait (as per users selection). The user can later use browser's print capacity to print. I am having difficulty on how to decide the this windows size in terms of pixels and I assume screen resolution also plays some role here. Probably something easy but could not figure it out. Can anyone guide please.

Thanks,

Vijay
Posted

1 solution

No, it's not something easy. The thing is: a page is not measured in centimeters or inches, so it cannot be A4 or Letter size. The whole idea is wrong. The size of the page depends on how the user looks at it, screen pixel dimensions of user computer and user-selected browser window size and magnification. Pretending it's something else and trying to mimic different behavior would be against the nature of Web.

After all, if you need exact printout, make a PDF file on the fly and offer the user to print it. Don't try to print the page, print your data properly formatted for printing. To prepare such PDF document, use iTextSharp library, see http://sourceforge.net/projects/itextsharp/[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900