 |
Account Login
|
 |
 |
Latest Articles
|
 |
 |
IRC Channel
|
 |
 |
Associates
|
 |
 |
Associates
|
 |
|
 |
 |
|
 |
09-11-2009, 10:21 AM
|
#1 (permalink)
|
|
The Contributor
Join Date: Jul 2009
Posts: 37
Thanks: 1
|
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.
|
|
|
|
09-11-2009, 02:12 PM
|
#2 (permalink)
|
|
The Acquainted
Join Date: May 2007
Location: Your G/F's Closet
Posts: 114
Thanks: 7
|
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",0 ); // Set font size and font name pdf_setfont($pdf, $arial, 10);
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
|
|
|
|
The Following User Says Thank You to Randy For This Useful Post:
|
|
09-11-2009, 02:33 PM
|
#3 (permalink)
|
|
The Contributor
Join Date: Jul 2009
Posts: 37
Thanks: 1
|
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
|
|
|
|
09-11-2009, 03:34 PM
|
#4 (permalink)
|
|
The Acquainted
Join Date: May 2007
Location: Your G/F's Closet
Posts: 114
Thanks: 7
|
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, $text, XLOC, YLOC);
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
|
|
|
09-12-2009, 06:36 AM
|
#5 (permalink)
|
|
The Contributor
Join Date: Jul 2009
Posts: 37
Thanks: 1
|
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?
|
|
|
|
09-12-2009, 07:17 AM
|
#6 (permalink)
|
|
The Acquainted
Join Date: May 2007
Location: Your G/F's Closet
Posts: 114
Thanks: 7
|
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
|
|
|
09-12-2009, 08:34 AM
|
#7 (permalink)
|
|
The Contributor
Join Date: Jul 2009
Posts: 37
Thanks: 1
|
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
:(
|
|
|
|
09-12-2009, 08:37 AM
|
#8 (permalink)
|
|
The Contributor
Join Date: Jul 2009
Posts: 37
Thanks: 1
|
if you don't mind, may i have your gmail ID so we can chat and i can show you exactly what i did
|
|
|
|
09-12-2009, 06:19 PM
|
#9 (permalink)
|
|
The Acquainted
Join Date: May 2007
Location: Your G/F's Closet
Posts: 114
Thanks: 7
|
I have sent you a pm with my gmail id.
__________________
Real Programmers always confuse Christmas and Halloween because Oct31 == Dec25 - Andrew Rutherford
|
|
|
09-12-2009, 07:06 PM
|
#10 (permalink)
|
|
The Acquainted
Join Date: May 2007
Location: Your G/F's Closet
Posts: 114
Thanks: 7
|
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
|
|
|
09-20-2010, 10:57 AM
|
#11 (permalink)
|
|
The Visitor
Join Date: Sep 2010
Posts: 1
Thanks: 0
|
$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
|
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|