PDA

View Full Version : BB Code Enhancements - BBCode: Embed PDF Files (No JavaScript/No iFrames) (BB Code)


BirdOPrey5
08-12-2010, 10:00 PM
This is <embed> BB Code to embed a PDF file into your forum. The user needs a compatible PDF Reader such as Adobe's free PDF Reader (http://www.adobe.com/products/reader/). If they don't have one they will still see a link to view the PDF directly.

I am aware <embed> is not "proper" HTML but it works fine in all major browsers (IE/FF/Chrome/Opera/Safari) while <object> was not working for me in IE. If you prefer to keep to strict HTML guidelines and don't care about IE users then simply change the two instances of "embed" in the replacement code to "object".

This has been confirmed working in the latest releases of IE, FF, Chrome, Safari, and Opera.

I am also aware there are at least 2 other PDF BB Codes out there... I believe this implementation is better because one of them uses JavaScript and another uses an iFrame and relies on a 3rd party website (google) to display the PDF. My implementation uses no JavaScript and does not reply on any other websites.

Demo: here. (http://www.juot.net/forums/showthread.php?p=848014#post848014)

Add a new BBCode

Title: Embed PDF
BB Code Tag Name: pdf
Replacement:

<div align="center">
<p align="center">
<embed src="{param}" type="application/pdf" width="700" height="900">
<br />
<a href="{param}">Click here to view or download the file directly.</a>
<br />
</embed>
</p></div>

Example: http://www.qapla.com/ju/PDFOpenParameters.pdf
(I suggest using your own example if possible.)
Use Option: No
Button Image: (optional) https://vborg.vbsupport.ru/external/2010/08/43.jpg
Remove Tag If Empty: Yes
All Disable Options: Yes

Overall this tag acts a lot like the built in [img] tags.

Please mark as installed if you use this. :)

Check My Profile (https://vborg.vbsupport.ru/member.php?u=258922) for other BB Code enhancements. They work on all versions.

Screenshot Attached:
https://vborg.vbsupport.ru/attachment.php?attachmentid=120786&stc=1&d=1281727562

yotsume has found a bug where VB drop down menus (like "thread tools") may get hidden behind the PDF if the menu overlaps the same screen space as the PDF. For now please leave some extra lines before embedding a PDF at the top of the first post if you need to use the drop down menus.

yotsume
08-14-2010, 07:33 PM
Works Great!

However... I changed the width to: width="100%". Looks even nicer using a %. This way the pdf view window is the full size of the post. In my case I used this inside of a vbadvanced bb code page with no wrapper.

Thanks!

SublimeBoa
08-14-2010, 07:55 PM
Simple to install, user friendly and works nicely.

Thanks! :up:

BirdOPrey5
08-14-2010, 07:57 PM
Works Great!

However... I changed the width to: width="100%". Looks even nicer using a %. This way the pdf view window is the full size of the post. In my case I used this inside of a vbadvanced bb code page with no wrapper.

Thanks!

Thanks for the suggestion, I personally prefer the smaller box but whatever works for you is good. :)

Simple to install, user friendly and works nicely.

Thanks! :up:

No problem. :up:

SublimeBoa
08-15-2010, 01:17 AM
Is there a way to adjust it so the scroll wheel works when outside the pdf itself? It scrolls the pdf just fine, but will not scroll the web page.

Thanks
Rick

SublimeBoa
08-15-2010, 01:18 AM
Never mind. Guess it just wanted to mess with me. Works fine now.

yotsume
08-15-2010, 01:25 AM
Your scroll wheel will detect where you have clicked on the page. So if you clicked on the pdf scroll bar your scroll wheel will move that bar instead of the pages bar. Click on a portion of the page and it will detect the pages scroll bar instead. ;)

SublimeBoa
08-15-2010, 01:39 AM
Thanks!

yotsume
08-15-2010, 04:34 AM
There is a small problem with the BB Code. Popup menus in VB will open under the embedded PDF. (see attached screenshot)

I believe the same way that flash can be made to open under menus... the PDF can be made to as well by adding a line of code that makes it "transparent".

UPDATE: Using a transparent or opaque mode will not work with a PDF because the adobe plugin doesn't currently support them for PDFs yet. I hope another solution to this issue can be found...

BirdOPrey5
08-15-2010, 01:50 PM
yotsume- I can confirm I do have this bug too, thanks... I guess the work around for now is to leave some empty lines before embedding the PDF, though for me it's not nearly as big an issue because of my choice to have a fixed width and most of the menus still very visible. This doesn't seem like it would be a problem if a pdf was posted in anyplace but the top of the first post.

I will see if I can find a solution.

BirdOPrey5
08-15-2010, 02:56 PM
I've been playing with z-index values all morning but this is apparently a common issue with flash too and there is no solution for that either- when something loads via a plugin all bets are off on how it displays :( Will keep looking but it does not look good.

trotskid
08-15-2010, 05:10 PM
Nice BB code, but page on forum doesn't scroll with mouse wheel on Firefox.

SublimeBoa
08-15-2010, 07:24 PM
Nice BB code, but page on forum doesn't scroll with mouse wheel on Firefox.

I had the same glitch with FF no matter where I clicked, then it just started working right.

yotsume
08-16-2010, 03:24 AM
I've been playing with z-index values all morning but this is apparently a common issue with flash too and there is no solution for that either- when something loads via a plugin all bets are off on how it displays :( Will keep looking but it does not look good.

The flash issue is actually easy to solve. This PDF issue however requires you to wrap it in an iframe and then use a lower z-index then the popup menu. Its a pain but for now not a big issue for me. Maybe Adobe will fix it in a new plugin update???

BirdOPrey5
08-16-2010, 03:34 AM
I actually tried the iframe 'solution' I found posted but in fact it still wasn't working for me even with the iframe-div-iframe codes I found.

yotsume
08-16-2010, 06:46 AM
I actually tried the iframe 'solution' I found posted but in fact it still wasn't working for me even with the iframe-div-iframe codes I found.

I think the iframe and z-index solution will only work if code is added to the navbar template to define its z-index. So that way the navbar popups will be higher then the PDF iframe. That should allow the menus to open over the PDF. It might be worth it to ask over at vBulletin for some help or maybe with some of the big names over here even...

BirdOPrey5
08-16-2010, 01:24 PM
I don't think the navbar template is the issue, to the browser it's all the same web page, it doesn't know if some code is in the navbar template and some code is in showthread or postbit etc... also using this in the navbar is out of the question anyway for obvious reasons.

I put a lot of time searching the web for an answer for this and it always comes back to just not possible because the way plugins are handled by the browser.

SublimeBoa
08-16-2010, 11:55 PM
OK, I been messing with this over at the forum, and it does seem to have a hang up in FF. I tried IE and works fine. In FF it loads everything just fine, but the scroll will only work on the PDF. No matter where you click on the forum, it doesn't remedy it.

BUT, you can get around it by keeping your bookmarks sidebar open, and after you load a page with a PDF, click the scroll bar on the sidebar, and it fixes things in the browser for some reason. ???? This is very consistent as well, using FF 2.x and 3.x.

Does this sound like something you can remedy for us FF users? Or should we just deal with it and use the back door I found? Not really that much of a pain now that I know how to get around it, but it would be nice if we didn't have to.

Other then that, I gotta say I still like it. :up:

BirdOPrey5
08-17-2010, 01:15 AM
Yeah sorry there's nothing I'm going to be able to do about that unfortunately- I'm pretty much stuck with however the plugin and browser is programmed to behave. :(

yotsume
08-22-2010, 06:41 PM
Question... Is there a way with the bb code to block the ability to download the embedded PDF file. Meaning the save button on the toolbar would not show or be whited out?

BirdOPrey5
08-22-2010, 10:04 PM
No, not with the BB Code... that is a setting that would have to be made by the software that created the PDF file- I don't know the specifics but I know you can set advanced PDF options in Adobe Acrobat so files are blocked from things live saving, editing, or printing.

yotsume
08-22-2010, 11:19 PM
No, not with the BB Code... that is a setting that would have to be made by the software that created the PDF file- I don't know the specifics but I know you can set advanced PDF options in Adobe Acrobat so files are blocked from things live saving, editing, or printing.

I did up the security in my PDF so you can not save it. However, once you embed the PDF with this code the save button becomes active again. So my way around this for my needs is to PW protect the PDF. This requires forum members to enter a PW to view the PDF.

BirdOPrey5
08-23-2010, 12:39 AM
Wow that sounds like a serious security flaw... did you by chance confirm if you could actually save the file if you clicked on the button? Maybe it wouldn't actually work?

Akeles
05-27-2012, 04:28 PM
Nice BB code