How to display pdf using iframe in Microsoft Teams - javascript

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.

Related

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

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
}

Embed PDF File Hosted on Google Drive on Website

There is a team drive full of PDFs.
I have set up oauth2 and can successfully login users. They can then enter in a file Id and my site will return all of the metadata for that file.
However I cannot seem to embed this PDF file. In the metadata there are two urls:
webContentLink
webViewLink
I tried creating an iFrame with both links but neither work.
Is this even possible to do?
I am using JS to do all of this and I am requesting the https://www.googleapis.com/auth/drive.metadata.readonly scope.
webContentLink and the embeddable link have minor differences.
webContentLink:
https://drive.google.com/file/d/PDF_DRIVE_ID/view?usp=drivesdk
Embed URL:
https://drive.google.com/file/d/PDF_DRIVE_ID/preview
Right now, I haven't seen a direct API method to fetch the embedabble link but if you plan to do this by code, you can just manipulate the webContentLink so that it removes the view?usp=drivesdk part and replace it with preview.
Sample snippet:
<iframe src="https://drive.google.com/file/d/PDF_DRIVE_ID/preview" width="640" height="480"></iframe>

Phantomjs - take screenshot of a html page

I created a html page (stored locally) that uses Googlemaps API. My whole page is a basic google map with some customization. I want to take a screenshot every time I change some parameters in the customization so later I can easily compare.
I've found this similar answer and I got it to work on my machine. However, when I change the url from an actual webpage into my own local html file, Phantomjs only saves an entirely black image.
Here is my script.
var WebPage = require('webpage');
page = WebPage.create();
page.open('googlemaps_demo.html');
page.onLoadFinished = function() {
page.render('myScreenShot' + '.png');
phantom.exit();}
The file googlemaps_demo.html and this js script itself are in the same folder. Could someone explain to me why this code only works for an online url, but not a local html file? And how to fix it?
You probably need to specify file using a file:/// scheme and a full location of your file, e.g. file:///c:/local/page.htm

Open PDF with headless browser Phantomjs

I have a pdf that is hosted on an s3 server, I would like to open the pdf and take screenshots within phantomjs. Everytime I get a status of fail. I looked around and cannot seem to find an easy solution
var page = require('webpage').create();
var link = 'http://vfs.velma.com/Velma/testcard.pdf';
page.open(link, function(status) {
if (status!=='success') {
console.log(status);
phantom.exit();
}
console.log(status);
phantom.exit();
});//ends page open()
I searched the docs but found nothing regarding opening a pdf. My ultimate goal is to screenshot the pdf and injecting an overlay image with jquery. Is this possible using only phantomjs and jquery?
PDF file is not a webpage, so naturally PhantomJS will not render it. However there are projects and services that make possible rendering PDF in a browser, like Mozilla's pdf.js or Google's online PDF viewer.
Since those produce valid HTML, you could work with them in PhantomJS.

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

Categories

Resources