jDownloadsownloads.com


Author Topic: Preview of PDF files?  (Read 2455 times)

0 Members and 1 Guest are viewing this topic.

Offline Jean-Pierre

  • Newbie
  • *
  • Posts: 8
Preview of PDF files?
« on: 27.10.2015 22:59:44 »
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?

Offline ColinM

  • Moderator
  • *
  • Posts: 4.019
Re: Preview of PDF files?
« Reply #1 on: 28.10.2015 08:56:16 »
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
« Last Edit: 28.10.2015 08:57:22 by ColinM »

Offline Jean-Pierre

  • Newbie
  • *
  • Posts: 8
Re: Preview of PDF files?
« Reply #2 on: 28.10.2015 22:52:28 »
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

Offline ColinM

  • Moderator
  • *
  • Posts: 4.019
Re: Preview of PDF files?
« Reply #3 on: 29.10.2015 22:48:14 »
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]

Offline Jean-Pierre

  • Newbie
  • *
  • Posts: 8
Re: Preview of PDF files?
« Reply #4 on: 29.10.2015 23:57:54 »
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

Offline EURRWebmaater

  • Newbie
  • *
  • Posts: 15
Re: Preview of PDF files?
« Reply #5 on: 18.11.2017 15:28:52 »
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?

Offline ColinM

  • Moderator
  • *
  • Posts: 4.019
Re: Preview of PDF files?
« Reply #6 on: 18.11.2017 17:10:43 »
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

Offline EURRWebmaater

  • Newbie
  • *
  • Posts: 15
Re: Preview of PDF files?
« Reply #7 on: 18.11.2017 17:33:21 »
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.
« Last Edit: 19.11.2017 09:55:51 by EURRWebmaater »

Offline ColinM

  • Moderator
  • *
  • Posts: 4.019
Re: Preview of PDF files?
« Reply #8 on: 19.11.2017 20:58:40 »
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
Code: [Select]
<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

Offline EURRWebmaater

  • Newbie
  • *
  • Posts: 15
Re: Preview of PDF files?
« Reply #9 on: 02.12.2017 18:35:13 »
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}
« Last Edit: 02.12.2017 20:14:33 by EURRWebmaater »

Offline EURRWebmaater

  • Newbie
  • *
  • Posts: 15
Re: Preview of PDF files?
« Reply #10 on: 19.08.2019 20:44:35 »
Solution add the next line to \components\com_jdownloads\views\download\tmpl\default.php line 465

Code: [Select]
$body = str_replace('{file_id}', $this->item->file_id, $body);Now the pfd files are loaded embedded within the page.  :D

Offline ColinM

  • Moderator
  • *
  • Posts: 4.019
Re: Preview of PDF files?
« Reply #11 on: 20.08.2019 10:23:03 »
Hi
That is a very neat solution :) .  Think it is much better than using the ImageMagick PHP Module.Will send you a PM
Colin

Offline EURRWebmaater

  • Newbie
  • *
  • Posts: 15
Re: Preview of PDF files?
« Reply #12 on: 20.08.2019 11:22:20 »
Complete instuctions:
add the next line to \components\com_jdownloads\views\download\tmpl\default.php line 465

Code:

Code: [Select]
$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:
Code: [Select]
{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.
« Last Edit: 20.08.2019 11:35:41 by EURRWebmaater »

Offline EURRWebmaater

  • Newbie
  • *
  • Posts: 15
Re: Preview of PDF files?
« Reply #13 on: 21.08.2019 12:36:28 »
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
Code: [Select]
// 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
« Last Edit: 21.08.2019 12:38:05 by EURRWebmaater »

Offline Arno

  • Administrator
  • ***
  • Posts: 12.541
    • jDownloads.com
Re: Preview of PDF files?
« Reply #14 on: 22.08.2019 09:32:25 »
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!