Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • René 327 posts 852 karma points
    May 28, 2014 @ 16:10
    René
    2

    PDF Thumbnails - Umbraco7

    Hi

    I have it to work in Umbraco7 - Cant install the pacakage in Umbraco 7, so i had to install it manually

     

    1. Unzip the  pacakae
    2. Upload the Flexit.PdfThumbnails.dll, GhostscriptSharp.dll , gsdll32.dll, gsdll64.dll
    3. Add the reference
    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    @using Flexit.PdfThumbnails
    @*
        Macro Parameters To Create, for this macro to work:
        Alias:mediaId     Name:Media Folder ID    Type:Single Media Picker
    *@
    
    @if (Model.MacroParameters["mediaId"] != null)
    {
         @* Get the media folder as a dynamic node *@
        var mediaFolder = Umbraco.Media(Model.MacroParameters["mediaId"]);
    
        if (mediaFolder.Children.Any())
        {
            <ul>
                @* for each item in children of the selected media folder *@
    
                @foreach (var mediaItem in mediaFolder.Children)
                {
                    int mediaID = mediaItem.Id;
                    var pdf = PDFHelper.GetMedia(mediaID);
                    <li>
                        <h5><a href="@mediaItem.umbracoFile">@mediaItem.Name</a></h5>
    
                        @foreach (var thumb in pdf.PdfThumbs)
                            {
                                <a target="_blank" href="@pdf.Media.Url"><img height="200" src="@thumb.fileName" [email protected]""></a>
                            }
                        }
    
                    </li>
                }
            </ul>
        }
    }

    If this helps anyone

    René 

     

  • Eduardo J. Cortés 3 posts 25 karma points
    Oct 10, 2014 @ 22:39
    Eduardo J. Cortés
    0

    I honestly want this to work, but it doesn't.

    I upload the dlls, and then create this on "partial View Macro Files", but nothing happens. It's broken in some way.

    If you (or anybody else) could help, it would be greatly appreciated.

    :-)

  • Søren Mastrup 122 posts 563 karma points c-trib
    Oct 16, 2015 @ 18:09
    Søren Mastrup
    0

    This solution will also work in Umbraco 7.3.0

  • Sebastian Dammark 581 posts 1385 karma points
    Nov 19, 2015 @ 14:41
    Sebastian Dammark
    0

    Funny, it doesn't work for me. When I call the new GetMedia extension I can see that there is no 'pdfThumbnails' node in the XML

    <File id="4394" parentID="4386" level="3" creatorID="0" sortOrder="6" createDate="2015-04-27T11:46:20" updateDate="2015-11-19T14:34:55" nodeName="filename.pdf" urlName="filenamepdf" path="-1,2966,4386,4394" isDoc="" nodeType="1033" writerName="Sebastian Dammark" writerID="0" version="bec89a23-d2fa-40a9-b49e-44f9238e3bcd" template="0" nodeTypeAlias="File">
        <umbracoFile>/media/1921/filename.pdf</umbracoFile>
        <umbracoExtension>pdf</umbracoExtension>
        <umbracoBytes>4370118</umbracoBytes>
    </File>
    

    I expect the DLL's to be uploaded to BIN folder ?

  • Sebastian Dammark 581 posts 1385 karma points
    Nov 19, 2015 @ 14:45
    Sebastian Dammark
    0

    Just for info

    I can see the folder in the media folder /media/1921/pdfthumbnails

    And just for kicks, it would be nice if you could tell it what page to convert to PDF. That way you don't fill the server with unused JPGs

  • Søren Mastrup 122 posts 563 karma points c-trib
    Nov 19, 2015 @ 14:48
    Søren Mastrup
    0

    This should work:

    @using Flexit.PdfThumbnails
    
    int pdfId = Convert.ToInt32(CurrentPage.pdfProperty);
    var pdf = PDFHelper.GetMedia(pdfId);
    foreach (var thumb in pdf.PdfThumbs.Take(1)){
        @thumb.fileName
    }
    

    If not - Try saving your PDF-file in the media archive.

  • René 327 posts 852 karma points
    Apr 11, 2016 @ 14:59
    René
    0

    Hi

    New information to help out here.

    Just testet on Umbraco version 7.4.2

    Install this: https://our.umbraco.org/projects/pdf-preview/

    Add a media picker to a doc type

    Add the macro to a template.

    Example template:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage @{ Layout = null; var pdfId = Model.Content.GetPropertyValue("pDF"); var pdfUrl = Umbraco.TypedMedia(pdfId).Url; }

    Index PDF

    @Umbraco.RenderMacro("PdfPreview", new {LinkURL=pdfUrl, MediaId=pdfId, PageNum="1", QualityDPI="18"})

    Result:

    enter image description here

Please Sign in or register to post replies

Write your reply to:

Draft