Copied to clipboard

Flag this post as spam?

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


  • Ishan Vyas 67 posts 198 karma points
    Jan 29, 2019 @ 09:09
    Ishan Vyas
    0

    upload the pdf file in umbraco

    I have pdf files i want to know how can i upload it and use it as we upload a image and when we click it, it displays so i want the same functionality for this pdf files also, when i click on the link it opens the pdf file in new window. so can any one guide me through this.

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Jan 29, 2019 @ 09:45
    Alex Skrypnyk
    1

    Hi Ishan

    There is no difference between images and pdg for rendering.

    Just upload pdf file to Media library and render it the same way as an image.

    Alex

  • Ishan Vyas 67 posts 198 karma points
    Jan 29, 2019 @ 10:23
    Ishan Vyas
    0

    so you mean to say as i upload the image with the syntax like below string catalogImage1Url = ""; if (Umbraco.AssignedContentItem.HasValue("catalogImage1")) { catalogImage1Url = Umbraco.AssignedContentItem.GetPropertyValue<IPublishedContent>("catalogImage1").Url; } and accessing the image with below line <img src="@catalogImage1Url" alt=""/>

    i can do the same with the pdf's also just have to upload the pdf file in media section?

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Jan 29, 2019 @ 10:25
    Alex Skrypnyk
    1

    Yes, but you have to render pdf file as a link to download, tag is only for images.

  • Ishan Vyas 67 posts 198 karma points
    Jan 29, 2019 @ 10:33
    Ishan Vyas
    0

    Alex sir, can you please elaborate it can you please give me a example of it, like syntax how can to render the pdf file as a link.

  • Søren Mastrup 122 posts 564 karma points c-trib
    Jan 29, 2019 @ 10:57
    Søren Mastrup
    101

    As Alex says, you can't render a PDF file in an image tag. Currently you are doing this:

    <img src="@catalogImage1Url" alt=""/>
    

    You should be doing this, for PDF files:

    <a href="@catalogImage1Url" target="_blank" title="Download PDF">Download PDF file</a>
    
  • Ishan Vyas 67 posts 198 karma points
    Jan 29, 2019 @ 11:04
    Ishan Vyas
    0

    Thank you Søren Mastrup sir & Alex Skrypnyk sir it worked out for me.Thanks for the immediate response!!

Please Sign in or register to post replies

Write your reply to:

Draft