The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Printing problem with php and html, Printing attendee labels
mitchellyachting
post Nov 8 2008, 10:53 PM
Post #1





Group: Members
Posts: 4
Joined: 23-October 08
Member No.: 6,972



Ok here is the problem.

I have just about completed a system for a recruitment fair and I just need to work out how to print the name label. I have a checking form at the desk where the attendee gives their email address (they pre-registered). The php looks up a MySQl DB and finds the record. I then create a gif file with a banner and the name of the person it. The GIF file is the correct size for the label printer.

My problem is I cannot seem to get php to output the file. I thought about using a HTML page to print it but I do not want a button being printed as well.

Any thoughts would be appreciated.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Nov 8 2008, 11:31 PM
Post #2


Jocular coder
********

Group: Members
Posts: 2,460
Joined: 31-August 06
Member No.: 43



QUOTE(mitchellyachting @ Nov 9 2008, 12:53 PM) *

My problem is I cannot seem to get php to output the file. I thought about using a HTML page to print it but I do not want a button being printed as well.


[Incidentally, this isn't an "HTML markup" problem...]

Shouldn't be a problem. The php file needs to output the appropriate http header, then send the file. Here's a sample source of a jpeg script -- it takes an existing colour palette, and adds a cross-hair cursor. HTH:

CODE

<?php

// iromap.php: output iromap.jpg with cross-hairs added

$map = @imagecreatefromjpeg($_SERVER['DOCUMENT_ROOT'] . '/graphics/iromap.jpg');

$x = $_GET['x']; $y = $_GET['y'];
$q = $_GET['q'];
if(!$q) $q = 80;    // default quality

if (is_numeric($x) && $x >=0 && $x < 256 && is_numeric($y) && $y >=0 && $y < 256)
{    // then draw cross!

    $hair = $y > 160 ? 0 : 0xffffff;

    foreach (array(1, -1) as $xsign)
        foreach (array(1, -1) as $ysign)
        {    imageline ($map, $x + $xsign, $y + $ysign, $x + 8*$xsign, $y + $ysign, $hair);
            imageline ($map, $x + $xsign, $y + $ysign, $x + $xsign, $y + 8*$ysign, $hair);
        }
}

header("Content-type: image/jpeg");
imagejpeg($map, '', $q);
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Darin McGrew
post Nov 9 2008, 02:45 AM
Post #3


WDG Member
********

Group: Root Admin
Posts: 8,365
Joined: 4-August 06
From: Mountain View, CA
Member No.: 3



I moved this to the Server-side Scripting forum.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
mitchellyachting
post Nov 9 2008, 10:50 AM
Post #4





Group: Members
Posts: 4
Joined: 23-October 08
Member No.: 6,972



Brian,

I tried your code sample but that just manipulates the image and displays it on the screen. I have the image manipulated already but my problem is I need to output it on paper with a label printer. So far I have managed to get window.print() to work but its crude and imbeds a header and footer onto the document.

Any further thoughts.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Nov 9 2008, 11:04 AM
Post #5


Jocular coder
********

Group: Members
Posts: 2,460
Joined: 31-August 06
Member No.: 43



Sorry, I realised afterwards I wasn't really sure what your question is.

We print invoices (etc) from a web application, and it's quite possible, but a bit messy.

You are using java script: you should be able to get rid of footers etc simply by changing the settings on the browser you are using. The problem is that every time someone uses the browser to print something else they forgot to switch back to the correct settings. But if it's a dedicated system this may not be a problem.

The other approach (which would be ideal) is to have the server running on the computer to which the printer is connected, and work out how to print an image file directly. In principle you should be able to find (e.g.) an image to postscript converter, so you can drive the printer directly. Depends how slick you need it to be, and how much time. (If you find out any juicy facts about this _please_ let us know!)

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 23rd April 2024 - 03:31 PM