Jump to content

Fixing A4 size in a header file


swatisonee

Recommended Posts

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



Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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...
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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 2
printer_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 ?
Link to comment
Share on other sites

[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 2
printer_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.
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

[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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.