hey all,
is there any way to convert a given file (this could be of any type) in to a pdf file in .net or php?
eg: suppose there is a upload link to upload your file of any type(word,excel,autocad,images..) and once the upload button is clicked the uploaded file should be converted into a pdf.
i checked out fpdf.but according to my knowledge all file types cannot be converted.a module to plugin to the CMS would also be fine.
FPDF does support images. I know because I have used it recently.
If you are wanting a pure PHP solution, you can use the PHP COM functions along with Word or Excel on the server to open up those files then copy the data out.
If I were you though, I would use Google. Load the doc into Google Docs then export it as a new format with the API.
There are a couple of 3rd party solutions available such as this one, which is optimised for use on the server and accessible from any web services capable environment, including .net. Supports loads of file types including MS-Office based documents.
Disclaimer, I worked on this product so consider me biased. Having said that, it works very well.
Related
I just want to ask if there are any free/opensource or are there even any existing PHP class library that can convert HTML to PHP using the tags as its image source?
Because I have created a web app that contains Google Maps in it and now I want to save the generated map, instead of saving it using printscrn I would like to convert it to PDF. Is it even possible?
Can you give me guys a link to the library if ever there are existing ones?
I have already looked for fpdf and tcpdf but on their examples all images is contained on the file directory.
Thanks
There is the library HTML2PDF (on github) licensed under LGPL. It is based on TCPDF and very easy to use.
I have tried and successfully converted html to pdf using wkhtmltopdf[1] binary sometime back (including images).
Download wkhtmltopdf binary which is compatible to your base server o/s and use a php wrapper class similar to this[2] (i haven't tested this wrapper class[2] but it should serve your purpose)
There are plenty of php wrappers available for wkhtmltopdf binary, so you can find one easily if this[2] didn't work well for your purpose.
[1] http://wkhtmltopdf.org/
[2] http://mikehaertl.github.io/phpwkhtmltopdf/
I am working on a PHP web application which programatically generates some DOCX files.
I want these files to be converted to PDF, but their layout is so complex that not any PHP-PDF generator library (domPDF, TCPDF, etc.) works well. They result in a poorly formatted PDF in each case.
In this situation, I have decided to let Google Drive do the conversion. For this, I have to:
Upload the DOCX files to GDrive
And then export them in PDF...
I have seen all of the GDrive API documentation, but it is very poorly documented. I only want to execute one single PHP script which:
Uploads the file to GDrive
Downloads its exported PDF version
Lets the PDF be downloaded when the script is finished...
I am searching for the optimal way to achieve this behaviour... (with or without GDrive, since the LibreOffice/Openffice CLI command is not an option because I am on a web hosting and I can't install any software...).
Have you considered using a file conversion service to do this for you ?
For complete transparency I work for Zamzar (an online file conversion website), we have recently released a developer API - https://developers.zamzar.com/ that would allow you to convert your DOCX files to PDF with little or no loss of formatting.
This would then eradicate your need to convert your file(s) using the Google Drive API. Check out our fairly extensive docs here - https://developers.zamzar.com/docs.
What I'd like to do
I'd like to allow a user to download a dynamically generated pdf file (certificate). I was thinking of creating a pdf template and just write the user's name on it with PHP, that's the only thing that will be dynamic about this.
How I'd like to do it
Since the application is for a client and I have no idea on what server will he use it I'd like to know if there are ways of achieving this without any extra extensions or whatsoever to be installed on the server. I can assume he has PHP > 5.
Basically read the template pdf and write a string to it then save it to be able to offer for download, all this with PHP?
doing this with pure php on your own will get very messy, so i recommend using FPDF in combination with FPDI (to open your templates). both can easily be added to your projects sources, so you don't need to install any extensions (unless you want to compress your PDFs - in that case you'll need zlib installed).
What is, according to you, the best way to convert uploaded files of any kind (.doc, .docx,...) into a pdf-file using nothing but php. Is it even possible to do so?
I looked at FPDF, but this creates the pdf files from text.
An other solution previously given was to use the PDFlib library on your server, but unfortunately, my server doesn't support this library...
What is the best way to convert to files my users upload on my site to pdf files?
A simpler approach would be to restrict uploads to .PDF format programmatically and require your users to only upload .pdf files. Provide a link on the upload page to a free and open source pdf printer (e.g. Cuteftp) that the user can install to create .pdf documents from any file that can be printed.
Trying to do it through PHP will be problematic because the uploads could be generated from many different programs that would be impossible to cater for in their entirety. e.g. How would it handle Scribus or ABC Flowcharter or any other 'non-standard' application someone used to create a document?
Much better to filter the upload upfront.
The best server-side PDF generator from those I tried was, so far, wkhtmltopdf, a WebKit-based, self-contained invisible browser that can render any HTML+CSS and generate a PDF from it. Reasonably fast and fairly reliable, has some useful PDF options, such as page size, orientation, etc.
The second part of the job in your case is to convert documents to HTML prior to feeding them to wkhtmltopdf. If possible, have your users upload the docs in HTML (Word and Co. can export (crappy) HTML). If this is not an option, you will have to find a tool just for that, which, in my opinion, is much easier than finding a tool that converts Word docs directly into PDF.
Good thing about wkhtmltopdf is also that you can feed the output of your PHP script to it using the ob_xxx() functions.
PHP Excel best simple way to create doc, docx, xls, xlsx, pdf files with PHP. Its lot easier with clear documentation.
Use Microsoft Office to render Microsoft Office documents, if you care about accuracy at all. This is easily done by invoking Office over COM.
Get access to your server, and install what you need. Doing so would be far easier than monkeying around with sub-par solutions.
Well... I can think of one way of doing it quite easily, but it doesn't involve using PHP.
Upload your documents to a folder on your server, that are browsable by your users.
EG: http://mysite.com/docs/
Then get your users to install a virtual printer driver such as Primo PDF
http://www.primopdf.com/index.aspx
then they can load the document into their browser, and print to PDF for offline browsing.
If this is not an option, and your dealing with office documents that conform to the openXML standard, you could attempt to parse the XML doc into a PHP page for display in the browser, then use JavaScript to trigger a print.
Unfortunately, it does still depend on your user having a PDF printer installed.
Alternatively, you could just load the docs natively, and print to your own PDF printer, then upload the PDF's to the web server for download.
I can't think of any easy way of doing this otherwise, without installing all sorts of different document parser tool-kits and doing a huge amount of behind the scenes work.
Anyone know of any Flash components that would do the job of displaying an external PowerPoint file (e.g. .PPT, .PPTX) file in a Flash movie on a web page? Or a way of automatically parsing uploaded PowerPoint docs from a PHP-based CMS and displaying them on a web page.
Our client needs to be able to upload a PowerPoint documents on their site without any intervention (if necessary).
I know about Slideshare and the like, but the content needs to live on the client's web server due to security restrictions. Also, Adobe Presenter seems to require Adobe software/plugins on the clients machine which wouldn't be ideal.
You could use Google Docs. It supports previewing PDF/PPT/DOC (Don't know about XLS) files.
I use it on one of my projects and it behaves very well.
You can call it using http://docs.google.com/gview?url=<your absolute file url here>
you could also use the embed=true parameter to embed it into your site, using an iframe or that sort of thing.
Hope this helps.
Using COM you can save a PPT as a PDF (see this question), and then use swftools' great (and free) pdf2swf utility to get nice swfs.
You can use http://ajaxdocumentviewer.com/. I use it on a large site with good success. It will require a flash or pdf viewer plugin.
Hmm have you looked at the new Sharepoint 2010? They do have some sort of integration with MS Office 2010. The demo i saw allows collaboration as well as uploading and viewing powerpoint slides (with all the nice transitions preserved) and even some minor edit functions.
For the browser I think they said that there isn't a need a install any plugins like flash or silverlight and works on all browsers.