Hi,
I use SOAP like webservice. It's work nice. Now I want to get pdf file from server. I receive a array

    ('filename'=>'test.pdf', 'mimetype'=>'pdf/file', 'content'=>'dhjhfjskjfhksjfhsjfhsfhsdfjhsfj')

How can I read and print the content o the file.

Thanks.
Sorry for my bad english :o)

How can I read and print the content o the file.

$yourArray['content']

Probably contains the binary file. You need to save it before you can open it.

display

header("Content-disposition: inline; filename=$YourArray['filename']");
header('Content-type: application/pdf;');
echo $YourArray['content'];

force save

header("Content-disposition: attachment; filename=$YourArray['filename']");
header('Content-type: application/pdf;');
echo $YourArray['content'];

not tested for pdf
works with images

the mimetype pdf/file is wrong

the above two scraps are used when the pdf is the only thing on the page to be displayed, headers make the page limited in the amount of other data than can be sent, everything is assumed to be encoded pdf

as part of a page, tested,
BUT there is always a but;
Ensure the type of encoding in which the content is sent, and change base64 appropriately

<a href="data:application/pdf;base64,<?php echo $YourArray['content']; ?>"><?php echo $YourArray['filename']; ?></a>

the mimetype is still wrong
If you are accepting multiple mimetypes from the web service, you can always if/else or switch/case through $YourArray['mimetype'] and echo the correct mimetype into the link

sample generated pdf, as html, in the attachment

If you are serving many files from the web service, it would be better to retrieve the file onclick
the page will be huge, +(all files x1.25) if all embedded at once

1 post, no return for a week, not coming back

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.