Q: I am looking at Qoppa’s Web PDF Markup module to use in my web application. I see that PDF file always should exist in the PDF Automation Server to be opened in the Web application using iframe. PDF files are stored in our own server and users need to open the files, manipulate them and then save them back to the same storage server. Is there a way to integrate the PDF Automation Server with the existing server container?
A: You are right that the PDF files have to be present on the server so that the server can convert them to HTML and further, incorporate any annotations back into the PDF.
If your PDFs are stored in some other system, you will need to have proxy scripts that on one side receive and respond to messages from the browser, and on the other side, interact with the PDF Automation Server to relay the messages and manage files.
For instance, if a message comes in from the browser to get a PDF (as HTML), the message would be sent to your script which then does a PUT of the PDF to the PAS (PDF Automation Server) server, requests the PDF content as HTML and then passes this back to the client browser.
Here is a sample PHP script using CURL doing that:
# initialize curl request to PUT the PDF file to the server $ch = curl_init("http://localhost:8090/qoppapdf/v1/documents/test01.pdf"); curl_setopt($ch, CURLOPT_PUT, 1); # the file that we will send to the server $file_path_str = 'c:/qoppa/auto/test01.pdf'; $fh_res = fopen($file_path_str, 'r'); # set curl options curl_setopt($ch, CURLOPT_INFILE, $fh_res); curl_setopt($ch, CURLOPT_INFILESIZE, filesize($file_path_str)); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/pdf', 'Connection: Keep-Alive')); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); # send the file to the server and close file handle $curl_response_res = curl_exec ($ch); fclose($fh_res); # get the file in HTML format and send it back to the client $ch = curl_init("http://localhost:8090/qoppapdf/v1/documents/test01.pdf/content"); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: text/html', 'Connection: Keep-Alive')); curl_exec($ch); |
Once any annotations are added to the PDF, the proxy script would pass these through to PAS, then get the modified PDF and store it back into your storage server.