Want your PDFs to view through Google Reader? Wrap it in a shortcode like this: [raw][pdf href="http://noscope.com/photostream/albums/various/no.pdf"]Link to a PDF[/pdf][/raw]. Drop the following in your functions.php:
function pdflink($attr, $content) {
return '<a class="pdf" href="http://docs.google.com/viewer?url=' . $attr['href'] . '">'.$content.'</a>';
}
add_shortcode('pdf', 'pdflink');
[Update]: Here’s an updated shortcode function which allows you to also embed PDFs using this syntax: [raw][pdf=http://noscope.com/photostream/albums/various/no.pdf]Link to a PDF[/pdf][/raw]. Note how it’s just a tad shorter, and you don’t have to remember the “href” parameter, though you can still use it.
function pdflink($attr, $content) {
if ($attr['href']) {
return '<a class="pdf" href="http://docs.google.com/viewer?url=' . $attr['href'] . '">'.$content.'</a>';
} else {
$src = str_replace("=", "", $attr[0]);
return '<a class="pdf" href="http://docs.google.com/viewer?url=' . $src . '">'.$content.'</a>';
}
}
add_shortcode('pdf', 'pdflink');
Also, here’s an example PDF link using the above code: [pdf href="http://noscope.com/photostream/albums/various/no.pdf"]Link to a PDF[/pdf].
分享 http://tinyurl.com/ygztt2e (WordPress Trick: Create A Google Viewer PDF Shortcode) http://plurk.com/p/3zevv0
Awesome update, thanks for the snippet !
wonderful code tanx
the function closed braket is not comming after the semicolon it may need to chane the code at list i may case it not working
}
add_shortcode(‘pdf’, ‘pdflink’);
—————————
add_shortcode(‘pdf’, ‘pdflink’);
}
——–
Hi,
Will users be able to download the PDF file? I’m looking for a secured way to publish my stuff (for free) but without allowing users to download the PDF file, only view it.
Can this help me?
Thanks a lot,
Eran
eran,
Eran,
I doubt that’s even technically possible. If the user is able to read your PDF file, they can save it.
Hi,
Thank you so much for your quick reply.
May there’s a flash plugin or something?do you know if Scribd allows disabling downloading and printing the documents? I’m trying to go over the support page without any luck so far
found it! yey !
http://support.scribd.com/forums/33626/entries/96700#properties