This is an archived forum post. The information may be outdated. Contact us if you have any
Dynamic HTML Page
wrote on 2016-02-23:
I have a page which uses JS to generate dynamic content based on what the user inputs. Once complete, I would like to save it to PDF. I couldn't find a whole lot of documentation on this so I'm using PHP Object Buffering to save the completed HTML to the server, then pdfcrowd to generate a PDF from the recently saved file. I'm not sure if this is proper but it works WHEN I use two separate buttons, one to generate the HTML file and another to call the PHP code like below.
If I understand your scenario correctly I would go about it like this:
1/ use JS to generate dynamic content from the user's input 2/ POST the generated content to your server 3/ on the server, post the content to our API and receive PDF 4/ send the generated PDF back to the browser
Hope this helps.
wrote on 2016-09-20:
@achristmann Did you ever find a resolution to this? I also had a similar issue.
I was able to generate the PDF by passing the html value via POST, then writing that value to a static file. First I grabbed the html via jQuery, then set a hidden input value to the html that was just grabbed. Then once the value is set I passed it to a PHP file, which would take the variable and write that to a static text file. The PDF crowd API is then able to handle creating the PDF from that static text file.
The problem I run into comes after that. I can open the PDF in the browser - Firefox and Chrome seem to accept the PDF just fine. However I can't open the PDF in Acrobat or Photoshop.
Unfortunately, that's exactly what I need to do with it. It needs to be added to another PDF, but if I can't open it I can't edit it.
Anyway, I think it has something to do with the headers, but everything is setup the way the PDFCrowd API documentation shows. So I don't know.
If anybody has found a solution to this it would be very helpful if you could share it here. Thanks!