Embed PDF into wordpress

Is there a way to show a PDF file inside Post in Wordpress? I used the tag but if someone has Internet Download Manager the Dialog will appear to Download the PDF file and then if they click cancel they will not be able to see it, they can ONLY download it

Is there's a way to stop automatic download?

There are many plugins for that but the image quality is too bad.

Topic embed views pdf posts plugins Wordpress

Category Web


The Embed PDF Plugin allows you to embed a pdf inside a viewer on your post or page.


The only reliable cross browser solution is to embed the .pdf in a iframe.

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

function my_pdf_embed($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 );

        //change the size to your liking
        $html = '<iframe width="500" height="500" src="'.$src.'"></iframe>';
        return $html; // return new $html    
    }
        return $html;
}

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.