Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First of all, all but the last item can be done (the way you expect). Due to security protocols, silverlight cannot access the user's drive and manipulate it. The closest you can get is accessing silverlight's application storage which will be of no help to you whatsoever in this case. I will highlight how to do the first 4 items.</p> <ul> <li><p>Allow user to select folder location &amp; Show contents of folder</p> <pre><code>public void OnSelectPDF(object sender) { //create the open file dialog OpenFileDialog ofg = new OpenFileDialog(); //filter to show only pdf files ofg.Filter = "PDF Files|*.pdf"; ofg.ShowDialog(); byte[] _import_file = new byte[0]; //once a file is selected proceed if (!object.ReferenceEquals(ofg.File, null)) { try { fs = ofg.File.OpenRead(); _import_file = new byte[fs.Length]; fs.Read(_import_file, 0, (int)fs.Length); } catch (Exception ex) { } finally { if (!object.ReferenceEquals(fs, null)) fs.Close(); } //do stuff with file - such as upload the file to the server }; } </code></pre> <p>If you noticed, in my example, once the file is retrieved, i suggest uploading it to a webserver or somewhere with temporary public access. I would recommend doing this via a web service. E.g</p> <pre><code>//configure the system file (customn class) TSystemFile objFile = new TNetworkFile().Initialize(); //get the file description from the Open File Dialog (ofg) objFile.Description = ofg.File.Extension.Contains(".") ? ofg.File.Extension : "." + ofg.File.Extension; objFile.FileData = _import_file; objFile.FileName = ofg.File.Name; //upload the file MasterService.ToolingInterface.UploadTemporaryFileAsync(objFile); </code></pre></li> </ul> <p>Once this file is uploaded, on the async result, most likely returning the temporary file name and upload location, I would foward the call to some javascript method in the browser for it to use the generic "download.aspx?fileName=givenFileName" technique to force a download on the users system which would take care of both <strong>saving to a new location</strong> and <strong>printing</strong>. Which is what your are seeking. </p> <p>Example of the javascript technique (remember to include System.Windows.Browser):</p> <pre><code>public void OnInvokeDownload(string _destination) { //call the browser method/jquery method //(I use constants to centralize the names of the respective browser methods) try { HtmlWindow window = HtmlPage.Window; //where BM_INVOKE_DOWNLOAD is something like "invokeDownload" window.Invoke(Constants.TBrowserMethods.BM_INVOKE_DOWNLOAD, new object[] { _destination}); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } } </code></pre> <p>Ensure you have the javascript method existing either in an included javaScript file or in the same hosting page as your silverlight app. E.g:</p> <pre><code>function invokeDownload(_destination) { //some fancy jquery or just the traditional document.location change here //open a popup window to http://www.myurl.com/downloads/download.aspx? fileName=_destination } </code></pre> <p>The code for download.aspx is outside the scope of my answer, as it varies per need and would just lengthen this post (A LOT MORE). But from what I've given, it will "work" for what you're looking for, but maybe not in exactly the way you expected. However, remember that this is primarily due to silverlight restrictions. What this approach does is rather than forcing you to need a pluging to view pdf files in your app, it allows the user computer to play it's part by using the existing adobe pdf reader. In silverlight, most printing, at least to my knowledge is done my using what you call and "ImageVisual" which is a UIElement. To print a pdf directly from silverlight, you need to either be viewing that PDF in a silverlight control, or ask a web service to render the PDF as an image and then place that image in a control. Only then could you print directly. I presented this approach as a lot more clean and direct approach. </p> <p>One note - with the temp directory, i would recommend doing a clean up by some timespan of the files on the server side everytime a file is being added. Saves you the work of running some task periodically to check the folder and remove old files. ;)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload