I have s problem with PDF

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
fastfingertips
Forum Contributor
Posts: 242
Joined: Sun Dec 28, 2003 1:40 am
Contact:

I have s problem with PDF

Post by fastfingertips »

I'm using ghostscript to merge 1 or more pdf files into a big one but when i'm trying to display the output i'm getting only
strange characters. I mention that the file is created and looks ok on server, but in browser is dust.

My code looks

Code: Select all

exec($createPdf);																			
$len = filesize($tmpfname);
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=SelectedOrders".$_POST['pdfExt']);						
readfile($tmpfname);
unlink($tmpfname);
exit();

The output looks like:

[quote]
%PDF-1.3 %Çì
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

General Discussion is not for coding questions..

Moved to PHP - Code.
fastfingertips
Forum Contributor
Posts: 242
Joined: Sun Dec 28, 2003 1:40 am
Contact:

Post by fastfingertips »

Anyone any idea please?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

The correct file is created yes? But when it's downloaded like that in the browser it's failing? :? Unless the created file isn't PDF that looks right to me.

You haven't got some whitespace above that code have you? That could mess things up with your headers.
fastfingertips
Forum Contributor
Posts: 242
Joined: Sun Dec 28, 2003 1:40 am
Contact:

Post by fastfingertips »

I resolved.

In an included file (create by my team) someone inserted a space before php tag, and because of that
the header was changed to html. Since all my errors where disabled i had to make a research first :).
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Glad you got it sorted :D
Post Reply