OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Embeddding Pdf files in static pages

Are you responsible for making OJS work -- installing, upgrading, migrating or troubleshooting? Do you think you've found a bug? Post in this forum.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
What to do if you have a technical problem with OJS:

1. Search the forum. You can do this from the Advanced Search Page or from our Google Custom Search, which will search the entire PKP site. If you are encountering an error, we especially recommend searching the forum for said error.

2. Check the FAQ to see if your question or error has already been resolved.

3. Post a question, but please, only after trying the above two solutions. If it's a workflow or usability question you should probably post to the OJS Editorial Support and Discussion subforum; if you have a development question, try the OJS Development subforum.

Embeddding Pdf files in static pages

Postby alirezaaa » Wed Aug 24, 2011 12:20 am

Hi every body,
I want to embed a pdf file in a static page, so first i created the page and then inserted this code in the html editor of the page:
Code: Select all
<embed src="test_page.pdf" width="500" height="375"/>

But when i update and save the code editor, it is changed to:
Code: Select all
<p>
<object width="500" height="375" data="/public/journals/1/test_page.pdf" type="application/x-shockwave-flash">
<param name="src" value="/public/journals/1/test_page.pdf" />
</object>
</p>


I tried to change type="application/x-shockwave-flash" to type="application/pdf", but it changes back to shockwave-flash after i save the page, so flash player plugin is loaded instead of pdf plugin and the file is not shown!
where is the problem?
Cheers,

Alireza
alirezaaa
 
Posts: 27
Joined: Sat Jul 09, 2011 9:54 am

Re: Embeddding Pdf files in static pages

Postby JasonNugent » Thu Aug 25, 2011 4:22 pm

Hi Alireza,

I was just able to embed a PDF into a text field that uses the HTML editor (the TinyMCE editor) that is a part of OJS. However, to make sure it worked correctly I first clicked the "HTML" button on the editor in order to insert the straight HTML code into the text field. There is less possibility of the editor changing the code that way. Did you try that? If not, can you see if that helps at all?

Regards,

Jason
JasonNugent
Site Admin
 
Posts: 847
Joined: Tue Jan 10, 2006 6:20 am

Re: Embeddding Pdf files in static pages

Postby alirezaaa » Thu Aug 25, 2011 10:29 pm

Hi Jason,
That is what I exactly did, but it seems that TinyMCE editor does not support embedding the pdf files through the HTML editor. The developer believes that there is no need to show a pdf file in the web page!
you can read the whole story at TinyMCE forum, which i found today:
http://www.tinymce.com/forum/viewtopic.php?pid=55440

However, I believe that being able to read a pdf file in a web page is a great idea.
I wonder how the full text of articles (in .pdf format) are shown in OJS using the pdf plugin ? Some coding might do it, but I don't know if there is another easier method?
Any ideas?
Cheers,

Alireza
alirezaaa
 
Posts: 27
Joined: Sat Jul 09, 2011 9:54 am

Re: Embeddding Pdf files in static pages

Postby JasonNugent » Fri Aug 26, 2011 2:57 am

Hi Alireza,

The quick solution may be to simply disable the TinyMCE plugin and use the normal text editor instead, for creating content. Then you can insert the links you want and the editor will not change them.

The embedded PDFs that OJS shows are not inserted via the TinyMCE editor -- those are put there by the code when it generates the galley view pages.

Cheers,

Jason
JasonNugent
Site Admin
 
Posts: 847
Joined: Tue Jan 10, 2006 6:20 am

Re: Embeddding Pdf files in static pages

Postby alirezaaa » Fri Aug 26, 2011 4:16 am

Hi Jason,
I tried that too. But in order to use the static pages plugin, you have to enable TinyMCE editor and if you disable it the static pages disappear.
So, I believe that there is no way to embed a pdf file without modifying OJS, and I fear that this will produce bugs in other pages.
I am gonna convert the pdf file to a flash movie which is embedded easily. This method has some limitations but might help me unless I find the solution.
Cheers,

Alireza
alirezaaa
 
Posts: 27
Joined: Sat Jul 09, 2011 9:54 am

Re: Embeddding Pdf files in static pages

Postby JasonNugent » Fri Aug 26, 2011 5:50 am

Aha!

I wasn't aware that you were using the Static Pages plugin. The Static Pages plugin comes with its own bundled copy of the TinyMCE text editor, so here's what you can do, if you like.

In the directory:

Code: Select all
plugins/generic/staticPages/


There is a file called "StaticPagesEditForm.inc.php". You can edit this file, and look for the line:

Code: Select all
extended_valid_elements : "span[*], div[*]",


And change that to include:
Code: Select all
extended_valid_elements : "iframe[*], span[*], div[*]",


At that point, you can reload your Static Page and edit it, and use iframe tags to include links to embedded PDFs. You don't need to use the embed tag if you don't want to.

Keep in mind that if you make this change to the plugin, you'll have to remember to do it again if you upgrade OJS, since the new version will overwrite this file.

Regards,

Jason
JasonNugent
Site Admin
 
Posts: 847
Joined: Tue Jan 10, 2006 6:20 am

Re: Embeddding Pdf files in static pages

Postby alirezaaa » Fri Aug 26, 2011 10:47 am

Hi Jason,
It worked!
I'm using Google pdf viewer and it's just great.
Code: Select all
<iframe src="http://docs.google.com/gview?url=http://example.com/mypdf.pdf&embedded=true" style="width:718px; height:700px;" frameborder="0"></iframe>

Thank you for your solution

Cheers,
Alireza
alirezaaa
 
Posts: 27
Joined: Sat Jul 09, 2011 9:54 am

Re: Embeddding Pdf files in static pages

Postby ramon » Wed Nov 21, 2012 7:41 am

Hello all,
I know this is an old post, but as it's related, I didn't want to create a new topic.
I'm using Open Journal Systems (OJS 2.3.8.0).

I've been trying to configure TinyMCE to enable IFRAMEs for an OJS install as we probably will need to embed multiple media within the articles abstracts.
This is the code in plugins/generic/tinymce/TinyMCEPlugin.inc.php

Code: Select all
 $tinymceScript = '
                        <script language="javascript" type="text/javascript" src="'.$baseUrl.'/'.TINYMCE_JS_PATH.'/tiny_mce_gzip.js"></script>
                        <script language="javascript" type="text/javascript">
                                tinyMCE_GZ.init({
                                        relative_urls : "false",
                                        plugins : "paste,fullscreen,jbimages",
                                        extended_valid_elements : "iframe[*]",
                                        themes : "advanced",
                                        languages : "' . join(',', $localeList) . '",
                                        disk_cache : true
                                });
                        </script>
                        <script language="javascript" type="text/javascript">
                                tinyMCE.init({
                                        entity_encoding : "raw",
                                        plugins : "paste,fullscreen,jbimages",
                                        extended_valid_elements : "iframe[*]",
                                        mode : "exact",
                                        language : "' . String::substr(AppLocale::getLocale(), 0, 2) . '",
                                        elements : "' . $enableFields . '",
                                        relative_urls : false,
                                        forced_root_block : false,
                                        paste_auto_cleanup_on_paste : true,
                                        apply_source_formatting : false,
                                        theme : "advanced",
                                        theme_advanced_buttons1 : "cut,copy,paste,|,bold,italic,underline,bullist,numlist,|,link,unlink,help,code,fullscreen,jbimages,iframe",
                                        theme_advanced_buttons2 : "",
                                        theme_advanced_buttons3 : ""
                                });
                        </script>';


I deleted the .gz file from the respective lib folder and refreshed, but nothing happens....

I also added the IFRAME tag in config.inc.php

Any ideas?

[UPDATE]
There must be something being done somewhere else, as the IFRAME tag is added AND saved in the abstract field, but it doesn't get displayed at all.

_______________________________
Ramón Martins Sodoma da Fonseca
Analista em C&T
Coordenação de Tecnologias de Informação
Instituto Brasileiro de Informação em Ciência e Tecnologia - IBICT
Ministério da Ciência e Tecnologia - MCT
ramon
 
Posts: 926
Joined: Wed Oct 15, 2003 6:15 am
Location: Brasí­lia/DF - Brasil


Return to OJS Technical Support

Who is online

Users browsing this forum: Google [Bot] and 5 guests