How to generate print preview window in php?

Hello,
How to generate print preview window in PHP programming language? Is it possible for this kind of programming language to make a very difficult algorithm like java scripts do?
Please do share your ideas with me.
