I need to create a php webservice to send pdf files to an iPad application. I don't know the number of files, I will be sent a last sync date and web service must send all documents after that date.
If it was only one file, I guess I could do it using headers to set content type but how can I send multiple documents?
Thanks in advance
Zip all the PDF documents after the specified date and bundle using PHP Zip library and send them in the content type as application/zip
From the receiving side, they will unzip and use the documents.
An easier approach might be to merge all the pdfs into one using fpdf.
This would allow the browser to handle display and saving though it does leave the user in the position of having to manage larger files. It really depends on what the data is for as to whether this approach will work.
Related
I am making an app that creates an invoice.
It is created in HTML and PHP using different data from a database.
I need to create a function that converts the page into a PDF and send it to a client.
I can not store it on server as it would mean to create a few hundred everyday. I need something like "http://FreeHTMLtoPDF.com/?convert=".$strBillURL; but it's not working any more.
Many thanks if you can help me!
I prefer to generate PDF files using some library that converts HTML/CSS to PDF. One of the libraries that provides this and is very easy to use is mPDF:
https://github.com/mpdf/mpdf
I have no information regarding what type of PDFs you generate, but in my projects I tend to generate them on the fly from the data in the database and do not store them at all.
There are also other options available for converting HTML to PDF, like wkhtmltopdf, but they might require additional knowledge in set up: https://github.com/wkhtmltopdf/wkhtmltopdf
I am currently trying to get the downloadURL from a response sent via my server of which, whenever $file->getdownloadUrl() is used it returns ['downloadURL'] =>
My question is, is it possible to download Google Documents in the application/vnd.google-apps.document MIME Type?
My assumption is, these would contain a link to the online version of the document, but it would be good to be able to edit the document in the correct format so that any formatting done would be retained when re-uploaded to drive,
Regards,
Nope, you cannot download Google Documents in application/vnd.google-apps.document MIME type. You only can export it to other formats.
Some workarounds:
Apps script Document Services provide a little bit better control over the document, but you won't be able to get full control over all formatting for now.
Export file as known formats such as Microsoft words and edit it. When you upload it back to Drive, you can request to convert it back to Google Docs format. Although you might possibly lose or corrupt with some formatting.
I want to make a web app that can get the values from a commonly used file type (such as xsl or ppt) to allow me to convert it into a custom format (like Google Drive). With an xsl (excel document) file, for example, I want to be able to get the value for each cell. I would be fine getting html for a file (like getting the html code that would display a word document) because values can be extracted out of that. I would like to be able to do it on the client side, but I am okay with using it on the server side with PHP.
Another approach would be to import the file as XML. PHP has great support for XML and could make short work of this. If you can get the files uploaded as Open Doc Format you can parse just about any of the types you listed (XLS, PPT, DOC, etc).
A pretty easy way to get data out of an excel sheet online is to use a Google Apps Script. The process would be a lot to explain here, but with a bit of google searching, you can find all your answers.
As for a PPT, I can't think of an easy way.
As for documents (i.e. pdf, doc, docx), you can use Google Apps Script as well.
Although, if you're making your own tool for this, you may want to just research how the data is stored in the file and work from there.
i've been searching for quite a long now to convert a word document (.doc & .docx ) to pdf.....my application is about taking a word document from clients than converting them to a pdf with added changes ( like header, footer ) to the original document.
Any suggestions are welcomed.
Thank you
Look at http://www.phplivedocx.org/ for converting DOC to PDF.
Example code with nusoap, http://www.phplivedocx.org/articles/using-livedocx-with-nusoap/
You can call the Docmosis Cloud Services from PHP using a http post or curl command. It supports doc and docx imports and pdf outputs. It's more intended to perform document manipulations than conversions but perhaps that suits you even better. Please note I work for the company that created Docmosis.
Hope that helps.
This is a year old, but for people still looking I found a link to a pretty decent api you can look at and see if it works for your needs.
https://cloudconvert.org/page/api#overview
Essentially you use their api and a key they provide when you sign up for an account. Send all the data for conversions to their servers then get the return. You can then store it on your own computer, the users computer, or a server of your choosing. There is some minimal set up and sign up processes and their Github account walks you through pretty easily.
Check it out and hopefully it is a good choice.
We need to install below libraries on server for convert DOC file format to PDF file format:
(Libre Office OR Open Office) and Unoconv librarie
I've used a couple of days to think of a best practice to generate a PDF, which end users can customize the layout for themselves. The PDF output needs to be saved on the server or sent back to the PHP file so the PHP file can save it, and the PHP file needs to know that it went OK.
I thought the best way to do this was to use XML, XSLT and Apache Cocoon. But I'm not sure if this is possible or if it's a good idea since I can't find any information of people doing anything similar. It cannot be an uncommon problem.
The idea came when I read about Cocoon converting XML through XSLT to PDF:
http://cocoon.apache.org/2.1/howto/howto-html-pdf-publishing.html
and being able to take in variables:
http://old.nabble.com/how-to-access-post-parameters-from-sitemap-td31478752.html
This is what I had in mind:
A php file gets called by a user, the php file generates a source XML file with a specific name
The php file then makes a request to Cocoon (on the same web server) to apply the user defined XSLT on the XML file. A parameter will be needed here to know which XSLT to apply.
The request is handled by the PHP file and then saved as a PDF on the server, and can later be mailed away.
Will this work at all? Is there a better way to handle this?
The core problem is that the users need to be able to customize the layout on the PDFs themselves, and I need the server to save the PDF and to mail it later on. The users will use it for order confirmations, invoices, etc. And I wouldn't like to hard code the layout for each user.
I've had some good results in the past by setting up JasperReports Server and creating reports using iReport Designer. They're both available in F/OSS ("community") editions, though you can pay for support and value-adds if you need those things.
This was a good solution for us, since we could access it via the Java API for our Java system, and via SOAP for our PHP system. The GUI designer made tweaking reports very easy for non-technical business staff too.
I use webkithtml2pdf to generate my PDF:s. Just create a document with HTML and CSS for printing like you would usually do, the run it through the converter.
It works great for generating things like invoices. You can use SVG for logos and illustrations, and they will look great in print since they are vector based. Even rounded corners with dotted outlines works perfectly.
A minor gotcha is that the input html must have th htm or html file name suffix, so you can't use the default tempfile functions.