![]() |
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. |
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:
PHP Code:
Cheers, Randy |
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 |
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:
PHP Code:
PHP Code:
Hope that helps, if not just post your code and im sure me or some other members can help. |
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? |
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:
Quote:
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 |
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 :( |
if you don't mind, may i have your gmail ID so we can chat and i can show you exactly what i did
|
I have sent you a pm with my gmail id.
|
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:
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. |
$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 |
| All times are GMT. The time now is 02:26 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0