Pass PDF to User from Web Service |
[eluser]bernie145[/eluser]
Hello all, I'm working on a site that allows students to sell books to us and print shipping labels to ship the books. I have the FedEx API working to accept the user and item data, create a label, and save the label as a pdf file in an application/labels folder. My question is, is there a way to have the controller that talks to the API and gets the label pass it straight to the user? Right now, the user clicks on a "print your label link" which calls the fedex/create_label function, but the only thing I've been able to figure out is to then load another view (print_shipment_view) that has a link to the actual label. This seems like an extra step to me. Shouldn't there be a way to open the pdf that was generated directly from the controller? Not sure if you need to see any of this or not... Code: $response = $client->processShipment($request); // FedEx web service invocation
[eluser]Aken[/eluser]
Easy way would be to set PHP headers to display/download the PDF file after you've written it. A quick example of that is on the PHP manual page for header(): http://php.net/manual/en/function.header.php Alternatively, you could use PDF generation code to create a PDF file straight from the $response->...->Image resource instead of using fwrite() and such, then display/download it using the same headers from above. If you're having a hard time finding solutions based on those recommendations, let me / us know and we'll help some more.
[eluser]bernie145[/eluser]
Aken, Thank you! That's exactly what I was looking for. Working Code... Code: if ($response->HighestSeverity != 'FAILURE' && $response->HighestSeverity != 'ERROR')
[eluser]russ_kern[/eluser]
Seems like you are good to go, but as an option, I've been using fPDF to allow a user to create custom sellsheets out of a Code Ignitor App. It's an old library, but may be worth a look sometime... and it's opensource. R |
Welcome Guest, Not a member yet? Register Sign In |