windows phone 8 official supported file icons - file

Does anyone know how to display the supported file type icons in WP8 ?
I have links on a xaml page which by clicking opens pdf, excel, word, powerpoints etc and these work nicely.
I would like to get the "official" icon which I can see for example in the office app in WP8 next to the link to indicate what kind of a file is in question.
I know from the file mimeType (for example application/pdf) what file is in question
Does anyone know how to accomplish this ?
Thanks,
Jani

Firstly, you need to get app product id, then use below code to get stream for official icon.
But you couldn't get icon of apps which are not scanned by InstallationManager.FindPackages().
IEnumerable<Windows.ApplicationModel.Package> apps = Windows.Phone.Management.Deployment.InstallationManager.FindPackages();
foreach(var app in apps)
{
if(app.Id.ProductId.Equals("APP_ID", StringComparison.InvariantCultureIgnoreCase)
{
var token = p.GetThumbnailToken();
var name = app.Id.Name + SharedStorageAccessManager.GetSharedFileName(token);
await SharedStorageAccessManager.CopySharedFileAsync(ApplicationData.Current.LocalFolder, name, NameCollisionOption.ReplaceExisting, token);
var file = await ApplicationData.Current.LocalFolder.GetFileAsync(name);
var randomStream = await file.OpenReadAsync();
Stream stream = randomStream.AsStream();
}
}

Related

Unable to display a PDF file in Angular app

I have a PDF file stored in a directory within the application (assets/pdf/fileName.pdf). I need to display it on a new tab on a button click from a dialog.
Here is what I have, after looking at various answers:
In *.component.ts:
openPDF() {
this.myService.fetchPDF().subscribe(
res => {
let file = new window.Blob([res], {type: 'application/pdf'});
let fileURL = window.URL.createObjectURL(file);
window.open(fileURL, '_blank');
}
);
}
In *.service.ts:
fetchPDF(): any {
const path = 'assets/pdf/fileName.pdf';
return this.httpClient.get(PathResolver.resolveStatic(path),{responseType : 'blob'});
}
I already tried using responseType : 'arraybuffer', but it didn't work out either.
Here are the threads I have looked at:
How to Display blob (.pdf) in an AngularJS app
Angular 2 download PDF from API and Display it in View
PDF Blob - Pop up window not showing content
Failed to load PDF document - Angular JS - BLOB
I am not sure why are you using httpClient. The outcome that you want could be simply achieved by the following code
In *.service.ts:
fetchPDF(): any {
const path = 'assets/pdf/fileName.pdf'
return path;
}
In *.component.ts:
openPDF() {
window.open(this.myService.fetchPDF(), '_blank');
}
You will either need to use the html embed tag (most likely also using a safe pipe), a PDF viewer (like Google PDF Viewer) or you can open the PDF in a new tab (this is the more common approach I see). It depends on your preference.

Google apps script, openByURL returns missing file?

I've been trying to figure out why part of my Google App script doesn't work, but I've failed to come up with an answer.
The script is downloading an attachment, CSV, from an email in Gmail and stores in with a specific name in a specific folder - this works perfectly fine.
But then I want to edit the CSV, and this is where I run into problems.
var newFolderIterator = DriveApp.getFoldersByName(destinationFolderName)
var newFolderId, myFileName, myFileId
while(newFolderIterator.hasNext()) {
newFolderId = newFolderIterator.next().getId()
var newFileList = DriveApp.getFolderById(newFolderId).getFiles()
while(newFileList.hasNext()) {
myFileName = newFileList.next()
myFileId = myFileName.getId()
var myFileURL = myFileName.getUrl()
Logger.log(myFileName.getId() + " " + myFileName.getName()) //Logs the ID and Name
Logger.log(myFileURL) //Logs the URL
var ss = SpreadsheetApp.openById(myFileName.getId()) //Error, cannot find the ID (error message: perhaps it's missing?)
}
}
I've tried using the openByURL as well, with the same error message.
Probably really easy to fix, any hints and tips is appreciated.
Thanks
The problem here is you are uploading a CSV but attempting to open it with SpreadsheetApp. SpreadsheetApp can only open Google Sheets documents, and your CSV is not automatically converted.
The CSV must first be converted to a Google Sheets document before you can access it with SpreadsheetApp.
You may be able to do this on upload, but I haven't tried this personally. This question looks relevant:
How to automatically import data from uploaded CSV or XLS file into Google Sheets

Registration with profile picture using services in Drupal

I've been trying to upload a user profile picture during the user registration using Service 3 and so far I haven't had any luck. I tested passing a hard coded fid in the field "picture" and also tried to pass the fields "filemime", "filename", etc. and it didn't work neither.
Any idea about what fields I need to populate?
I guess it must be related to this post Using Drupal Services and DIOS SDK for setting user picture in iOS app
but it doesn't have and answer neither.
I use following code -
//Picture is first uploaded from ios using file service and fid is passed in $data object
$file_contents_object = file_load($data->picture_fid);
$file_contents_array['fid'] = $file_contents_object->fid;
$file_contents_array['uid'] = $file_contents_object->uid;
$file_contents_array['filename'] = $file_contents_object->filename;
$file_contents_array['uri'] = $file_contents_object->uri;
$file_contents_array['filemime'] = $file_contents_object->filemime;
$file_contents_array['filesize'] = $file_contents_object->filesize;
$file_contents_array['status'] = $file_contents_object->status;
$file_contents_array['timestamp'] = $file_contents_object->timestamp;
$file_contents_array['rdf_mapping'] = $file_contents_object->rdf_mapping;
//use your cck field here
$user_obj->field_user_profile_picture['und'][0] = $file_contents_array;
Hope this will help.

How to play an attachment video from the timeline item

I want to insert a timelineitem with video attachment and if user selects a specific menu item, glass to play the video. I'm doing all from .net app like this, please correct me, if i'm doing wrong.
TimelineItem item = new TimelineItem()
item.MenuItems.Insert(0, new MenuItem(){Action="what is the action to use?";...});
request = Service.Timeline.Insert(item, attachment, contentType);
request.Upload();
I would like to know, do i need a menu item, if yes, what is the action i should use?
Currently i'm sending the video attachment, but there is no way to play the video.
Any help is greatly appreciated.
You don't need to specify any menuItems but your timeline item should not contain html content.
Make sure that your video is of a supported format: once it's inserted, and Glass has synced and fully downloaded the attached video, it should start playing right when you land on the item in your timeline.
This works using the QuickStart project for Java (mirror-java-starter-demo):
https://github.com/googleglass/mirror-quickstart-java
Replace the lines near line 119 in MainServlet.java with this:
URL url = new URL(req.getParameter("imageUrl"));
String contentType = req.getParameter("contentType");
url = new URL("http://localhost:8888/static/videos/video.mp4");
contentType = "video/mp4";
byte[] b = ByteStreams.toByteArray(url.openStream());
int i = b.length;
InputStream temp = url.openStream();
MirrorClient.insertTimelineItem(credential, timelineItem, contentType, temp);
Then run the project and click the "A Picture" button to upload a video from a new folder inside static called videos called video.mp4. I used a 10 second clip I recorded with glass (6.30 MB).
Note that when running with App Engine 1.76 on a windows machine I got this error when uploading, but changing to 1.80 made this issue go away:
Here is Windows metadata about the video that might be useful:
Depending on your network connection it might take a little bit for the video to show in your timeline, but mine plays.

how to save Extjs4 chart image to print in a pdf report?

i have several charts in my extjs4application dashboard..
i want to generate a pdf report using the images of those charts
for that i use iTextSharp
is there a way to get the images from the charts in order to include them in my report?
the ideal for me is to use it like this with itextsharp
MyImageStream = new MemoryStream();
myChart.SaveImage(MyImageStream);
my chart would be the chart object
i asked around in the forums they told me i would generate and render my chart at client (already done) and then i would get the svg, send it to the server and server would use it to generate the pdf...
but i dont know how to work with svg neither how to send it to server
EDIT
im trying to use wkhtmltoimage to save my chart into image
but its not working whan i specify a mapPath to my .aspx
but it works fine if i specify a website url or localhost path (see htem in comment)
by doesnt work i mean no error but no png created!
my code:
var url = HttpContext.Current.Server.MapPath("~/chartImage.aspx");//dosnt work
//works : // "google.com"; //"localhost/chartImage.aspx";//
var fileName = " pie13.png ";
var wkhtmlDir = HttpContext.Current.Server.MapPath("~/wkhtmltopdf/pdf/");//"C:\\Program Files\\wkhtmltopdf\\";
var wkhtml = HttpContext.Current.Server.MapPath("~/wkhtmltopdf/wkhtmltoimage.exe");//"C:\\Program Files\\wkhtmltopdf\\wkhtmltopdf.exe";
var p = new Process();
p.StartInfo.CreateNoWindow = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.FileName = wkhtml;
p.StartInfo.WorkingDirectory = wkhtmlDir;
string switches = "";
//switches += "--print-media-type ";
//switches += "--margin-top 10mm --margin-bottom 10mm --margin-right 10mm --margin-left 10mm ";
//switches += "--page-size Letter ";
p.StartInfo.Arguments = switches + " " + url + " " + fileName;
p.Start();
thanks in advance
Ok, here's a revised version after reading your comment above.
Ext JS is a client side library so you need to run it in a browser to get your charts and this can't be changed. If you really need to get these charts on the server then you must resort to some more or less dirty hacks. One of them would be:
Prepare a special web page that contains only the chart to be included in the PDF
Use wkhtmltoimage program to convert it into an image file (on the server)
Insert that image into PDF document using iTextSharp
But in this case I'd rather re-think the choice of tools or the way reports are generated.
Use wkhtmltopdf package (http://code.google.com/p/wkhtmltopdf/) to convert a web page with your charts into a pdf file and then let users download that pdf. In order to do that you need to run wkhtmltopdf server-side (pay attention to authentication/user impersonation).
Since wkhtmltopdf is based on Safari it should work with extjs without problems.
I am researching about this, I think you first have to convert your chart into a picture and then use a PDF generator library and include this picture on it.
To convert chart to picture:
http://dev.sencha.com/deploy/ext-4.1.0-gpl/examples/charts/Area.js
To generate PDF on c# if you are using it on server side it could be pdfsharp or itext

Resources