how can get the FPDF library - php

i have found some pdf file geneartion program in php. When i run it i get the following error Warning:
Warning: include(helveticab.php) [function.include]: failed to open stream: No such file or directory in E:\wamp\www\raj19\fpdf.php on line 789
Warning: include() [function.include]: Failed opening 'helveticab.php' for inclusion (include_path='.;C:\php5\pear') in E:\wamp\www\raj19\fpdf.php on line 789
FPDF error : Could not include font metric file
I think the fpdf.php is missing .I have searched on their site but i could not find the english version. can anyone provide me full link of english version?

helveticab.php is a font definition file, which is shipped with FPDF. Get it here:
http://www.fpdf.org/

Since your code is not able to locate font library, add this line to your code.
define('FPDF_FONTPATH','fpdf/font/');

All you have to do is to copy the entire folder, and check for "fonts" one. Go inside and search for the file you're looking for.
If nothing works. Try with $font = 'fonts/arial.ttf'; and in the "fonts" folder put the TTF file. If you don't know where to get it. Search in your explorer "fonts" and get the TTF file by dragging it to the fonts folder or copying it.
If doens't works, copy the code line where you're trying to call the font file.

Depends on where the library is in the root directory. if Is in the same place just use
$str = 'fpdf.php';
require($str);
if your output is in a directory called fpdf and your php output is in another directory i.e. mydoc, you need to go up one step
$str = '../fpdf.php';
if your php output is down 2 steps i.e. root/myfolder/mydoc/output.php then you need to up two steps $str = '../../fpdf/fpdf.php'; i'm assuming that you have your fpdf library in the folder root/fpdf/fpdf.php

Related

PHP Excel 01simple-download-xlsx.php and 07reader.php giving different output

I am trying to run 2 example of PHPExcel
01simple-download-xlsx.php and 07reader.php
01simple-download-xlsx.php Working Perfect but this example 07reader.php is showing error mentioned below Why can't understand since last 4 hours.
Any one can kindly tell me why this is happening when the file is using same directory structure.
Warning: require_once(../Classes/PHPExcel/IOFactory.php): failed to
open stream: No such file or directory in
C:\xampp\htdocs\manazeschool\software\office_admin\exam_excel\Examples\07reader.php
on line 37
Fatal error: require_once(): Failed opening required
'../Classes/PHPExcel/IOFactory.php'
(include_path='.;C:\xampp\php\PEAR') in
C:\xampp\htdocs\manazeschool\software\office_admin\exam_excel\Examples\07reader.php
on line 37
Some of the examples (such as the 01* files) correctly use an absolute pathname __DIR__ . '../Classes/...' to include the main PHPExcel library, which means you don't need to be in the /Examples directory to run them.
Other examples (07reader.php included) simply use a relative pathname '../Classes/...'to include the main PHPExcel library, which means you do need to be in the /Examples directory to run them.
To resolve the issue, either ensure that you're in the /Examples folder when you run these files, or modify the include to use the absolute pathname.
I believe I've now fixed all of these example files to use the absolute pathname in the development branch on github.

FPDF error "Unable to create output file"

I'm working with fpdf libray for providing pdf files. A part of my project consists of using this library to generate pdf files for consumers.
We are working with a server test under "ovh". The arborescence of my space in "ovh" is : /www/betatest.
A folder named upload which contains factures's folder where all the facture's pdf files will be there.
So, when i try to generate a pdf file inside the factures folder, in a web browser it displays me :
Warning: fopen(upload/factures/facture_98.pdf) [function.fopen]: failed to open stream: Success in /homez.742/coplayer/www/betatest/library/fpdf/fpdf.php on line 1025
FPDF error: Unable to create output file: upload/factures/facture_98.pdf.
I tried a lot of things that i found in this web site but does not work.
Please help me. Thank's a lot! :)
Make sure the directory have at least a 755. Also, use $_SERVER['DOCUMENT_ROOT'] with your path to target the good directory :
$nomFacture = $_SERVER['DOCUMENT_ROOT']."upload/factures/facture_".$idFacture.".pdf";
That will produce something like
/homez.742/coplayer/www/betatest/upload/factures/facture_12.pdf
Make sure you have not sending to output something else (like echo, var_dump, etc.) before generating PDF with Output("path_file", "F"). It is mandatory.
make sure that file upload/factures/facture_98.pdf is not open anywhere when you run script. if it's open somewhere else then TCPDF can't open it.

Using FPDF error with font helveticab.php

Im attempting to use FPDF, on Windows and using the XAMPP server.
I keep running into this error:
Warning: include(helveticab.php) [function.include]: failed to open stream: No such file or directory in C:\xampp\php\PEAR\fpdf.php on line 541
Warning: include() [function.include]: Failed opening 'helveticab.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\php\PEAR\fpdf.php on line 541
FPDF error: Could not include font metric file
Anyone have an idea of how this can be resolved?
Also, I have checked and helveticab.php is installed which is the answer given in similar questions that i looked at.
Thanks
Not sure why they did it, but if the font is "Arial" they change the font to Helvetica. One of the styles is "c". They append the style to the font, so it searches and adds the fonts and styles. Example is helvetica bold is helveticab, or helvetica italic bold is helveticabi, but helveticac does not exist. To circumvent this, I added the following lines in fpdf.php at around line 498. If the style is "c", we set the style to "":
Code the already have
// Test if one of the core fonts
if($family=='arial')
$family = 'helvetica';
Code I added:
if(stripos($style, "c")!==false)
$style='';
I encountered the same problem but what solves it was I uploaded a folder in the program folder with name font. inside the font folder, I added the following files:
helveticab.php, helvetica.php, helveticabi.php, helvetica-extracompressed.ttf, and helveticai.php
Font folder can be downloaded from https://github.com/Setasign/FPDF.
Just download all the files in https://github.com/Setasign/FPDF/tree/master/font and add them to your application.
Try to use another font instead of Arial as like : Helvetica
Hope this will solve the problem :)

adding own library in drupal

i want to include a php file .module file like this using hook_init
function drupsocial_init() {
require_once base_path().(drupal_get_path('module', 'drupsocial') . '/libraries/dsinvoke.php');
}
but showing this error
Fatal error: require_once() [function.require]: Failed opening required '/drupal6/trunk/sites
/all/modules/drupsocial/libraries/dsinvoke.php' (include_path='.;D:\xampp\php\PEAR') in D:\xampp\htdocs
\drupal6\trunk\sites\all\modules\drupsocial\drupsocial.module on line 32
how can i include such file
You normally can include any file if you know the full path of the file and the file is accessible. Check the path to the library, correct it and you should not have any problem.
Start with the full path to the file first. If that works, you can think about using a dynamic path to the file.
why drupal trying to load the file in the trunk directory ? are you working on a svn repo ? i think there's something wrong with that path.
I also suggest you to check permissions
Hope this helps

dompdf with codeigniter

I followed this tutorial:
https://github.com/EllisLab/CodeIgniter/wiki/PDF-generation-using-dompdf
However, I can't seem to set the path right. On the config file of dompdf (config_dompdf.inc.php) I did the following:
define("DOMPDF_DIR", realpath(dirname('./system/plugins/dompdf/')));
I get this error:
Message: require_once(/var/www/myApp/system/plugins/include/functions.inc.php) [function.require-once]: failed to open stream: No such file or directory
Filename: dompdf/dompdf_config.inc.php
Line Number: 233
As per the tutorial, I placed the dompdf directory under system/plugins. But you can see above that on line 233, there is an error because of an incorrect path. How do I fix the path?
(define("DOMPDF_DIR", realpath(dirname('./system/plugins/dompdf/')));)
Thanks!
A custom loader that is on autoload is conflicting with DOMPDF, that's the reason it doesn't work. Switched to TCPDF since the custom loader is used by all controllers of the app.
this file take $_GET['input_file'] as the name of the file that should be converted to pdf
http://localhost/dompdf/dompdf.php?input_file=[nameofyourfile]
You only need to change the value of DOMPDF_DIR if you have moved dompdf_config.inc.php from its usual location in the dompdf directory. Otherwise, dompdf is already set up to populate that constant with the correct path. Based on the information you have provided I do not believe you should have modified the default value.

Categories