Displaying PDF content within Silverlight - silverlight

The requirement is below:
--> The version of Silverlight is 3.0
--> I don’t want to convert it to jpg, png etc. since I want end user to copy data from the displayed data.
--> I am currently using IFrame to display pdf but it has some problems like IFrame not supported consistently across different browsers.
--> I could not find any control (third party) that displays pdf with SL 3.0 Most of the controls that I came across are either for 4.0 or does conversion into some png kind of format which doesn’t allow user to copy data. If there is nothing that can be done from SL easily then I am ready to use 3rd party controls that are meant to work with SL 3.0 and allow end user to copy data.
--> I thought about reading data from pdf and displaying again over some control like text block but this would eventually become complicated for scenarios where I have to maintain formatting and displaying images etc.
Please suggest on this.

I think you gonna lose this one. I don't know of anything that renders PDF well in Silverlight 4 let alone Silverlight 3.
Whilst this comment "IFrame not supported consistently across different browsers" may be true IFrame is generally supported by the all major browsers.
Hence your best bet is to test and tweak your IFrame solution with these browsers.
Alternatively launch an independent browser window to display the PDF or let the users local system use whatever it has installed to display the PDF.

Related

Scraping Data from Silverlight Control within Browser

I have been using Excel VBA and WPF applications to scrape data from various websites, and all has gone well. But now I have run into something I cant get past.
The website is displaying its data within a Silverlight control:
<OBJECT width="100%" height=400 id=rnSilverlightGrid
data="data:application/x-oleobject;base64,QfXq3+...blah blah thousands of characters...AAAA=="
type=application/x-silverlight-2
</OBJECT>
(Left out what I thought was not helpful.)
getElementById("rnSilverlightGrid") returns nothing, but I am able to get a handle to the object with ie.document.all.tags("Object").Item(0), but have been unable to go further into the object to get data.
Can anyone tell me how now to get the data out of this Silverlight grid? This is currently coded in Excel VBA, but if necessary I can switch to WPF and use the WebBrowser control. I would rather not make the switch if avoidable (not sure how to do it there either anyways). I looked into White (seems like a dead end), and have seen other questions about this which have gone unanswered.
Thanks in advance!
Silverlight has the capability to make certain objects available to JavaScript calls so that JavaScript developers can affect the Silverlight application externally.
These are called "Scriptable Objects".
further reading: https://msdn.microsoft.com/en-us/library/cc645085(v=vs.95).aspx
My understanding is that this feature is available in SL4 and SL5.

How to annotate a PDF document in WPF

First I need to show a PDF File in an WPF application . It appears the only two ways are using a web control or some sort of WinForms/Com based solution using the Acrobat reader component.
Assuming I get it to show up in a UI my problem is I want to add annotations to the PDF itself. Is this even possible.

Silverlight PDF Viewer

I want to be able to show PDF docs within my Silverlight 4 application. I know there is no native support for this and the only real way to do this is to use a third party control. I’ve looked around and found what looks to be a couple of good options, but they are expensive and somewhat limited. I don’t know much about PDF docs, but it seems that most of these controls are converting PDFs to something else; such as XOD or XPS.
I am considering writing my own PDF Viewer for my needs, but not sure where to start on something like this. What would be the best format to convert PDFs to for Silverlight and WPF? If I could convert to RTF, I could use existing controls to display the document.
I’m assuming since there is such a lack of PDF for Silverlight controls out there that this will not be easy. Any help or guidance is greatly appreciated.
Thanks,
-Scott
You do have one more option besides re-implementing a pdf control.
With a bit of javascript and silverlight's DOM bridge, you can render your PDF in the browser's native pdf plugin and display it in a 'window' over the top of your silverlight application.
This is how many of the 3rd party "web browser" controls for silverlight work as well.

What controls should I use on a Silverlight website for loading textual content?

I am embarking on development of a Silverlight based website. I am the lone developer and am doing it on my own (ie, not for any company).
Now I want to load a lot of textual content on the website along with animations and rich user interfaces that can be created using Silverlight. The text content may change from time to time and when that happens, I don't want to do a lot of rework. So I m thinking to load the text from a Word/text file into controls and whenever new content arrives/existing content is modified, I just have to append it to the Word/text file.
This way the application itself remains untouched, only the file contents keep changing. Silverlight doesn't support FlowDocument. RichTextBox doesnt have a Load or LoadFile property. So how do I go about this? Should I make use of Frame, Downloader and similar other controls as well? What do you suggest? What would be the best approach to this?
The RichTextBox does have a Xaml property so you could download Xaml files containing the restricted set of textual elements that RichTextBox supports. You could also create a Silverlight editor around which you could create and upload this Xaml text content.
However have you considered whether Silverlight is the right platform to deliver primarily textual content? HTML is pretty good at that and with frameworks such as JQuery you can create quite interactive experiences that work well across browsers.

Can I re-use a Silverlight app in different areas of my page?

I've got a single Silverlight app that I'd like to display in a grid. The way the Silverlight app displays its content is dependent on the unique ID of the record in each grid row. Unfortunately, the XAP file is re-downloaded for each row in the grid. With a size of 700KB, this really impacts performance. Is it possible to download the XAP file once and then just re-use it for each row in the grid?
Once a XAP is downloaded Silverlight will cache the assemblies etc locally per instance of a Silverlight control. If you create another instance of a Silverlight control then this in turn has it's own domain that it in turn looks after.
My suggestion is to abstract out the parts you requrie and bake them into a seperate xaml, then load them into areas where you need them the most. If you still require a central .xap to handle the marshalling / event management etc then in Silverlight 3 we've put in place a Local Connection API which allows other Silverlight instances to talk to one another within the one browser page locally (ie SilverlighA can talk to SilverlightB all within index.html)
This can then allow you to establish a sort of local proxy if you will.
Scott Barnes / Rich Platforms Product Manager / Microsoft.
I'm not sure you can. Theoretically it should be cached, but in this case theory don't seem worth squat.
It's all down to the way the < object > tag behaves with it's various params and this is (another) one of the "sparsely" documented areas of silverlight.
It is possible but not easy to do. You could download the xap and save it to IsolatedStorage and create a silverlight host each time you need one referencing your cached xap but you only have 1MB space available and you aren't guaranteed that if you have other silverlight apps from the same domain.
Given what you described I still don't see any value in doing what you want to do. I think you have it backwards.

Resources