Ausdrucken mit PHP

Die Scriptsprache PHP fĂĽr die Gestaltung von dynamischen Websites.

Ausdrucken mit PHP

Beitragvon HemC » Di 03 Jun, 2003 20:41

hi!

wie kann ich in PHP ausdrucken? (eine site)
gibt es eine print() funktion oder so?

mfg
HemC
HemC
 

RE: Ausdrucken mit PHP

Beitragvon Manuel Capellari » Di 03 Jun, 2003 22:46

>gibt es eine print() funktion oder so?
höchst unwahrscheinlich :-) ... aber javascript kann das ....

window.print() bzw. self.print() sollte dir eigentlich weiterhelfen ... damit wird der druckdialog gestartet ...
Manuel Capellari
 

RE: Ausdrucken mit PHP

Beitragvon Tom » Mi 11 Jun, 2003 09:08

vielleicht will er ja direkt am Webserver ausdrucken, wär ja auch mal was ;o)
Tom
 

Beitragvon The_Invisible » Fr 27 Jun, 2003 18:32

da PHP serverseitig und nicht clientseitig (wie Javascript) läuft ist das nicht möglich...

wie bereits gesagt, als einzige Lösung bleibt das Aufrufen des Druckdialoges mittels Javascript

mfg
The_Invisible
Administrator
Administrator
 
Beiträge: 83
Registriert: Mo 23 Jun, 2003 14:58

Beitragvon radditz » Mo 30 Jun, 2003 17:36

serverseitig ausdrucken geht auf jeden Fall
der Befehl system() sollte dir dabei weiterhelfen
system ruft so gesehen die Konsole auf, nur eben am Webserver

den genauen Befehl weiĂź ich nicht, solltest du mal im Linux Forum nachfragen, wie man per Konsole druckt

wenn du willst, dass der Client was druckt, dann gehts eigentlich nur mit Javascript, aber das haben ja bereits 2 Leute vor mir erläutert
radditz
Ultimate Power-User
Ultimate Power-User
 
Beiträge: 4399
Registriert: Mo 23 Jun, 2003 16:50

Beitragvon alpinux » Di 01 Jul, 2003 06:28

Zuerst solltest du einen Drucker freundlichen Code erzeugen. Dazu habe
ich ein script gefunden. (http://www.mikenew.net/download/scripts/phprintCodeDisplay.php)

[php]
<?php

/*PHPrint - This file is phprint.php
Make any Page Printer Friendly! Version 2.0 - With error handling
Copyright by MikeNew.Net, Notice must stay intact
Any improvements to this script are welcome: www.mikenew.net/contact.asp
************
Legal: MikeNew.Net is not responsible for any damages caused
by use of this script. (Not likely that it will. Hasn't yet.)
This script will make your pages printer friendly.
Optionally, it will strip images as well. (Instructions for that below)

// After installation, you can remove text from here down to the next: 8< ---->
// Back up/copy this file first.

1. Save this script in the root of the site for simplicity.
2. Place <!-- startprint --> somewhere in your HTML page where you consider
it to be the start of printer friendly content, and <!-- stopprint --> goes at the end
of that same content.
3. You place a link to phprint.php anywhere on the HTML page (preferably outside the printed content,
like this: <a href="/phprint.php">Print this page</a>
- or however you like, just as long as you link to this script. */

// If you've already tested, you can remove the text from here up to the other: 8< ---->

//Do you want to strip images from the printable output?
// If no, change to "no". Otherwise, images are stripped by default.
$stripImages = "yes";

//what's the base domain name of your site, without trailing slash?
// Just the domain itself, so we can fix any relative image and link problems.
$baseURL="http://www.yoursite.com";

// That's it! No need to go below here. Upload it and test by going to yoursite.com/page.php
// (The page containing the two tags and a link to this script)
// -----------------------------------------------------

$startingpoint = "<!-- startprint -->";
$endingpoint = "<!-- stopprint -->";
// let's turn off any ugly errors for a sec so we can use our own if necessary...
error_reporting(0);
// $read = fopen($HTTP_REFERER, "rb") ... this line may work better if you're using NT, or even FreeBSD
$read = fopen($HTTP_REFERER, "r") or die("<br /><font face=\"Verdana\">Sorry! There is no access to this file directly. You must follow a link. <br /><br />Please click your browser's back button. </font><br><br><a href=\"http://miracle2.net/\"><img src=\"http://miracle2.net/i.gif\" alt=\"miracle 2\" border=\"0\"></a>");
// let's turn errors back on so we can debug if necessary
error_reporting(1);

$value = "";
while(!feof($read)){

$value .= fread($read, 10000); // reduce number to save server load
}
fclose($read);
$start= strpos($value, "$startingpoint");
$finish= strpos($value, "$endingpoint");
$length= $finish-$start;
$value=substr($value, $start, $length);

function i_denude($variable) {
return(eregi_replace("<img src=[^>]*>", "", $variable));
}
function i_denudef($variable) {
return(eregi_replace("<font[^>]*>", "", $variable));
}

$PHPrint = ("$value");
if ($stripImages == "yes") {
$PHPrint = i_denude("$PHPrint");
}

$PHPrint = i_denudef("$PHPrint");
$PHPrint = str_replace( "</font>", "", $PHPrint );
$PHPrint = stripslashes("$PHPrint");

echo "<base href=\"$baseURL\">";

echo $PHPrint;
// Next line is invisible except to SE crawlers, please don't remove. Thanks! :)
echo "<br><a href=\"http://miracle2.net/\"><img src=\"http://miracle2.net/i.gif\" ";
echo "alt=\"miracle 2\" border=\"0\"></a>";
echo "<br/><br/>This page printed from: $HTTP_REFERER";
flush ();
?>
[/php]


und dann kannst du mittels JavaScript den Dialog Drucken aufrufen.
Am besten fĂĽgst du diese Zeile ans Ende deiner Seite.

[php]
<script>
window.print();
</script>
[/php]
alpinux
Alumni (Moderatoren)
Alumni (Moderatoren)
 
Beiträge: 143
Registriert: Mo 30 Jun, 2003 07:15
Wohnort: Austria

Beitragvon spybreaker » Mi 02 Jul, 2003 18:14

hi,

ich habe da so eine idee,
ich wĂĽrde gerne einige html dateien generieren (und am server speichern) und die anschlieĂźend als html datei (nicht den sourcecode) direkt mit php am server ausdrucken... also alles ein skript.

wie mache ich dass am besten...

mit system (print) kan man meines wissens nur text drucken,
und die php_print funktionen benötigen RAW Daten...

danke,
spybreaker
spybreaker
Neu im Board
Neu im Board
 
Beiträge: 6
Registriert: Mi 02 Jul, 2003 18:10


ZurĂĽck zu PHP

Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 11 Gäste