How can users print whole documents from file preview in Microsoft Graph - javascript

We are using graph api in our app to allow users to view files hosted on our SharePoint site.
We can get the files (mainly Word documents) to load fine in a new tab, using the URL format of:
"https://graph.microsoft.com/v1.0/sites/" + siteId + "/drive/items/" + itemId + "/preview"
However, there seems to be no facility to print from here. If you use the browser to print, it will only get the first page of the document.
Is there any way to print the whole document without having to give the users the ability to download a copy first and open it locally?

Use the following request body:
{
"viewer":"office",
"chromeless":false
}

Related

show msg in modal in react or javascript

I have an interesting question:
I give the user the option to upload .MSG files to the system,
Inside the DB I keep the BASE64 of the file
Now I want to introduce the .MSG inside a model
And here I am having a problem
I'm unable to convert BASE64 back
I will note that I can see extensions of PDF and WORD
Using the PDFVUWER library...
I do not have a code because I do not know how to do it
Are you asking how to open an MSG file in JS? You'd need to use Outlook Object Model (Application.Session.OpenSharedItem), but that means JS would only be able to do that in IE.
JavaScript doesn't provide anything for drawing MSG files on the page. You need to use Outlook for opening such files if you want to display them to users. But that would be in Outlook (external application), not in the browser. Moreover, Outlook should be installed on the client side.
Instead, I'd recommend keeping the message body represented by the HTMLBody property value from the OOM in the Db. In that case you will be able to display it to a user like a regular web page. Note, the message body requires some processing before saving to the Db, so embedded images could be displayed.
When MSG files are uploaded to the application you can extract the required pieces of the file such as message body and etc. for displaying it at any point later. The MSG file format is described in the Outlook Item (.msg) File Format section of MSDN.

How to display pdf using iframe in Microsoft Teams

I have a C# pdf comparison app hosted on azure and i just want to display the compared pdf in iframe. This is working fine in a browser but when i am integrating it to teams the compared pdf is not showing in iframe. After clicking on compare button the output pdf is downloaded automatically but nothing is being display in iframe.
This is the block of code which i am using for embedding:
success: function (Data) {
if (Data) {
var embed1 = document.getElementById('outputPdf');
embed1.src = "../../PythonFile/OutputPdf/" + Data;
$("#outputPdf").css("display", "block");
}
},
<iframe id="outputPdf" type="application/pdf" style="display:none;width:100%" height="600"></iframe>
#Asif Hussain:
In Microsoft Teams, we have only be able to download the PDF file in "Files". It's not possible to precise the download file name or the download file location.
The use of PDF's needs to be improved with Microsoft Teams. There is no official solution - we have been waiting for one for a while. As workarounds, you could always look at using the Third Party Adobe applications, or if a PDF (s) is hosted on a site, look to use a web page tab and see if the ability to manipulate on the site pulls through.

Base64 PDF in new tab shows Blank Page before Refresh

The title says it all really... I have a base64 pdf string which I append to:
data:application/pdf;base64,
The pdf is brought into a new tab using a link in my webpage. A blank page will initially show up, but then I refresh the page and it displays perfectly.
This issue only began once I changed my NodeJS code for retreiving the PDF, before it was retreiving the PDF with the https module but now I am using request.
https://jsfiddle.net/o7upp4d8/
There is a current push to disallow new windows to have the ability to navigate to a data URL Intent to Deprecate and Remove: Top-frame navigations to data URLs. The "feature" is apparently already being implemented.
There was some objection raised to the idea, but apparently not enough; at least not yet.

How do I take a converted file (pdf to html), and open it locally in a new tab in google chrome?

Basically I have a django app that communicates with a chrome extension. I have a bunch of functionality that interfaces with normal HTML pages that's all done by the extension. I want to allow users to have the same functionalities for PDF files. I have a python script which translates the pdf file into an html page.
The problem I run into is when the pdfs are open locally within chrome.
Like the following file:///home/wcr5048/Downloads/sample_pdf.pdf
This is my current solution, it basically gets the html and replaces all the current html, which is just an embedded pdf, and replaces it with the converted pdf(html). But I run into an issue because the "url" isn't really a url, and therefore I can't append html to something that doesn't exist.
function convert_to_html(request) {
console.log('converting to html...');
document.getElementsByTagName('html')[0].innerHTML = request.data;
chrome.runtime.sendMessage({
detail: 'refresh'
});
}
What I don't want to happen is to download a file just like the pdf but one that's been converted into html. I would rather have everything happen automatically.
I only see two possible options:
I create a unique link for the converted pdf file for every user, and then send the raw html string to populate the corresponding view.
I somehow tell the extension to use a popup to cover the entire width of the screen, and then populate it with the data.
Are there any suggested solutions that would be a better fit, and if not, which would be a better solution.
Thanks for viewing

Javascript: Save json data as a file on the server / user's hard disk

I have developed an app that allows the user to fill out text fields with information. I want them to be able to press a button that will make a file with data (a really long array with info on what they typed and where it should go) so they can reload the data at a later date. I don't have a server now, and I am sending this app as a standalone html app to my friends for their use until I get hosing / mySql / etc.
Is there a way that when they click on a button it will take this data (saved as an array, save_data), put it into a file, and basically begin the download process from their web-browser?
And later on, what tech would I need to be looking into to save this into online user accounts?
It is posible, but only if you force your users to use windows and microsoft internet explorer. You can send the html file as a hta file, wich can write and read from data from the hard disk.
check http://msdn.microsoft.com/en-us/library/ms536496%28VS.85%29.aspx
for more information.
An hta file is basically a local html file with some extra tags in the header, and is run (interpreted) locally without security restrictions, like any exe file.
I don't know how to show the complete html code here,(markdown is not for me), so if you want an example:
1 - create a file test.hta, with the standard html, head, body and script tags
2 - inside head tag, insert
<HTA:APPLICATION
ID="oMyApp"
APPLICATIONNAME="test"
BORDER="yes"
CAPTION="yes"
SHOWINTASKBAR="yes"
SINGLEINSTANCE="yes"
SYSMENU="yes">
</HTA:APPLICATION>
3 - inside body tab put a button with onclick="writeText();"
4 - inside the script tag insert
function writeText(){
try{
var fso = new ActiveXObject("Scripting.FileSystemObject");
var fileObject = fso.OpenTextFile("C:\\testhta.txt", 8, true,0);
fileObject.WriteLine('text file written');
fileObject.close();
}catch(ex){
alert(ex);
}
}
5 - save it, doubleclick it, click on the button and you will get a nice "C:\testhta.txt" file with 'text file written' in it.
If you don't have a server, then no ... there is no way to initiate a file download/save based on dynamically generated data with javascript

Categories

Resources