TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 09-11-2009, 10:21 AM   #1 (permalink)
The Contributor
 
dhaval's Avatar
 
Join Date: Jul 2009
Posts: 37
Thanks: 1
dhaval is on a distinguished road
Default Create pdf

Hi friends,

I am trying to create pdf through php
even i've done all the step which is necessary
before to create pdf file through php
below is my code for creating

$user=$HTTP_POST_VARS['userName'];
$pdf=pdf_new();
pdf_open_file($pdf,'F:\Program Files\xampp\htdocs\Dhaval\Dhaval.pdf');
pdf_set_info($pdf,"Author",'Dhaval');
pdf_set_info($pdf,'Title','All Rounder');
pdf_set_info($pdf,'All Rounder','Dhaval');
pdf_set_info($pdf,'subject','Success');
pdf_begin_page($pdf,595,842);
$arial=pdf_findfont($pdf,'Arial','host',1);
pdf_setfont($pdf,$arial,14);
$jpg_image=pdf_open_jpeg($pdf,'chess-en.jpg');
pdf_place_image($pdf,$jpg_image,200,300,1.0);
pdf_close_image($pdf,$jpg_image);
pdf_end_page($pdf);
pdf_close($pdf);
echo "<a href='F:\Program Files\xampp\htdocs\Dhaval\Dhaval.pdf'>Open PDF in new window</a>";

but it shows below error

Fatal error: Uncaught exception 'PDFlibException' with message 'Metrics data for font 'Arial' not found' in F:\Program Files\xampp\htdocs\Dhaval\pdf_file.php:10 Stack trace: #0 F:\Program Files\xampp\htdocs\Dhaval\pdf_file.php(10): pdf_findfont(Resource id #2, 'Arial', 'host', 1) #1 {main} thrown in F:\Program Files\xampp\htdocs\Dhaval\pdf_file.php on line 10

so please help me to solve it.
dhaval is offline  
Reply With Quote
Old 09-11-2009, 02:12 PM   #2 (permalink)
The Acquainted
 
Randy's Avatar
 
Join Date: May 2007
Location: Your G/F's Closet
Posts: 114
Thanks: 7
Randy is on a distinguished road
Default

Now i am not the best coder myself so I may be wrong if so somebody else please correct me but im going to do my best here.

Looking at the error its the font that is missing meaning that the script is unable to find the fonts that you listed here:

PHP Code:
$arial=pdf_findfont($pdf,'Arial','host',1); 
For font be sure to have something included like this:

PHP Code:
// Locate Font Directory
$fontdir "C:\WINDOWS\Fonts";
// Font Name Parameters
pdf_set_parameter($pdf"FontOutline""arialMyName=$fontdir\arial.ttf");
// Find Font
$arial PDF_findfont($pdf,"arialMyName","host",);
// Set font size and font name
pdf_setfont($pdf$arial10); 
Note: Credit for my given code goes to the php manual located here.

Cheers,
Randy
__________________
Real Programmers always confuse Christmas and Halloween because Oct31 == Dec25 - Andrew Rutherford

Last edited by Randy : 09-11-2009 at 02:15 PM. Reason: Added php.net credit
Send a message via AIM to Randy Send a message via MSN to Randy
Randy is offline  
Reply With Quote
The Following User Says Thank You to Randy For This Useful Post:
dhaval (09-11-2009)
Old 09-11-2009, 02:33 PM   #3 (permalink)
The Contributor
 
dhaval's Avatar
 
Join Date: Jul 2009
Posts: 37
Thanks: 1
dhaval is on a distinguished road
Default

Hi,
First of all Thanks for your help
actually exactly what I want to do is
make pdf of FCKeditor's value
well now made pdf but how to get FCKeditor's
value and make its pdf
so, please help me to fix it out.

Thanks in advance
dhaval is offline  
Reply With Quote
Old 09-11-2009, 03:34 PM   #4 (permalink)
The Acquainted
 
Randy's Avatar
 
Join Date: May 2007
Location: Your G/F's Closet
Posts: 114
Thanks: 7
Randy is on a distinguished road
Default

Glad that part helped there and for the getting FCKeditor to work should be quite simple.

To do that you just take your FCKeditor form field set the name of it set the form to GET or POST which ever you prefer, create a variable with it and then use the pdf_show command.

Something like this.
Note: this is quick it would be easier to help with your fckeditor code

Top of the page that your form goes to (what the action="" goes to)
PHP Code:
$text $_GET['fckeditor_field']; 
Then for when you create the pdf something like this should work.

PHP Code:
pdf_show($pdf$text); 
or if you want there is the pdf_show_xy
PHP Code:
pdf_show_xy($pdf$textXLOCYLOC); 
basically that one lets you define locations for using the x and y axis numbers.

Hope that helps, if not just post your code and im sure me or some other members can help.
__________________
Real Programmers always confuse Christmas and Halloween because Oct31 == Dec25 - Andrew Rutherford
Send a message via AIM to Randy Send a message via MSN to Randy
Randy is offline  
Reply With Quote
Old 09-12-2009, 06:36 AM   #5 (permalink)
The Contributor
 
dhaval's Avatar
 
Join Date: Jul 2009
Posts: 37
Thanks: 1
dhaval is on a distinguished road
Default

Hi,
Thanks again for your valuable reply
with your help the problem has been solved :)
but still something remains i want to put image also
in pdf but it doesn't show.
what to do?
dhaval is offline  
Reply With Quote
Old 09-12-2009, 07:17 AM   #6 (permalink)
The Acquainted
 
Randy's Avatar
 
Join Date: May 2007
Location: Your G/F's Closet
Posts: 114
Thanks: 7
Randy is on a distinguished road
Default

to do that basically do the same as with fckeditor, create the variable (same command in the other post simply change the name of the field and variable name as image)

and use the following:

PHP Code:
pdf_fit_image($pdf$image$x$y); 
here is what each does, note i did not include the string.
Quote:
pdf_fit_image(resource, int, float-x, float-y, string)
string basically lets you modify the image such as string etc..

Read the manual at the following link if you want some help with the string, that is not my cup of tea.
http://us3.php.net/manual/en/function.pdf-fit-image.php

Glad to be helping :D
__________________
Real Programmers always confuse Christmas and Halloween because Oct31 == Dec25 - Andrew Rutherford
Send a message via AIM to Randy Send a message via MSN to Randy
Randy is offline  
Reply With Quote
Old 09-12-2009, 08:34 AM   #7 (permalink)
The Contributor
 
dhaval's Avatar
 
Join Date: Jul 2009
Posts: 37
Thanks: 1
dhaval is on a distinguished road
Default

hi,
it doesn't work yar
i think it can't get the right path
cause when i tried to echo image it doesn's show
and fatal error comes like below

Fatal error: Uncaught exception 'PDFlibException' with message 'pdf_fit_image() expects parameter 2 to be long, string given' in F:\Program Files\xampp\htdocs\Dhaval\cpdf1.php:62 Stack trace: #0 F:\Program Files\xampp\htdocs\Dhaval\cpdf1.php(62): pdf_fit_image(Resource id #2, 'F:\Program Files\xampp\htdocs\Dhaval\cpdf1.php on line 62

:(
dhaval is offline  
Reply With Quote
Old 09-12-2009, 08:37 AM   #8 (permalink)
The Contributor
 
dhaval's Avatar
 
Join Date: Jul 2009
Posts: 37
Thanks: 1
dhaval is on a distinguished road
Default

if you don't mind, may i have your gmail ID so we can chat and i can show you exactly what i did
dhaval is offline  
Reply With Quote
Old 09-12-2009, 06:19 PM   #9 (permalink)
The Acquainted
 
Randy's Avatar
 
Join Date: May 2007
Location: Your G/F's Closet
Posts: 114
Thanks: 7
Randy is on a distinguished road
Default

I have sent you a pm with my gmail id.
__________________
Real Programmers always confuse Christmas and Halloween because Oct31 == Dec25 - Andrew Rutherford
Send a message via AIM to Randy Send a message via MSN to Randy
Randy is offline  
Reply With Quote
Old 09-12-2009, 07:06 PM   #10 (permalink)
The Acquainted
 
Randy's Avatar
 
Join Date: May 2007
Location: Your G/F's Closet
Posts: 114
Thanks: 7
Randy is on a distinguished road
Default

Alright, in my pm said i'd be busy all day which is true but im taking a break right now and found out what you have to do.

you have to use the pdf_open_image_file first to open the image file then you use the pdf_fit_image.

PHP Code:
pdf_open_image_file($pdf$imagetype$filename$string$intparam); 
variables are defined in order below:
resource, imagetype (gif, jpg, png, etc..), name of image, string type, int

can't really explain much cause you basiccaly just stick that in between the information given above as far as i can tell, plus i have never input an image im running with the php manual.
__________________
Real Programmers always confuse Christmas and Halloween because Oct31 == Dec25 - Andrew Rutherford
Send a message via AIM to Randy Send a message via MSN to Randy
Randy is offline  
Reply With Quote
Old 09-20-2010, 10:57 AM   #11 (permalink)
The Visitor
 
Join Date: Sep 2010
Posts: 1
Thanks: 0
pcsimke is on a distinguished road
Default

$slika = pdf_load_image($pdf,"gif","D:\\xampp\\htdocs\\teli me.gif","");


path needs to look somthing like this D:\\xampp\\htdocs\\telime.gif


note the \\

this worked for me
pcsimke is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create a gallery class Tanax Advanced PHP Programming 25 02-19-2013 04:25 AM
How to create back up ? digitak Advanced PHP Programming 10 05-03-2009 02:03 PM
Create your own advanced WYSIWYG editor almsamim Javascript, AJAX, E4X 8 10-23-2008 06:41 PM
How easy is it to create RSS feeds? Brook Absolute Beginners 4 02-03-2008 08:10 PM
Need your feedback Tanax Absolute Beginners 29 10-11-2007 04:50 PM


All times are GMT. The time now is 11:15 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design