Issues with pdf image and number format

Topics: Developer Forum
Nov 9, 2009 at 4:57 AM
Edited Nov 9, 2009 at 5:04 AM

I am creating excel files with no problem and only have issues with the pdf output.

I am generating output using csv files, I don't know if this makes any difference when generating pdf output

writer being used with version 1.7.0:

			// redirect output to client browser
    		header("Pragma: public");
    		header("Expires: 0");
    		header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
		header("Content-type: application/pdf");
    		header("Pragma: public");
    		header("Cache-Control: must-revalidate, post-check=0, pre-check=0");		
    		header("Content-Disposition: attachment;filename=$report.pdf");
    		header("Content-Transfer-Encoding: binary ");

		$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcelFromCSV, 'PDF');
		$objWriter->save('php://output'); 

The first problem is when trying to use an image in the pdf.  tcpdf throws an error that it is unable to find the image.  I am using the full path to the image file (same for excel output).  Is there anything different I should do with respect to the image path for pdf output?

The second problem is that the number format FORMAT_USD_SIMPLE is not working.  Looks fine on excel but with pdf output the decimal is missing so $5,687.52 ends up being $568752

The last problem I is that the pdf output is apparently not using the column widths that were set and is wrapping text.  I am setting column widths with:

		$objPHPExcelFromCSV->getActiveSheet()->getColumnDimension('A')->setWidth(10);
		$objPHPExcelFromCSV->getActiveSheet()->getColumnDimension('B')->setWidth(10);
		$objPHPExcelFromCSV->getActiveSheet()->getColumnDimension('C')->setWidth(15);
		$objPHPExcelFromCSV->getActiveSheet()->getColumnDimension('D')->setWidth(15);
	etc...
Is there something different I should do to get the pdf to follow the widths I set?
Developer
Nov 9, 2009 at 5:30 AM

Can you upload 2 files:

1. Sample Excel file that you generated

2. Corresponding PDF file that you generated showing broken number format and wrong column width

Please bundle the two files in a zip archive and upload here:

http://phpexcel.codeplex.com/WorkItem/View.aspx?WorkItemId=10749

Developer
Nov 9, 2009 at 11:21 AM

Hi tomdchi, can you check if you forgot to upload the file?

Developer
Nov 10, 2009 at 4:52 AM

I can reproduce the problem. Let's deal with one thing at a time.

Decimal and thousands separator problem:

http://phpexcel.codeplex.com/WorkItem/View.aspx?WorkItemId=10913

Developer
Nov 12, 2009 at 2:44 AM

With latest source code tomorrow:

http://phpexcel.codeplex.com/SourceControl/ListDownloadableCommits.aspx

Try to put this before the export and see if the problem with decimal/thousands separators disappears.

require_once 'PHPExcel/Shared/String.php'
PHPExcel_Shared_String::setDecimalSeparator('.');
PHPExcel_Shared_String::setThousandsSeparator(',');

Nov 13, 2009 at 6:14 AM

Thousands separator and decimal are now working with latest svn.  I did notice  that in excel output the double underline shows properly but in pdf it shows as a single line.  Not a big deal at all though.

Awesome work!!

Tom

From: koyama [mailto:notifications@codeplex.com]
Sent: Friday, November 13, 2009 12:07 AM
To: tom@rapidach.com
Subject: Re: Issues with pdf image and number format [PHPExcel:74507]

From: koyama

With latest source code tomorrow:

http://phpexcel.codeplex.com/SourceControl/ListDownloadableCommits.aspx

Try to put this before the export and see if the problem with decimal/thousands separators disappears.

require_once 'PHPExcel/Shared/String.php'
PHPExcel_Shared_String::setDecimalSeparator('.');
PHPExcel_Shared_String::setThousandsSeparator(',');

Read the full discussion online.

To add a post to this discussion, reply to this email (PHPExcel@discussions.codeplex.com)

To start a new discussion for this project, email PHPExcel@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com