I need to embed PDF files in an xpage application. We are using IE11 x64 and this cannot be changed. Eventually, I'll also need to embed MS Office files (Word, Excel, Power Point).
I have looked at a lot of pages and couldn't get a working solution for this... I have some code that works if I force IE11 in IE10 mode, but then Dojo starts acting weird (cannot close dialog boxes, ...).
The code I have right now in my computed field looks like this:
var id:string = pageDocument.getDocument().getUniversalID();
var attNames = #AttachmentNames();
var url = getAttachmentURL(id,attNames);
'<object data="' + url + '#view=Fit&pagemode=none&statusbar=0&messages=0"' +
'type="application/pdf" width="100%" height="100%" > ' +
'<p>It appears your Web browser is not configured to display PDF files. ' +
'No worries, just click here to download the file.</p>'+
'</object>'
I need a free solution.
IBM, This should be made easy if we want to compete with SharePoint, no???
Short answer: don't bother.
Long answer: While you might get it to work for PDF in IE11, your boss won't be happy, because it will not show on her iPad, so you need to have a plan B.... and there is another gotcha down the road (read below). This is what I would do:
Use Apache PDFBbox to extract text from the PDF and show that in the XPage.
Add a link to the page to open the whole PDF
Do the same thing for office documents using Apache POI eventually using OpenNTF POI4XPages
The download link should make use of WebDAV for Domino to allow round-trip editing
Why all this fuzz:
Your users will use mobile at some point of time and NO mobile browser does support embedding (nor do any browsers on a Mac)
Even if you successfully get embedding working, users will start to edit the embedded document and get really really upset since you don't save back the changes
On a side note: asking IBM to support a technology that is vendor proprietary working in one browser (that has been EOL for future updates - see project Spartan) - ain't going to happen.
I got this working nicely in IE11 for PDF files with this very simple line:
<embed src="MyPDFFile.pdf" width="640px" height="755px" alt="pdf" />
I'll go along with Stephen's answer: I won't bothe rtrying to mak ethis work with Office files. It will give our "Notes is bad" users some munitions to move to SharePoint, but we do have other advantages!
I tried using Bumpbox, and pdf.js and while I could get them working, iframes seemed to work best for me with using normal Domino attachment urls in xpages
I am not sure if this solution is right or not, but it works well for an app I have that only has PDFs. It does work on mobile too, at least on iOS.
<iframe
src="#{javascript:
var url = 'https://app.nsf/';
var doc = sessionScope.docID;
var atname = #RightBack(sessionScope.aname,'Body');
var end = '/$file'+atname;
return url+doc+end}"
width="800" height="1000">
</iframe>
Probably the best approach is to use a pure HTML5/JavaScript renderer
for PDF documents without any third-party plugins (e.g. PDF.js)
For further discussion take a look at the following stackoverflow
entry recommended way to embed pdf in html
In my opinion, it's the best way to use a commercial product (e.g. crocodoc) for other documents like MS Office (Word, Excel, etc.).
Related
We have a sharepoint online site with a good amount of pages that have href links to a shared in-house network server. Example: file://servername/sharedFolder This way when the user clicks the href - it directs them to the location in the file explorer if using IE or Edge.
Due to server maintenance - we needed to rename the server. So now "servername" is "servername1". This messes up all the links on the sharepoint site.
I need to iterate over all the pages on the sharepoint site, and fix the hrefs.
I apologize im very new to sharepoint so maybe im missing something very simple.
What i have right now is the following:
using (ClientContext ClientWebContext = new ClientContext("site"))
{
ClientWebContext.Credentials = new SharePointOnlineCredentials("username", ss);
Web web = ClientWebContext.Web;
Microsoft.SharePoint.Client.File file = ClientWebContext.Web.GetFileByServerRelativeUrl("page");
ClientWebContext.Load(web, w => w.Title, w => w.Description, w=> w.Lists);
ClientWebContext.Load(file, f => f.Length, f=> f.ServerRelativeUrl, f=> f.Name, f=>f.);
ClientResult<System.IO.Stream> str = file.OpenBinaryStream();
ClientWebContext.ExecuteQuery();
FileInformation fileInfo = Microsoft.SharePoint.Client.File.OpenBinaryDirect(ClientWebContext, file.ServerRelativeUrl);using (FileStream filestream = new FileStream("C:" + "\\" + file.Name, FileMode.Create))
{
fileInfo.Stream.CopyTo(filestream);
}
}
The idea was to download the page - parse the html and update the hrefs, then write the page back out to the sharepoint server. But when i view the file that has been downloaded it doesnt contain any of the html that is actually on the page.
If i go to a page, select "edit", then select "Edit Source" I can view and edit all the html in raw format.
I guess the question is - how do i get this html and how do i pro grammatically update it.
EDIT:
A typical sharepoint page contains a table, cells & text inside of those cells. The text then contains links to the server I was talking about above. The sharepoint site is essentially being used as a wiki for new employees and a resource for existing employees to find information quickly. It doesnt contain many complex web parts and embedded code, mainly just a table, cells and text.
Thanks,
-John
Yeah, I don't think this approach will fly.
Again, different types of SharePoint pages have different web parts. Modern SharePoint site page, Wiki page, web part page. They all can have text web parts and/or page elements that can hold HTML, and in some, the WYSIWYG default presentation can be changed to a HTML editor. Then there are also list web parts, link web parts, and all kinds of stuff that can have an underlying link URL.
But these page elements are SharePoint artifacts. The page elements and their contents are stored in an internal SharePoint database. The page chrome and styling is also stored in different parts of the database. The SharePoint server processes the different parts that make up a page. On the SharePoint server side, these page elements then get translated and rendered into HTML that is served to the end user's browser.
You cannot take this rendered end result and expect to use it to change the underlying source of the HTML.
You need to get to the source. Again, what exactly that source is depends on the type of page used. Just because it is "in SharePoint" doesn't identify the page type.
Sorry, I know this is not what you want to hear, but if you want to manipulate SharePoint content, you need to acquire an understanding of what SharePoint is and what its moving parts are.
When I set response content type as Excel, the Open/Save dialog is shown twice , just on IE8. It works fine on other browsers (tested on Chrome/Firefox/Opera).
The code for setting response content type is:
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-disposition","attachment;filename=abc.xls");
I searched for solutions/workarounds. Turning off Smartscreen didn't help.
Also, another suggestion was to wait for 5-10 sec before clicking Save/Open. That too didn't work.
What's the cause of this? Are there any IE specific workarounds?
It's a pain but IE8 is still widely used by the users.
This is just a guess, but it could have something to do with the way Office (used to) embed itself in IE with plugins.
A workaround might be putting it in a zip file before sending it over to the user.
I have been working with Vaadin charts during this week and I found a problem that I cannot solve. I need to send several charts to a PDF generation (using iTextpdf) and I could do it using SVGGenerator. The main problem is I cannot use this solution because the final laptop doesn't allow any installation, and Phantomjs is required for SVG Generator (no add-on can be installed neither). I tried to find a different solution to convert the chart content into file or buffer that I can manage, but I think I have been reading so much posts and I am not able to distinguish the solution.
So, I will try to clarify basic questions first:
a) Is it possible to manage SVG Generator without any installation in the laptop?
b) If not, is there a different way to convert a chart into an object which class could be managed to insert it into a PDF?
I can assure you I tried to read all documentation in this forum and official Vaadin forum related to this topic but I couldn't find any solution. I don't want to seem lazy, I only want to avoid spending more time and clarify the maining pre-conditions to solve this issue.
thanks in advance for your time and help.
Kind regards,
David.
You can take a screenshot of your chart and append it to pdf:
Screenshot screenshot = new Screenshot();
screenshot.setTargetComponent(myTargetComponent);
myChartLayout.addComponent(screenshot);
//when complete
screenshot.addScreenshotListener(new ScreenshotListener() {
public void screenshotComplete(ScreenshotImage image) {
//do something
}
});
//take screenshot
screenshot.takeScreenshot();
You will not be able to render a Vaadin Chart without a web browser engine of some kind. That's what PhantomJS provides. If you have a full-blown web browser at your disposal, though, you can grab the SVG markup manually from there; it's just a bit more difficult to automate. This works in Chrome:
Open your Charts app in the browser
Open the JavaScript console (Ctrl/Cmd + Shift + J)
Type something like this: copy(document.getElementsByTagName('svg')[0].outerHTML)
Paste the contents of your clipboard to a new text file and save it as an SVG.
You don't need to install phantomjs, just bundle its binary along with your web application (Reference). I did the same thing with my Amazon AWS deployment and it works just fine.
I am creating an ASP.NET web application. In one of my webpages (an ASCX control) I am placing a fusion chart inside a <div> tag. I want to provide an option for the client to download this fusion chart.
Is there any way that I can download
the fusion chart present in the Div
tag, as an image (Using javascript
because the div tag is a client side
control).
The request is that my client could save this fusion chart present in the <div> tag as an image when he visits the webpage.
The target browser is IE.
Please help me.
I can confirm that it is not possible to 'Export the chart as image' when using FusionCharts Free. However, as mentioned by Larsenal, you will be able to use FusionCharts v3.2.1 and it's updated JavaScript API to export pure JavaScript charts to JPEG, PNG, PDF, SVG formats.
Ref.- http://www.fusioncharts.com/docs/?ECPureJS.html
Furthermore, you may even export your Flash charts, if required, in a similar manner. DO check out the link below for a more detailed account of the same.
Ref.- http://www.fusioncharts.com/docs/?ECOverview.html
Hope this helps.
It is currently not possible to generate an image from a section of a webpage with JavaScript. Quoting myself from another question:
Firefox added something similar to
this to their canvas implementation.
You can find
CanvasRenderingContext2D.drawWindow()
documented in their wiki. It is
restricted to being used by plugins,
for security purposes, and isn't
supported by any other browsers.
There is
talk
of adding support to other browsers,
and perhaps removing some of the
security restrictions, but that is
probably a long way off. For now,
there isn't a good JavaScript solution
to your problem.
Sorry, there's no way to do it with Javascript.
I don't know about the Fusion controls, but some graphing libraries include a way to render to an image or PDF. Start looking there, not Javascript.
Update: FusionCharts claims to have the ability to export to JPG, PNG, PDF and CSV. Start with this page about exporting pure JS charts in their documentation.
I have a report that contains a link to a Word document. I have created an Action on the textbox that is Jump to URL, with the URL populated.
I have a PerformancePoint dashboard displaying the report, which is in a report library using SharePoint Integrated reports.
The link is not working correctly. Following the recommendations of this guy I surrounded my link w/ the javascript to open in a new window.
This works everywhere except for the end result. The link works from BIDS, Dashboard Designer, and the Report Library. It does not work from within the dashboard deployed to the SharePoint site. Any ideas?
Edit:
This HTML link:
=First(Fields!Link.Value, "MyUrl")
gives me this in the rendered report:
<TD style="WIDTH:53.98mm;word-wrap:break-word;HEIGHT:6.35mm;" class="a7">Click Me!</TD>
This Javascript link:
="javascript:window.location.href='" & First(Fields!Link.Value, "MyUrl") & "';"
gives me this in the rendered report:
<a tabindex="40" href="javascript:window.location.href='http://example.com/sites/some/subsite/DocumentLibrary/Folder/MyDocument.doc';" style="color:Blue" TARGET="_top">Click Me!</a>
Which does nothing when you click it.
I'm not familiar with Performancepoint, but the way you write the javascript seems like you simplified it a bit? I'm asking because the only way that perfectly fine link would not work would be if the page has a return false for the links in it. Try moving the whole changing the URL into a function, like:
<script type='text/javascript'>
function goTo(url) {
window.event.stopPropagation(); // cancelBubble() in IE
location.href = url;
return false;
}
</script>
with the link being:
="javascript:goTo('" & First(Fields!Link.Value, "MyUrl") & "')"
and do some trial and error inside the goTo function, sorry not being able to help you more precisely. Try also testing in a second browser (if you are not already) to see if this is some browser-specific behavior.
It turns out that there were two issues going on.
My first attempt at rendering a link using https://example.com/... didn't work because Reporting Services 2005 refuses to link to https web sites. (no source for this info, just determined through experimentation)
My second attempt at putting javascript around the link failed because PerformancePoint 2007 dashboards don't execute JavaScript from a report. (no source for this info, just determined through experimentation)
The solution was to go back to a straight HTML solution, and use http. This gets redirected to https and the document loads. This solution may not work if your environment does not automatically redirect http --> https.
I didn't mention the https in my original question because I didn't realize that would make a difference.