locked
Possible to display .pdf and other documents from Blend? RRS feed

  • Question

  • Is it possible to wire up something in Blend where you click a hyperlink and a .pdf (not on the Internet!) pops up; or a Word doc? I've tried dragging a .pdf to the artboard, but get the 'NO!' symbol. My dim understanding of these things thinks it may have something to do with accessing the O/S's API?
    Thursday, April 21, 2011 2:47 PM

All replies

  • Okay, so how 'bout if I save the .pdf as an image? I want it to pop up full size for printing. Can I get Silverlight to call another browser window to display it full size, as my main app is restricted to 1024 by 768?
    Thursday, April 21, 2011 3:36 PM
  • Which platform are you targeting? In WPF you can do this fairly easily, but in Silverlight it will be more difficult.
    Thursday, April 21, 2011 3:46 PM
    Moderator
  • I'm creating a browser based app to run in the browser on any platform. I've seen tutuorials for out-of-browser stuff, but I imagine this would only work for Windows.
    Thursday, April 21, 2011 4:04 PM
  • Seems like there might be a couple of ways to do this, depending on your full requirements. You can open a childwindow in SL, this isn't a separate browser window, but it could be a different size the what you currently have on screen I believe. This could display an image such as .png. You can also interact with the browser bridge to create an iframe or something of that nature to display it (although if isn't hosted on the web that might be harder).

    Assuming you can host it on the web, you could just have a hyperlink to the pdf.

    You could use the SL printing API to print whatever you want though, I don't think it has to be rendered any particular way on screen.

     

    Thursday, April 21, 2011 4:11 PM
    Moderator
  • Linking to an existing document on the web and having it open in another browser window is pretty straightforward, even for me (well, once I found out how to do inline links in text)  :)

    I'll look up ChildWindow, but what is the SL printing API - don't you just use the browser's printing abilities?

    Thursday, April 21, 2011 6:14 PM
  • Here is a good intro:

    http://www.silverlightshow.net/items/A-look-at-the-Printing-API-in-Silverlight-4.aspx

    You can print things that aren't displayed I believe as well with the printing API.

    • Marked as answer by Kvinneby Thursday, May 12, 2011 8:06 PM
    • Unmarked as answer by Kvinneby Thursday, May 12, 2011 8:06 PM
    Thursday, April 21, 2011 6:22 PM
    Moderator
  • Well it's been a couple of weeks and I've just got around to playing with ChildWindows. Once again, I've looked around the net, tried to find something that I can understand, but there doesn't seem to be an obvious way in Blend 4 to simply open a ChildWindow - I would have thought a button; and I've gone as far as actually coding 'ChildWindow.show' in the Button_click event, but the child window opens covering my whole parent window, won't close, in the Blend UI constantly resizes itself on the artboard, and behaves like, well, a child :)

    Is a ChildWindow one of the things you can't control entirely in the Blend UI? All I'd like to do at this point is open a ChildWindow displaying some text (with maybe a hyperlink or two in the text, so obviously I'd put a RichTextBox on it) on one of the pages of my Silverlight app. What's the easiest way to do this?

    Thursday, May 12, 2011 8:06 PM
  • Can we take a step back here and ask what is your overall goal? I suggested possibly using ChildWindow but I don't think I completely understand what you are trying to do and what the requirements are.
    Thursday, May 12, 2011 8:08 PM
    Moderator
  • I've got a Silverlight + Website project in which I have several pages that show up in a frame on the main page. Each of these pages has only a finite amount of room to display information; mostly text and pictures. I've used animations that make pictures and text appear from Collapsed or Scaled to x=0, y=0. These animations take some fiddling and I'd like to add more, but I thought I could make it a bit easier by just having a Child Window appear. It seems logical to use them, but there appears to be no easy way to open one, which is very odd to me.

    So, 1st consideration is just to have an alternative to popping up other forms of display, like collapsed textblocks, pictures and charts that can be collapsed again so other things can be displayed on the same page; 2nd is .pdfs:

    I do have links that open .pdfs from their parent websites, but there is the odd .pdf that would far better serve the project if it were included in the project and could be displayed from a button click. My app is constrained to 1024 x 768 but if a Child Window were to appear with a .pdf on it I'm guessing you could scroll through it even though it's confined to the parent window...?

     

     

    Friday, May 13, 2011 1:17 PM
  • It sounds like you may want to investigate UserControls instead of ChildWindow. Unless you need to additional functionality (and complexity) that comes with ChildWindow, UserControls are much simpler. They can be designed/edited separately, and can be displayed/controlled in your main page.

    Probably your best bet to embed it is to do what you suggested earlier and convert it to an image and use either the Image control, or an Image control inside a UserControl.

    Friday, May 13, 2011 1:22 PM
    Moderator
  • Isn't a user control just a page? So you're saying just add more pages to the project?
    Friday, May 13, 2011 1:29 PM
  • Pages and UserControls are conceptually similar, but UserControls are more meant for encapsulating "pieces". You sounded like you were showing/hiding multiple pieces of UI in a single Page, this is a good use case for dividing up some of the parts into UserControls to manage the complexity.
    Friday, May 13, 2011 1:55 PM
    Moderator
  • I've seen from tutorials how to create user controls, and that you use them to add multiple instances of something and even share them across projects. But I'm at a loss to understand how they would be used to help me display .pdfs...I think I'm conceptually missing something :)

    Friday, May 13, 2011 2:50 PM
  • They won't directly help you display pdfs, it will help with with this: "Each of these pages has only a finite amount of room to display information; mostly text and pictures. I've used animations that make pictures and text appear from Collapsed or Scaled to x=0, y=0. These animations take some fiddling and I'd like to add more, but I thought I could make it a bit easier by just having a Child Window appear". It seemed you were having trouble with organization, and wanted to use ChildWindow to help with that, I was just trying to point out that UserControl was probably easier.

     

    As far as I know there is no control in Silverlight to display pdfs. There are a few 3rd party controls linked in this post (http://forums.silverlight.net/forums/p/70573/177899.aspx) but I have no experience with any of them.

    You could also convert your pdf to an image such as a png and display that.

    Friday, May 13, 2011 2:55 PM
    Moderator