I have just toiled for a few days on receiving an xml file through http post and then removing the embedded cdata tag and processing the data to create a pdf file. I have managed to create the file, but am unsure on how to get it to open in adobe acrobat from a php link. Basically when the user clicks a button data is sent to retrieve the clients credit report, the data is returned in an xml file with the embedded pdf within the file. My question is that when the user clicks the button and everything is done processing how can I get the newly created pdf file to open in adobe for the user to view? I tried a hyperlink starting with <a href="file://filelocation> but it tries to first open the file in internet explorer then gives the error that the version of adobe we are using can't display pdfs in the browser (which is a lie because it works in another application we use) but then after you click ok, adobe opens up the file. How can I skip the middle portion where IE tries to open the file?
If the mime type of the page is application/pdf then the browser should ask whatever program is set to open pdf's to open the link. However you may find that some browsers can display pdf natively, so these will not open another program.
Assuming the pdf is using a .pdf extension then the mime type should be picked up from that. However if you are serving this as xml then the mime type will not be application/pdf. You could always try forcing a download. There are a load of scripts on this forum and the web that will help with force download.
Do you need to have the pdf embedded in xml? Or could you serve it directly?
I'm actually pulling the pdf out of an xml file from an http post response. i have went the route of trying to force a download so the user can download or open in adobe, the issue is that when you click open it says it can't find the file, but you can save it and everything works fine. Whats weird is that it was working until I had to change a config parameter in my php.ini file to turn off the mbstring.dll, because it was causing issues in other areas of my web app(though I don't know why). Ever since I turned that off the "open" option doesn't work when the dialog pops up. Here's the code I have so far: [php] $file = $PDFName; $path = "CreditReports/".$PDFName; $fr = fopen($path, 'r'); $filedata = fread($fr, filesize($path)); fclose($fr);
This was the original code that was working in whole until the config change, since then I've tried subbing /pdf in the content-type: statement but no change in the end result. I echoed out $path and its the correct place where the pdf file is created after pulling the data out of the xml file. Any idea on what would keep this code from working after that config change?