News:

Dear forum visitors, if the support forum is not available, please try again a few minutes later. Thanks!

Main Menu
Support-Forum

Preview of PDF files?

Started by Jean-Pierre, 27.10.2015 22:59:44

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Jean-Pierre

Hi, I just started to use jDownloads for managing free and paid downloads of PDF files. I'm very satisfied so far with the quality of the product, however there is one point where I have not found a way to do so far: for PDF files that are to be sold, I would like to offer a preview, i.e. a few pages of the full document so that users have a better idea of the PDF file before paying for it. I uploaded these preview PDF files through "Select Preview File" on the "Edit Download" page, but they do not show up anywhere. I would have expected to find a "Preview" link or button next to the "Download" button in the frontend, but  that's not the case. Any suggestion?
  •  

ColinM

#1
Hi
There is no automatic  way to preview several pages of a pdf as you indicate but there are various ways you can achieve your objective.  In all of them you either make images of the relevant pages or you create a short preview pdf file.

With the present jD 3.2 series the nearest to an automatic scheme then with the appropriate Configuration setup jD will create a preview image of the front page.  See the Thumbnails Settings section of the Configuration - Pictures Tab, in particular field 'Create Thumbnails from PDF files? However the image created is only the front page of the pdf.

You can have multiple images associated with each download so these could be images made by yourself.

Perhaps a better way is to create a pdf preview file - say using the Primo pdf 'printer' to get just the pages you want of each document that you wish to have a preview.  This could be a separate 'Download' or you could use the jD Content plugin within the Description part of the main download.  A variation on this would be to embed a "pdf viewer" plugin such as the free Techjoomla pdf viewer - see
https://techjoomla.com/free-downloads/pdf-embed

To assist in embedding other plugins in  jD then the following article may help
http://www.jdownloads.net/documentations/item/extending-with-plugins-example-using-image-gallery-videos.

Colin
Colin M
  •  

Jean-Pierre

Thank you Colin,

I will see what approach fits best. I have already separate PDF preview files, however I would prefer not to embed them in the article, but to download them in a similar way than the main document.

Jean-Pierre
  •  

ColinM

Hi
I was suggesting using the content plugin in the Description part of the Main download.  I have constructed, very quickly, an very basic illustrative example.The 'blue ringed ' part represents the link to the preview, which would have public download permission. I set it to have a pale blue background It uses appropriate layouts.  If you think scheme useful then I will post more details.

Colin

[gelöscht durch Administrator]
Colin M
  •  

Jean-Pierre

Hi Colin,

Thank you. Yes, I  believe your approach is a valid answer to my request. The PDF previews can be public, no problem.

Jean-Pierre
  •  

Tazzios

I want the user to be able to read the complete file also on the website.

I use the same plugin and try this code on my website
{pdf={url_download}|100%|600|pdfjs}  but the {url_download} is replaced with a download button instead only the url. I checked the parameter list but couldn' t find and raw url link or something is there an other way to get the raw url in the layout section?

ColinM

Hi
In jD Config - Downloads tab - field "Which file types are to be opened in the Browser?" you can specify which files are opened in the browser.  This happens when clicking on the download button or the Download name.  But for this to work the file must be downloadable.
If the whole file is viewable on the web then there is a lot of software which can 'steal' whatis being displayed!
Colin
Colin M
  •  

Tazzios

#7
I noticed now  it depends on the browser. my firefox just came with a download popup while IE opened a new tab with the pdf.
I would like it if the experience is the same AND that the user says on the website.

The scraping is not a problem, all the files are only available for members.
Is a additional tag possible or is there some PHP code that i can put in my layout that gives the url?
Edit: RAW elements would also be nice to embed a filtered fabrik list with relevant files.

ColinM

Hi
You could try {pdf={file_title}|100%|600|pdfjs} but you would also need to set some config parameters.
See http://www.jdownloads.net/documentations/item/download-actions-direct-via-summary-page-or-via-download-details

Another approach is to use the jD Content Plugin with code based around something like below - also needs as above
<p>This article shows several&nbsp; jDownloads Content Plugin examples</p>
<div>{jd_file onlinelayout==Files link only v3.2}</div>
<div>This is some text with a download {jd_file file==25}in the middle of the line using layout "Files link only v3.2".</div>
<p>This is just text on a line as &lt;p&gt;</p>

for more on content plugin see
http://www.jdownloads.net/documentations/item/using-the-content-plugin-in-articles-and-modules

Please let us know how you get on
Colin
Colin M
  •  

Tazzios

#9
I`ve been looking and testing but always come to the point that i  need a full URL to the PDF file for the embedded PDF viewer. The  {file_id} would be the easiest way but is not available in the 'file detail' lay-out. Then i could simple use this:

{pdf="index.php?option=com_jdownloads&task=download.send&id={file_id}"|100%|600|pdfjs}

Tazzios

Solution add the next line to \components\com_jdownloads\views\download\tmpl\default.php line 465


$body = str_replace('{file_id}', $this->item->file_id, $body);

Now the pfd files are loaded embedded within the page.  :D

ColinM

Hi
That is a very neat solution :) .  Think it is much better than using the ImageMagick PHP Module.Will send you a PM
Colin
Colin M
  •  

Tazzios

#12
Complete instuctions:
add the next line to \components\com_jdownloads\views\download\tmpl\default.php line 465

Code:

$body = str_replace('{file_id}', $this->item->file_id, $body);

Install PDF plugin: https://techjoomla.com/free-downloads/pdf-embed

Put the next Code to put in your download details template:
{pdf="index.php?option=com_jdownloads&task=download.send&id={file_id}"|100%|600|pdfjs}

See the attachment for an example of the result.

Disclaimer I have no  idea (yet) what it does with other documents then pdf.

[gelöscht durch Administrator]

Tazzios

#13
I made some improvements:

  • No plugin needed, but you need to placepdfjs web files somewhere adjust $Path_pdfjs accordingly

  • Only shown with pdf files
  • separate tag that you can use in the layout:{file_pdfviewer}
  • Smartsearch highlighting!
pdfjs download: https://mozilla.github.io/pdf.js/getting_started/#download

components\com_jdownloads\views\download\tmpl/default.php line 465
// Added $body = str_replace('{file_id}',$this->item->file_id , $body); //for debugging but maybe nice to keep

//temp $body = str_replace('{file_id}', date_format(date_create($this->item->date_added),'Y-m-d') , $body);

// get the smartsearch from the url if exist
$search= base64_decode(htmlspecialchars($_GET["highlight"]));
$search= str_replace('[', '' , $search);
$search= str_replace(']', '' , $search);
$search= str_replace('"', '' , $search);
$search= str_replace(',', ' ' , $search);
$body = str_replace('{file_search}', $search , $body); //for debugging but maybe nice to keep

// get file extension
$file_extension = end(explode(".", $this->item->url_download));
$body = str_replace('{file_extension}', $file_extension , $body); //for debugging but maybe nice to keep

// Insert pdfviewer
if($file_extension == 'pdf')
{
// Path to pdfjs/web/viewer.html  **** could be installed with jdownloads
$Path_pdfjs = '/vve/plugins/content/pdf_embed/assets/viewer/pdfjs/web/viewer.html' ;
//replace the file_pdfviewer with the pdfjsviewer
$body = str_replace('{file_pdfviewer}',
'<iframe src="' . $Path_pdfjs . '?file=%22index.php%3Foption%3Dcom_jdownloads%26task%3Ddownload.send%26id%3D'
. $this->item->file_id . '#search='. $search . '" ' .
' style="width:100%;height:800px;" frameborder=1> </iframe>', $body);  // ***** the style parameters should be configurable at the backend
}  // Added

Arno

Hi,
thanks a lot that you share this with us. I think that Colin will add a hint about this possibility in the documentation.  8)
Best Regards / Gruß
Arno
Please make a Donation for jDownloads and/or write a review on the Joomla! Extensions directory!
  •