swatisonee Posted December 15, 2006 Share Posted December 15, 2006 Hi,I use FP to draw tables of my various php pages. Its a pain printing because i have to adjust it to A4 size every time .Is there a function or code that i can set up at the top of each page so it appears on the screen as well as on paper in A4 size only ? Something like <? include("a4.php"); ?> I cannot find what i'm looking for on google and the pagination hits mainly talk about the prev-next type of issues.Would appreciate any pointers.Thanks.Swati Quote Link to comment Share on other sites More sharing options...
Psycho Posted December 15, 2006 Share Posted December 15, 2006 The page size, to my knowledge, is set in the browser application itself - not the web page content. In IE, go to File < Page Setup and change your page size to A4. Quote Link to comment Share on other sites More sharing options...
swatisonee Posted December 15, 2006 Author Share Posted December 15, 2006 Thats a pain isnt it. Every time a page is to be printed, page size has to be selected . i was hoping to set it in such a way that what a person sees on screen - A4 layout is what gets printed. Quote Link to comment Share on other sites More sharing options...
Psycho Posted December 15, 2006 Share Posted December 15, 2006 No, you do not need to set it each time. You can simply set the default in your browser settings. It wouldn't make sense to dynamically set the page size for the user since you don't know what type of paper they have in their printer. The user should have the browser already configured for their paper type.However, I do wish there was a way to change the page layout from portrait to landscape on the fly. At least there wasn't a few years ago when I needed that functionality for a project - haven't checked since. Quote Link to comment Share on other sites More sharing options...
taith Posted December 15, 2006 Share Posted December 15, 2006 found something!http://us3.php.net/manual/en/function.printer-set-option.php[code]printer_set_option($handle, PRINTER_PAPER_FORMAT, PRINTER_FORMAT_A4);[/code]assuming your using a link to print the page, that might help, if your using file print, probly not... Quote Link to comment Share on other sites More sharing options...
Psycho Posted December 15, 2006 Share Posted December 15, 2006 Good find. If it's for an internal network, that might work. But, I don't think it will work for external users since "handle must be a valid handle to a printer". Perhaps there is a way to create a handle to the user's default printer - but I would think that would be a security risk. Quote Link to comment Share on other sites More sharing options...
swatisonee Posted December 18, 2006 Author Share Posted December 18, 2006 I guess i did something wrong and did not understand how to use this. I put this in the header of the php file (viewdata.php) .[code]<? include ("../include/printer.php");?>[/code]and got this in return[quote]Fatal error: Call to undefined function: printer_open() in /home/xxxx/public_html/xxxx/include/printer.php on line 2[/quote]And printer.php is [code]<?php$handle = printer_open(); // line 2printer_set_option($handle, PRINTER_SCALE, 100);printer_set_option($handle, PRINTER_TEXT_ALIGN, PRINTER_TA_LEFT);printer_set_option($handle, PRINTER_PAPER_FORMAT, PRINTER_FORMAT_A4);printer_set_option($handle, PRINTER_BACKGROUND_COLOR, "#FFFFFF");printer_set_option($handle, PRINTER_TEXT_COLOR, "#000000");printer_close($handle);?>[/code]Could someone suggest some modifications please ? Quote Link to comment Share on other sites More sharing options...
mainewoods Posted December 18, 2006 Share Posted December 18, 2006 create a printer friendly page using the css 'print' media type:http://www.javascriptkit.com/dhtmltutors/cssmedia.shtml Quote Link to comment Share on other sites More sharing options...
Psycho Posted December 18, 2006 Share Posted December 18, 2006 [quote author=swatisonee link=topic=118730.msg487289#msg487289 date=1166450692]I guess i did something wrong and did not understand how to use this. I put this in the header of the php file (viewdata.php) .[code]<? include ("../include/printer.php");?>[/code]and got this in return[quote]Fatal error: Call to undefined function: printer_open() in /home/xxxx/public_html/xxxx/include/printer.php on line 2[/quote]And printer.php is [code]<?php$handle = printer_open(); // line 2printer_set_option($handle, PRINTER_SCALE, 100);printer_set_option($handle, PRINTER_TEXT_ALIGN, PRINTER_TA_LEFT);printer_set_option($handle, PRINTER_PAPER_FORMAT, PRINTER_FORMAT_A4);printer_set_option($handle, PRINTER_BACKGROUND_COLOR, "#FFFFFF");printer_set_option($handle, PRINTER_TEXT_COLOR, "#000000");printer_close($handle);?>[/code]Could someone suggest some modifications please ?[/quote]The printer_open() is not a built in PHP function, it is a custom function to create a handle to a printer - which the manual does not explain. As I alluded to in my previous post, this will not work for the web because you do not have access to the user's printers. It would probably only be workable on an internal network. Quote Link to comment Share on other sites More sharing options...
swatisonee Posted December 19, 2006 Author Share Posted December 19, 2006 Oh ok. but isnt it strange then that its a php function ? Quote Link to comment Share on other sites More sharing options...
Psycho Posted December 19, 2006 Share Posted December 19, 2006 No, not really. VBScript is the primary scripting language used in ASP driven web sites. But, I can do A LOT with it on the desktop. Just recently I created a script that would parse particular emails that I receive and create a spreadsheet with the retrieved data. This was all on the desktop with no web server involved. I suspect you can do a lot of the same things with PHP scripting on the desktop. Quote Link to comment Share on other sites More sharing options...
swatisonee Posted December 19, 2006 Author Share Posted December 19, 2006 Thats very interesting . It sounds like an indexing Is something like that possible in Php ? I must admit though I dont know how one would use php without it going thru a server. Quote Link to comment Share on other sites More sharing options...
Psycho Posted December 19, 2006 Share Posted December 19, 2006 [b]Chapter 43. Using PHP from the command line[/b][i]As of version 4.3.0, PHP supports a new SAPI type (Server Application Programming Interface) named CLI which means Command Line Interface. As the name implies, [color=red]this SAPI type main focus is on developing shell (or desktop as well) applications with PHP.[/color][/i]http://us3.php.net/features.commandline Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.