This is a migrated thread and some comments may be shown as answers.

Open PDF document within LightBox control?

7 Answers 801 Views
LightBox
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 1
Jason asked on 23 Feb 2014, 05:34 PM
Hello,

Is it possible to open/display a PDF document within the LightBox control?  If so, can you please provide a simple example.

Thanks!

7 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 26 Feb 2014, 06:26 AM
Hi Jason,

Please have a look into the sample code snippet to achieve your scenario.

ASPX:
<asp:Image ID="Image1" AlternateText="Mountain Pine Cones Thumbnail" runat="server"
    ImageUrl="~/Images/Icon-small.jpg" />
<telerik:RadLightBox ID="RadLightBox1" runat="server" Width="780px" Height="600px"
     Modal="true">
    <Items>
        <telerik:RadLightBoxItem TargetControlID="Image1">
            <ItemTemplate>
                <iframe id="iframe3" runat="server" width="600px" height="600px" src="Getting Started.pdf">
                </iframe>
            </ItemTemplate>
        </telerik:RadLightBoxItem>
    </Items>
</telerik:RadLightBox>

Hope this will helps you.
Thanks,
Shinu.
0
Jason
Top achievements
Rank 1
answered on 27 Feb 2014, 06:38 PM
Thank you Shinu, that did the trick!
0
Jon
Top achievements
Rank 1
answered on 03 Feb 2015, 02:52 AM
Thanks, also what I was looking for, but I have a follow-up question, is it therefore possible to set the pdf's src in the code behind ?
0
Daniel
Telerik team
answered on 05 Feb 2015, 12:47 PM
Hello Jon,

There is an easier way to display the PDF file in RadLightBox. The control supports iframes directly so you can just the set NavigateUrl property to point to the desired PDF file. Both client and server approach is possible. In my opinion this would be a better way compared to using templates.
<telerik:RadLightBox ID="RadLightBox1" runat="server">
    <Items>
        <telerik:RadLightBoxItem NavigateUrl="~/test.pdf">
        </telerik:RadLightBoxItem>
    </Items>
</telerik:RadLightBox>

Server-Side Basics
Client-Side Basics
Adding RadLightBox items on Client

Regards,
Daniel
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Marc
Top achievements
Rank 1
answered on 15 Feb 2015, 08:37 AM
Hi Jason, Could you post a link to your PDF being displayed in a light box instead of a tab?

I am particularly interested to see how this works in a mobile browser.

When a PDF is opened in a desktop using a lightbox, you still get all the usual controls to print, save etc.

In a Mobile browser, the browser controls the share etc. but it doesnt recognize the presence of the lightbox with share for example as it would normally do if opened in a new tab. This is for iOs devices. For Android, it will save the PDF to the phone regardless if opened set to open in a new tab or lightbox.




0
Marc
Top achievements
Rank 1
answered on 15 Feb 2015, 08:38 AM
Hi Daniel,

Sorry, I should have posted this question to you ...

I am particularly interested to see how this works in a mobile browser.

When a PDF is opened in a desktop using a lightbox, you still get all the usual controls to print, save etc.

In a Mobile browser, the browser controls the share etc. but it doesnt recognize the presence of the lightbox with share for example as it would normally do if opened in a new tab. This is for iOs devices. For Android, it will save the PDF to the phone regardless if opened set to open in a new tab or lightbox.




0
Daniel
Telerik team
answered on 18 Feb 2015, 03:45 PM
Hello Marc,

I believe this is an expected behavior. For best consistency across browsers I would recommend that you try pdf.js as demonstrated in the following blog post. You can easily modify the example to use RadLightBox if you prefer it over RadWindow.
Building an ASP.NET PDF Viewer with Telerik Window Control and PDF.js

Browsers do not necessarily have a built-in PDF reader. Even if they do, they may be designed to open the PDF file in fullscreen for better mobile experience for example.
RadLightBox does not have a built-in PDF reader so this behavior is out of our control.

Let me know if you need more information.

Regards,
Daniel
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
LightBox
Asked by
Jason
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Jason
Top achievements
Rank 1
Jon
Top achievements
Rank 1
Daniel
Telerik team
Marc
Top achievements
Rank 1
Share this question
or