I am currently working on a web2print project based on Adobes Scene7. The full url to a print product (pdf) is very long and exceeds all browser limitation of url length. So to get the final print product I assume I have to submit the url in a different way via POST method.
There seem to be two ways: First, use a html form (method=post) and create all url parameters as (hidden) input fields. Second, make an ajax call (e.g. jQuery.ajax) with post.
Actually if I would open the print url in the browser, the ready pdf would be opened within the browser. So I need a way to send the very long url via POST to the server and open the PDF I get back from it. Testing the ajax version I ran into the same-origin-policy and get an error, as I call a url not on my local server. This must be a standard situation in web2print projects, how is this handled?
Thx in advance
Michbeck
I got the problem solved. I did it in two steps. First I use ajax to send the base url and the url parameters to a php script on my local server. It is easily done with jQuery:
The server script uses cURL to send the data to the final server. Therefore the base url and the parameters are not posted as one url but seperated by the use of CURLOPT_POST and CURLOPT_POSTFIELDS. The server response (a pdf) can be written to file with file_put_contents. If the PDF gets to big, you will get a memory limitation error here. Than it is better to write the answer from cURL directly to the pdf file.