[PHP] PDF creation using PHP, based on a PDF template

2004-01-22 Thread Mark Wouters
Hi all!

I'm trying out this script I found in a book I bought. It does not work
though..  The code is below. It looked like an easy solution for what I want
to do.
It takes a template PDF file and replaces description1 with a value,
bedr1 with a value,...
I want to be able to generate an PDF invoice automatically, based on a
template PDF.
I get this error: The file is damaged and could not be repaired.
Except when I comment out the 4 $output = pdf_replace( ) lines.. then it
works.. so something is wrong with the pdf_replace function..
If I open the PDF in Notepad I noticed it got cut off quite in the beginning
of the file..

Does anyone have an idea?
Or does someone know an other way to create PDF's based on a PDF, on the
fly, using PHP??

Thanks!

Mark.


?
  set_time_limit( 180 ); // this script can be very slow

  function pdf_replace( $pattern, $replacement, $string )
  {
$len = strlen( $pattern );
$regexp = '';
for ( $i = 0; $i$len; $i++ )
{
  $regexp .= $pattern[$i];
  if ($i$len-1)
$regexp .= (\)\-{0,1}[0-9]*\(){0,1};
}
return ereg_replace ( $regexp, $replacement, $string );
  }


 $description1=PDF creation module;
 $bedrag1=240;
 $total1=480;

//generate the headers to help a browser choose the correct application
header( Content-Disposition:  filename=result.pdf);
header( Content-type: application/pdf );

$date = date( F d, Y );

// open our template file
$filename = template.pdf;
$fp = fopen ( $filename, r );

//read our template into a variable
$output = fread( $fp, filesize( $filename ) );

fclose ( $fp );

// replace the place holders in the template with our data
$output = pdf_replace( description1, $description1, $output );
$output = pdf_replace( bedr1, $bedrag1, $output );
$output = pdf_replace( tot1, $total1, $output );
$output = pdf_replace( mm/dd/, $date, $output );

// send the generated document to the browser
echo $output;
?

--

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] PDFlib error 2516

2004-01-15 Thread Mark Wouters
Hello!

Tried out this simple script from a tutorial on creating PDF with PHP:

?php

 $pdf = PDF_new();
 PDF_open_file($pdf, testpdf.pdf);

  PDF_set_info($pdf, Author, Someone);
  PDF_set_info($pdf, Title, PDF creation with PHP);
  PDF_set_info($pdf, Creator, Someone);
  PDF_set_info($pdf, Subject, Creating PDFs);

  PDF_begin_page($pdf, 595, 842);

   $arial = PDF_findfont($pdf, Arial, host, 1);
   PDF_setfont($pdf, $arial, 14);

   PDF_show_xy($pdf, Pricelist, 40, 780);

  PDF_end_page($pdf);

 PDF_close($pdf);

?

However got this error:

Fatal error: PDFlib error: [2516] PDF_findfont: Metrics data for font
'Arial' not found in
/usr/local/psa/home/vhosts/resilion.be/httpdocs/test/createpdf.php on line
23

Does anyone have an idea what the problem could be? What does the host
mean in the example above ($arial = PDF_findfont($pdf, Arial, host,
1); )?

Thanks for any help

Mark.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] mcrypt and PHP to encrypt values to be passed to differend server

2003-12-28 Thread Mark Wouters
Hello!

I'm trying to use mcrypt to encrypt some values (login and password) I have
to pass from one website to another.
I thook this code from the php.net website as an example:

?php
/* Open the cipher */
$td = mcrypt_module_open ('rijndael-256', '', 'ofb', '');

/* Create the IV and determine the keysize length */
$iv = mcrypt_create_iv (mcrypt_enc_get_iv_size($td), MCRYPT_DEV_RANDOM);
$ks = mcrypt_enc_get_key_size ($td);

/* Create key */
$key = substr (md5 ('very secret key'), 0, $ks);

/* Intialize encryption */
mcrypt_generic_init ($td, $key, $iv);

/* Encrypt data */
$encrypted = mcrypt_generic ($td, 'This is very important data');

/* Terminate encryption handler */
mcrypt_generic_deinit ($td);

/* Initialize encryption module for decryption */
mcrypt_generic_init ($td, $key, $iv);

/* Decrypt encrypted string */
$decrypted = mdecrypt_generic ($td, $encrypted);

/* Terminate decryption handle and close module */
mcrypt_generic_deinit ($td);
mcrypt_module_close ($td);

/* Show string */
echo trim ($decrypted).\n;
?

I put this in the page starting from:

?php
$adminlogin = $row1[adminlogin];
$adminpw = $row1[adminpw];
// both are queried from a database

$td = mcrypt_module_open ('rijndael-256', '', 'ofb', '');
$iv = mcrypt_create_iv (mcrypt_enc_get_iv_size($td), MCRYPT_DEV_RANDOM);
$ks = mcrypt_enc_get_key_size ($td);
$key = substr (md5 ('a key fsfqz'), 0, $ks);
mcrypt_generic_init ($td, $key, $iv);

/* Encrypt data */
$encryptedlogin = mcrypt_generic ($td, $adminlogin);
$encryptedpassw = mcrypt_generic ($td, $adminpw);

mcrypt_generic_deinit ($td);
mcrypt_module_close ($td);
?
a href=destinationpage.php?login=?php echo($encryptedlogin);
?password=?php echo($encryptedpassw); ? target=_blanklink/a


In the destination page (destinationpage.php, on a different server) I have
this:

  $td = mcrypt_module_open ('rijndael-256', '', 'ofb', '');
  $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size($td),
MCRYPT_DEV_RANDOM);
  $ks = mcrypt_enc_get_key_size ($td);
  $key = substr (md5 ('a key fsfqz'), 0, $ks);
  mcrypt_generic_init ($td, $key, $iv);

  /* Decrypt encrypted string */
  $login = mdecrypt_generic ($td, $login);
  $login = trim ($login);
  $password = mdecrypt_generic ($td, $password);
  $password = trim ($password);

  mcrypt_generic_deinit ($td);
  mcrypt_module_close ($td);

  and then an echo($login - $passwordbr); to check if the values are
correct.

But they are not!!
What am I doing wrong?? Is it because both are on a different server?
I would very much appreciate your help. Or if someone has an other good way
of encrypting values, please let me know!

Thanks!!!

Mark.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] sending php page by mail

2001-11-11 Thread Mark Wouters

Hi all,

Description of my problem: i want to sent a newsletter to a mailgroup.
However i also want to be able to see who read the mail at a certain
moment and who didn't. Therefor i thought putting the page online, i.e.
it's a php page which gets its data from the database. By sending a mail
to the client with it's personal emailID, i can track who reads the mail
when accessing the php page.

That part works fine, but my problem now is that i want the page to be
opened directly in the mail, so the receiver of the mail does not have
to click on a link to see it..

Someone told me to use this:
$msg_body = img src='http://www.domain.com/eletters/letters.php?ID=; .
$letterID . emailID= . $sendtoID . ';
But all i get, working like this is a broken image in the mail.
This is the headers i use sending the mail:

$headers .= From: ;
$headers .= $mailfrom;
$headers .= \nReply-To: ;
$headers .= $mailfrom;
$headers .= \nMIME-Version: 1.0\nContent-Type: text/html;
charset=iso-8859-1\n;

Did i forgot something? Is there an other way to do this?

Thank you very much for any answer!

See ya,

Max



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] mail() problem

2001-05-19 Thread Mark Wouters

Hi,

Below the code i use. Everything works, the $mailto variable is buils up
from a database and contains more then one email adresses. Now my
question: how can i make the receivers of my message NOT to see the
email addresses of all the receivers, so then can't reply to all?

$mail =$mailto;
$title =$subject;
$mess = $message;
mail($mail, $title, $mess, From: [EMAIL PROTECTED]\nReply-To:
[EMAIL PROTECTED]\nContent-Type: text/html; charset=iso-8859-1);

Thanks!

--
Mark Wouters
eXpanded Media
Web Designer



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] attachements in mail()

2001-05-19 Thread Mark Wouters

Hi,

I've another question.. is it possible to send attachements with mail()
??

Thanks,

--
Mark Wouters
eXpanded Media
Web Designer
Parijsstraat 74, B-3000 Leuven - Louvain
Tel: +32 (16) 31.10.12
Fax: +32 (16) 31.10.19
E-mail: [EMAIL PROTECTED]
URL: http://www.expandedmedia.be



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] sending attachements with mail

2001-05-19 Thread Mark Wouters

Nobody knows if it's possible to send attachements with mail()??

Thanks,

--
Mark Wouters
eXpanded Media
Web Designer
Parijsstraat 74, B-3000 Leuven - Louvain
Tel: +32 (16) 31.10.12
Fax: +32 (16) 31.10.19
E-mail: [EMAIL PROTECTED]
URL: http://www.expandedmedia.be



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]