i need to display a pdf on the website. i've tried many ways but none of it worked for me.
let me explain what i've tried and why this is not ok for me.
i tried to insert pdf into html with <object> and <embed> tags. its ok if client browser has flash. but android phones don't have it so this is not a solution. plus iphone streching pdf so it is not readable.
then i tried to use just an <iframe> element. works fine only if browser has pdf plugin. in other cases browser starts file downloading. so this is not a solution too.
then i tried to use https://docs.google.com/gview?embedded=true&url=myfile.pdf. well and here i got troubles because there is some bug in in google docs because file displays only one in for times. the rest attempts ended with error code 200 from google. so as you already understood this is not a solution too.
then i tried to download php libs which should convert pdf to html (or image) but none of them worked beacuse i'm not that good at php and sometimes it asked to install third party libs so at this point i've failed too.
so now i'm stuck. i need to do something to display pdf on the page. i need some crossbrowser/responsive solution. it would be great if you help me to find some service like https://docs.google.com/gview which is gonna work without bugs or suggest any other solution. may be some small php lib with good documentation.
any help appriciated!
You can achieve by using PDF.js
https://github.com/mozilla/pdf.js/
for usage you can check this example http://mozilla.github.io/pdf.js/examples/index.html#interactive-examples.
Related
I've been implementing a google drive connector into a web application.
Basically when a known event is triggered in the page it launches a webhook which communicates with the 'drive-connector' in order to generate a document and fill it with some information.
This 'drive-connector' is a custom PHP which uses the Google Drive API to create folders and files. I am able to create the folders and files and give the files the desired content.
To give the content to the drive document I use an HTML template (https://developers.google.com/drive/api/v3/manage-uploads) which is allowed by the API, before uploading it I change some variables inside the template with the data that comes from the webhook, all well for now.
The problem
I'm able to upload the HTML document, once I replace the variables for the desired data, but It has to be very simple and without much css. When I try to upload the document from a more worked and beautiful template Google Drive doesn't recognize many CSS and it changes the appearence of the document. I can't put a header nor a footer. Many fields are moving from its places and making a mess of the whole document.
In order to make it easier for me to replace the variables in the template I choosed to use HTML anyways I'm starting to think that would be easier to use a .doc or .odt template ( I would need to use a library in order to do that )
My question
Is good to use an HTML document as template for the google drive document? Or should I change the way I am trying to achieve this?
Thanks in advance
Observation: Since I don't really have problem with my code I haven't put any line of code, how ever If you need the HTML template to guess if it has any problem, just tell me.
EDIT 1 -> I've found this: How can developers edit a Google Doc programmatically? Is there a Docs API?
It is not the answer of my question but seems to have some solutions to my problem. Anyways I don't get much clear in that post, I haven't found the proper documentation so I'm still fighting to get this.
EDIT 2-> Reading again the documentation I thought that I could make the document firstly in the google drive and then using the API download it as HTML, this way I would have the template but I'm not sure if I could modificate it has I wish. If this works I will reply my own question and close the post
After trying this I could not upload the HTML which was exported from the google doc. The error that the google api gives me is: code 400 message: bad request
Finally I could find a work around!
Anyways It is not a very effective and good way of doing it.
As I explained in my EDIT 2, I tried to download a google drive document created in google drive by hand and export it has HTML, so I had the template in HTML. Then I added my variables for future dynamic replacements and everything works more or less fine.
I solved the problem of the bad request modifying a bit the document, seems like you cannot have exacly the same document twice in the drive, after changing some lines of code It started to work.
Anyways I don't feel like this is a definitive and fine way of doing what I want so I will keep the post open for if somebody knows a better way of achieving this.
Hi I'm trying to convert a joomla page into pdf so far the things I tried keep failing or fell short. I tried PhocaPDF but I get tons of errors upon install and It would require me to change the jore of joomla. also tried Root pdf content problem is I have some php codes in the articles that would output too. So I'm only left with hard coding it. Would anyone help me on how should I approach this? Should I use PHP on my articles or Javascript? Thanks.
you can try to use following extension
http://forum.joomla.org/viewtopic.php?f=624&t=808593
I have been scouting the web for a pdf editing tool for quite some time now. And it would therefore be nice with some suggestions/recommendations to the problem.
I have read a bunch of other topics around StackOverflow, but havent quite been able to find a full solution yet.
The case: I have an application written in php/javascript on a linux server and recently it has become a requirement for my customers that they are able to edit Pdf documents direct in the browser. The functions i need are primarily the ability to make annotations and to draw on the PDF. That means. They load an already uploaded PDF-document and edits it and then saves it in PDF-format again. All done within the browser.
The second requirement is that the program must save pdf document in PDF-format again, since i have an Ipad app with all of this functionality, and i need them to play nicely together. It is therefore not an option to save an image of html of something like that.
I read a comment suggesting the Zend framework, and it did sound quite useful. However i have developed my own platform from the ground, and therefore my second question is, if it is possible to embed only the PDF-tool from Zend or something?
Thank you in advance.
ps. If i missed a simular subject that answers exactly this, please let me know and i'll delete again.
There are several libraries that can be used to edit PDF-files. To name a few: Tcpdf, fpdf and Zend_Pdf.
The later can be used even without the complete ZendFramework. But be cautious: Currently it only allows editing of PDF-Files up to version 1.4.
If you need speed you should also have a look at the PDFlib which could be tweaked to support your usecase
I am not satisfied with the browsers internal behaviour of displaying PDFs. I would like to provide my users with an easy yet stylish PDF viewing experience on my sites. Something like Scribd, but managable and unter full security and control on my server.
I could provide inline links to GoogleDocsViewer or ZohoViewer. Or convert the PDF right after its upload with SWFTools and show the swf with native PHP or HTML5.
Anyway, somehow, after hours of reading and thinking, I am just not happy with any of the above approaches.
Any suggestions?
Take a look at Google Docs Viewer. The following code will help you (untested):
<iframe src="http://docs.google.com/gview?embedded=true&url=PDF-URL" style="width:600px; height:500px;" frameborder="0"></iframe>
Update 13.09.2016:
Google removed their generator. Even though, you can still use the viewer by appending the escaped document-url to the url above manually.
I had to do something similar and finally I opted for generating images with ImageMagick, its works exactly the same way like Google Viewer.
But, if you want, you still can try to use PDF.js its from Mozilla and want to replace de browser PDF plugin.
I'm trying to find a way to search inside PDF files. I came accross the PHP PDF class but I can't seem to find any function for reading/searching a filestream.
So, as naive as I am, i tried to simple get a stream using file_get_contents(), obviously it's an encrypted-like output ;)
So my question, is there any way to search through PDF files? I'm looking for script-only / free / open source solutions and not buying some expensive commercial libraray.
XPDF?
There is a blog post here that may be of help.
There seems to be some code here that could help - a simple class that reads a PDF into plaintext. Unsure if it supports decryption.
There are also a number of resources in PHP documentation that may help you. Click.
FPDF and FPDI may also help. Probably your best bet after some research.**
A PHP search engine called Sphider has the option of adding PDF search via XPDF. You can then customise the result templates to fit in with the rest of your site (if applicable).