3

I am using jquery.gdocsviewer.min.js plugin to read office and pdf documents in a website. The plugin is working fine. I am trying to get the content of the generated preview using jquery

var rowcontent=$('.embed').html();///embed is the class of the link

But I cant get this to work. Check a working fiddle

http://jsfiddle.net/4s8bn/133/

Please advice me on what to do or if its practical. I want to fetch the content and save it as html in a database.

jonah
  • 213
  • 4
  • 16

2 Answers2

2

In client side, it is not possible to get that pdf directly and save as html in database.You have to do it in server side. For server side,here is an example with php Once you get that in server side you can catch it with Ajax in client side.

Community
  • 1
  • 1
Mahbubur Rahman
  • 4,961
  • 2
  • 39
  • 46
  • kindly repost the link again. its broken. is there no php solution. am not proficient with Java. especially on server – jonah Oct 13 '15 at 09:56
  • see i have updated the answer. I am not proficient with php. So google, if above link doesn't help.But sure u will get some answer cause it's a widely used. – Mahbubur Rahman Oct 13 '15 at 10:07
1

Try:

var rowcontent = $('.gdocsviewer').html();

From the docs:

The plugin inserts a the IFRAME for the viewer inside an injected DIV. The DIV tags all carry the class name "gdocsviewer", which allow for styling all the gdocsViewer instances via CSS. If the anchor tag has the ID attribute defined, then the injected DIV tag is also set an ID attribute in the format of ID_of_Anchor + '-gdocsviewer'. See the demo source code for more details.

Irvin Dominin
  • 30,819
  • 9
  • 77
  • 111
  • Hi @irvin, thanks for the feedback. But I am getting an iframe instead of the html. – jonah Oct 13 '15 at 07:22
  • You can't because of the same origin policy restrictions. If you try to get it you'll get permission denied type errors. – Irvin Dominin Oct 13 '15 at 07:29
  • I really needed to get this for my client's app. I don't have a workaround. Any solution would help. and am out of ideas. The documents are all stored in my server. If you think of some workaround, kindly post – jonah Oct 13 '15 at 07:56