Document support (rtf, doc, docx) for UWP/Windows 10 Mobile - win-universal-app

How can I display documents (doc, docx, rtf) in an UWP app? The WebView isn't able to do this.
Other options would be calling an external application with Windows.System.Launcher.LaunchUriAsync (e.g. Word) or using a 3rd party library. The requirement is to have the data in the app, because you don't have control over it, if it's handled to another one. Another option would be to convert it to another format (e.g. PDF) which UWP can handle (not really).
Any ideas?

If you would like to display word or pdf files in the UWP app you can use WebView control with Google Docs Viewer - I was using it for the online documents.
This is the code:
XAML:
<WebView x:Name="MyWebView"/>
Code behind:
public WebViewPage()
{
this.InitializeComponent();
loadWebView();
}
void loadWebView()
{
var googleDocsViewer = "http://drive.google.com/viewerng/viewer?embedded=true&url=";
var pdf = "http://www.uma.es/precarios/images/pdfs/wd-spectools-word-sample-04.doc";
MyWebView.Navigate(new Uri(googleDocsViewer + pdf));
}
I did not test it with local files, but I think that should also work. Please try and let me know.

UWP can actually handle RTF files with RichEditBox - for more info about that see here in the official documentation (I don't know about RichTextBlock). For Docx support I can recommend a third-party library by Syncfusion, which you can get for free if you meet certain requirements.

Related

Why my custom C# extention does not execute when deployed to Spotfire WebPlauer/Consumer

I have a simple custom Add-in that just displays a message to the user.
namespace GeorgiSpotfireCustomExtention
{
public class GeorgiEvent : CustomApplicationEventHandler
{
protected override void OnApplicationInstanceCreated(AnalysisApplication application)
{
base.OnApplicationInstanceCreated(application);
MessageBox.Show("On Application Instance Created");
}
}
}
That is my CustomAddIn class:
public sealed class CustomAddIn : AddIn
{
// Override methods in this class to register your extensions.
protected override void RegisterApplicationEventHandlers(ApplicationEventHandlerRegistrar registrar)
{
base.RegisterApplicationEventHandlers(registrar);
registrar.Register(new GeorgiEvent());
}
}
I am just trying to learn the package deployment process. When I am running it locally - in the installed Spotfire Analyst client it displays the message just fine:
However, when I package the extention, add it to the server (via the "Deployments & Packages" section, adding the "spk" file and then saving the area, the message is not shown when I try to open a document in the WebPlayer/Consumer.
Notes: I am choosing "TIBCO Spotfire Any Client" for my intended client in the Package Builder when building the spk file.
from the Spotfire Wiki (emphasis mine):
WinForms graphical user interface is a component of the .NET Framework and not something supplied by Tibco Spotfire. It's not recommended to implement solutions using Forms, but sometimes it could be handy when debugging. There is no commitment that it will work in future versions of the Analyst client. Forms are not supported on the Web Player.
the example listed on the wiki is for IronPython, but presumably the same holds true for C# extensions.
Correct. My assumption, and I don’t really know a lot about .NET, so this is not absolute, is that the form is rendered on the machine executing the code. In the case of your example above, the dialog would pop on the Node Manager host. If you’re really set on using an alert like this, you can accomplish it in JavaScript with an ‘alert()’. There is probably a way to render dialogues o in the web client too, but I don’t know it offhand.

Unable to open Google Play store with Xamarin.Forms Portable class Library

Currently I use this to try and open the Google Play Store directly to my app however this does not work.
var intent = new Intent(Intent.ActionView, Uri.Parse("market://details?id=" + appPackageName));
In a Forms PCL project, you can open a URI by using Device.OpenUri()
Device.OpenUri(new Uri("http://www.google.com"));

How to Upload images from local folder to Sitecore

`webClient.UploadFile("http://www.myurl.com/~/media/DCF92BB74CDA4D558EEF2D3C30216E30.ashx", #"E:\filesImage\Item.png");
I'm trying to upload images to sitecore using webclient.uploadfile() method by sending my sitecore address and the path of my local images.But I'm not able to upload it.I have to do this without any API's and Sitecore Instances.
The upload process would be the same as with any ASP.net application. However, once the file has been uploaded you need to create a media item programtically. You can do this from an actual file in the file system, or from a memory stream.
The process involves using a MediaCreator object and using its CreateFromFile method.
This blog post outlines the whole process:
Adding a file to the Sitecore Media Library programatically
If you're thinking simply about optimizing your developer workflow you could use the Sitecore PowerShell Extensions using the Remoting API as described in this this blog post
If you want to use web service way than you can use number of ways which are as follows:
a) Sitecore Rocks WebService (If you are allowed to install that or it is already available).
b) Sitecore Razl Service(It is third party which need license).
c) Sitecore Powershell Remoting (This needs Sitecore PowerShell extensions to be installed on Sitecore Server).
d) You can also use Sitecore Service which you can find under sitecore\shell\WebService\Service.asmx (But this is legacy of new SitecoreItemWebAPI)
e) Last is my enhanced SitecoreItemWebAPI (This also need SitecoreItemWebApi 1.2 as a pre-requisite).
But in end except option d you need to install some or other thing in order to upload the image using HTTP, you should also know the valid credentials to use any of above stated methods.
If your customers upload the image on the website, you need to create the item in your master database. (needs access and write right on the master database) depend on your security you might consider not build it with custom code.
But using the Sitecore webforms for marketers module With out of the box file upload. Create a form with upload field and using the WFFM webservices.
If you dont want to use Sitecore API, then you can do the following:
Write a code that uploads images into this folder : [root]/upload/
You might need to create folder structure that represent how the images are stored in Sitecore, eg: your images uploaded into [root]/upload/Import/ will be stored in /sitecore/media library/Import
Sitecore will automatically upload these images into Media library
Hope this helps
Option: You can use Item Web API for it. No reference to any Sitecore dll is needed. You will only need access to the host and be able to enable the Item Web API.
References:
Upload the files using it: http://www.sitecoreinsight.com/how-create-media-items-using-sitecore-item-web-api/
Enable Item Web Api: http://sdn.sitecore.net/upload/sdn5/modules/sitecore%20item%20web%20api/sitecore_item_web_api_developer_guide_sc66-71-a4.pdf#search=%22item%22
I guess that is pretty much what you need, but as Jay S mentioned, if you put more details on your question helps on finding the best option to your particular case.
private void CreateImageIteminSitecore()
{
filePath = #"C:\Sitecore\Website\ImageTemp\Pic.jpg;
using (new SecurityDisabler())
{
Database masterDb = Sitecore.Configuration.Factory.GetDatabase("master");
Sitecore.Resources.Media.MediaCreatorOptions options = new Sitecore.Resources.Media.MediaCreatorOptions();
options.FileBased = true;
options.AlternateText = Path.GetFileNameWithoutExtension(filePath);
options.Destination = "/sitecore/media library/Downloads/";
options.Database = masterDb;
options.Versioned = false; // Do not make a versioned template
options.KeepExisting = false;
Sitecore.Data.Items.MediaItem mediaitemImage = new Sitecore.Resources.Media.MediaCreator().CreateFromFile(filePath, options);
Item ImageItem = masterDb.GetItem(mediaitemImage.ID.ToString());
ImageItem.Editing.BeginEdit();
ImageItem.Name = Path.GetFileNameWithoutExtension(filePath);
ImageItem.Editing.EndEdit();
}
}

How can you read the fields from a password-protected PDF using iText when you do have the PDF password?

I have a PDF created from LiveCycle Designer in PDF 1.7.
I'd like to read some fields in that PDF on the server side at times. I have the password that protects the PDF on the server side.
I am able to use iText for this for non-encrypted PDFs just fine...
PdfReader reader = new PdfReader(request.getInputStream());
AcroFields af = reader.getAcroFields();
Map<String, AcroFields.Item> afFields = af.getFields();
for (String key : afFields.keySet()) {
System.out.print(key + " = ");
System.out.println(af.getField(key));
}
But when I do that same thing for a PDF that is password protected, this seems to break down. I get no fields returned.
Is there some way I can send that password into iText and be able to read the fields?
I also have access to the LiveCycle ES3 SDK as well. Maybe they provide an API to do that?
The answer, in case anyone was seeking for it, was to abandon the use of iText when trying to read data from a LiveCycle created PDF from your java app. I was so used to using Open Source APIs, I forgot to utilize the LiveCycle Web Services that they provided.
They provide a workbench product that lets you string web services together. And one of the many web services offered was an EncryptionService that can decrypt a password protected PDF, and then another service that can get an XML representation of the data in the PDF.
So I simply called those two services, and done.

Calling Office Communicator via Silverlight Out of Browser

I need to invoke office communicator to create a chat window and phone call directly from Silverlight when running out of browser. When running in browser I do this and it works pretty well:
System.Windows.Browser.HtmlPage.Window.Eval(String.Format("window.open(\"sip:{0}\", target=\"_self\");", sip));
When running out of browser as far as I have gotten is to invoke the Communicator.UIAutomation via a dynamic but honestly I don't know what to do next.
dynamic communicator = AutomationFactory.CreateObject("Communicator.UIAutomation");
Anyone have any suggestions on how to make this work? Searching has yeilded zero results.
A couple thoughts:
Have you tried making the automated Communicator object a var, then setting a breakpoint and digging into the resulting hydrated object? You might find some methods or properties on the object you can use to make things happen.
There's a blog here that describes the Office Communicator SDK and has some sample projects. I think you might be able to include the SDK assemblies in your OOB app and automate Communicator using Microsoft's provided SDK.
The SDK has to be preinstalled in the user machines. There's no easy way to deploy it along your Silvelright OOB application.
You will need the SDK.
You can check the documentation for more details here: C:\Program Files (x86)\Microsoft Office Communicator\SDK\OCSDK.chm
It mainly refers to C#, but most of it could easily be ported to Com Automation. As an example look at the following code to start a conversation
dynamic comm = new ActiveXObject("Communicator.UIAutomation");
dynamic msgrAdv = comm.IMessengerAdvanced;
if(msgrAdv!=null)
{
try
{
object obj = msgrAdv.StartConversation(
1, //CONVERSATION_TYPE.CONVERSATION_TYPE_IM,
sipUris, // object array of signin names
null,
"Testing",
"1",
null);
windowHandle = long.Parse(obj.ToString());
}
catch (COMException ex)
{
this.writeToTextBox(
formReturnErrors.returnComError(ex.ErrorCode)
);
}
I hope this help. Noticed that from the example in the help file I changed some of the members that are defined in the .NET Assembly (which can't be referenced from your C# code). If you need this, I would suggest opening the CommunicatorAPI.dll assembly in Reflector.

Resources