4 votes

PDF Thumbnails

Don't you just find it annoying when you design a brand new website with some nice styling for your customers, and they start to upload pdf files instead of writing the text in the RTE? Sometimes it's necessary. when the customer received the pdf from a third party, and this is where this package can give you a compromise.

How does it work:

When you upload a pdf file, this package will generate jpg thumbnails of all pages in a subfolder of pdf file media folder. Through an extension you get the list of thumbsnails associated with the pdf file, and you can choose which to render of the page

How to install:

  1. Install the package
  2. Done

There is a macro included that demonstrates how to get the thumbnails

Technical info:

The package includes an extension function called GetMedia, that works just like the umbraco.library version. Actually it calls the umbraco.library version and adds the thumbnails xml snippet the returned xml. This is cached just like the umbraco.library version and uses the UmbracoLibraryCacheDuration setting from umbracoSettings.config.

The xml format is this:

<File id="1086" version="704a1724-b86e-4dff-bfbc-897b01a830e7" parentID="1055" level="2" writerID="0" nodeType="1033" template="0" sortOrder="30" createDate="2013-06-19T15:43:39" updateDate="2013-06-19T15:43:39" nodeName="Theumbraco6requestpipeline" urlName="theumbraco6requestpipeline" writerName="admin" nodeTypeAlias="File" path="-1,1055,1086">  <umbracoFile>/media/110/TheUmbraco6RequestPipeline.pdf</umbracoFile>  <umbracoExtension>pdf</umbracoExtension>  <umbracoBytes>2091318</umbracoBytes>  <pdfThumbnails>    <file id="1">/media/110/pdfthumbs/TheUmbraco6RequestPipeline_page_1.jpg</file>    <file id="2">/media/110/pdfthumbs/TheUmbraco6RequestPipeline_page_2.jpg</file>    <file id="3">/media/110/pdfthumbs/TheUmbraco6RequestPipeline_page_3.jpg</file>    .......  </pdfThumbnails></File>

XSLT Sample:

<xsl:param name="currentPage"/><xsl:variable name="mediaItem" select="/macro/mediaItem"/><xsl:template match="/"><xsl:if test="$mediaItem">    <xsl:variable name="pdf" select="Flexit.PdfThumbnails:GetMedia($mediaItem/File/@id,0)"/>    <h2><xsl:value-of select="$pdf/@nodeName"/></h2>    <a href="{$pdf/umbracoFile}">Get full PDF here</a>    <xsl:for-each select="$pdf//pdfThumbnails/file" >        <img src="{.}"/>    </xsl:for-each></xsl:if></xsl:template>

Razor example

@inherits [email protected] Flexit.PdfThumbnails;@{    var pdf = PDFHelper.GetMedia(1086);    <a href="@pdf.Media.Url">Link to full PDF</a>    foreach (var thumb in pdf.PdfThumbs)    {        <img src="@thumb.fileName">    }}

The following libraries/code has been used to create this package:
GhostScript (http://www.ghostscript.com/)
GhostScriptSharp wrapper (https://github.com/cbadke/ghostscriptsharp)

This has only been tested on 6.1.1

Version history:

1.0: Added Razor helper
0.9 Initial release


Package owner

Bo Kingo Damgaard

Bo Kingo Damgaard

Bo has 456 karma points

Package Compatibility

This package is compatible with the following versions as reported by community members who have downloaded this package:
Untested or doesn't work on Umbraco Cloud
Version 10.0.x (untested)
Version 9.3.x (untested)
Version 9.2.x (untested)
Version 9.1.x (untested)
Version 9.0.x (untested)
Version 8.18.x (untested)
Version 8.17.x (untested)
Version 8.16.x (untested)
Version 8.15.x (untested)
Version 8.14.x (untested)
Version 8.13.x (untested)
Version 8.12.x (untested)
Version 8.11.x (untested)
Version 8.10.x (untested)
Version 8.9.x (untested)
Version 8.8.x (untested)
Version 8.7.x (untested)
Version 8.6.x (untested)
Version 8.5.x (untested)
Version 8.4.x (untested)
Version 8.3.x (untested)
Version 8.2.x (untested)
Version 8.1.x (untested)
Version 8.0.x (untested)
Version 7.15.x (untested)
Version 7.14.x (untested)
Version 7.13.x (untested)
Version 7.12.x (untested)
Version 7.11.x (untested)
Version 7.10.x (untested)
Version 7.9.x (untested)
Version 7.8.x (untested)
Version 7.7.x (untested)
Version 7.6.x (untested)
Version 7.5.x (0%)
Version 7.4.x (50%)
Version 7.3.x (untested)
Version 7.2.x (untested)
Version 7.1.x (untested)
Version 7.0.x (untested)

You must login before you can report on package compatibility.

Package Information

  • Package owner: Bo Kingo Damgaard
  • Created: 21/06/2013
  • Current version 1.0
  • License MIT
  • Downloads on Our: 1.2K

External resources