0

I would like to insert a Pdf visualizer to read my wp articles. So I can print go through pages like the one in www.scribd.com Is there any plugin for that? I tried "Google Doc Embedder" plugin but I couldn't make it work..

Thanks for your help!

4 Answers 4

1

You can put this in your theme functions.php file, It will work in any browser ( I tested this since it uses an iframe) and auto embed .pdf files from the media tab when you click "insert into post".

You can alter the width and height parameters for the size when its added to the editor.

add_filter('media_send_to_editor', 'my_filter_pdf', 20, 3);

function my_filter_pdf($html, $id) {
    $attachment = get_post($id); //fetching attachment by $id passed through

    $mime_type = $attachment->post_mime_type; //getting the mime-type
    if ($mime_type == 'application/pdf') { //checking mime-type
        $src = wp_get_attachment_url( $id );

        $html = '<iframe width="500" height="500" src="'.$src.'"></iframe>';
        return $html; // return new $html    
    }
        return $html;
}

I made a plugin version here for you, create a php folder and inside that a .php file in your WordPress /plugins folder and paste this into it. https://gist.github.com/2176359

2
  • 1
    Please return something in cases where your if statement returns false.
    – fuxia
    Commented Dec 16, 2012 at 13:52
  • I guess that would be important!
    – Wyck
    Commented Dec 16, 2012 at 17:17
0

here's a pdf viewer based on html5 and js which firefox added to its extensions :

http://andreasgal.com/2011/06/15/pdf-js/

and here's a demo of it :

http://mozilla.github.com/pdf.js/web/viewer.html

but I don't know how you make your articles into pdf's.

0

You could find out what isn't making the Google Doc Embedder plugin work for you. As the developer of that plugin, I can hopefully provide some support to whatever issue you're having...

http://wordpress.org/tags/google-document-embedder#postform

0

Use the plugin specific for embedding PDFs.

And don't forget to accept one of the answers given to you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.