How to have pdf viewer in ruby - html

How can I embeded pdf viewer in ruby on rail?
Now I tried
<embed src="MyPdfDocument.pdf" width="500" height="375">
but it doesn't work. I used firebug and see the error like this
[Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIStreamListener.onStopRequest]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: file:///home/bengasi/.mozilla/firefox/cmb1mbzu.default/extensions/firebug#software.joehewitt.com/components/firebug-channel-listener.js :: anonymous :: line 167" data: no]
[Break on this error] this.listener.onStopRequest(request, requestContext, statusCode);\n
firebug-...stener.js (line 167)

If you are trying to display a PDF as an image, surrounded by HTML content... then a browser won't do that, and your problem is with the browser, not Ruby on Rails. You can link to a PDF, and display it whole, but you cannot embed it in another document.
You could simulate the effect (maybe, in some browsers) with an iFrame, but that is a HTML question, not a rails question... and you would possibly spend a lot of time making it work in all browsers.

You might find this useful:
http://googlesystem.blogspot.com/2009/09/embeddable-google-document-viewer.html

Related

StackOverflow HTML render error - ERR_SSL_PROTOCOL_ERROR?

Why did StackOverflow HTML render like this? I'm unable to reproduce the weird rendering if I take the exact same HTML source code, save to file.html and open the file.html file. Below is the error I got in the browser console. The css file was probably omitted in the browser source code because of the sequence of this error and when css renders the html source code, so is this a Google Chrome (chromium framework) issue?
Google Chrome console error:
Failed to load resource: net::ERR_SSL_PROTOCOL_ERROR
pubads_impl_2022102601.js?cb=31070593:10 The following functions are deprecated: googletag.pubads().setTagForChildDirectedTreatment(), googletag.pubads().clearTagForChildDirectedTreatment(), googletag.pubads().setRequestNonPersonalizedAds(), and googletag.pubads().setTagForUnderAgeOfConsent(). Please use googletag.pubads().setPrivacySettings() instead.
hv # pubads_impl_2022102601.js?cb=31070593:10
​ Unrecognized feature: 'attribution-reporting'.
$f # impl_v91.js:100
​ Unrecognized feature: 'attribution-reporting'.
$f # impl_v91.js:100
​ a: 0.0029296875 ms

iOS 9 "Save PDF to iBooks" with HTML

iOS 9 has a new built-in UIActivity of UIActivityTypeOpenInIBooks. It's in the default list of activities in the UI and in header file but I've not been able to find any API documentation for it (yet).
It appears that UIActivityTypeOpenInIBooks will create a PDF in iBooks just fine if you include UIImages in your UIActivityViewController items or return them in your UIActivityItemProvider.
However I'd like to create a PDF with an HTML page containing text and images like Safari does. But I can't seem to find a way to pass the HTML to UIActivityTypeOpenInIBooks in an acceptable way.
I've tried passing the HTML as a String, NSData and NSURL of a file. I've also tried returning an UIMarkupTextPrintFormatter which works fine for printing but not for UIActivityTypeOpenInIBooks.
Providing an HTML string or the UIMarkupTextPrintFormatter both result in the following errors:
2015-09-08 11:35:46.392 MyApp[4599:1492484] ERROR: attempting to save to URL with no printing source (formatter/renderer) set
2015-09-08 11:35:46.393 MyApp[4599:1492484] FAILED! due to error in domain UIPrintErrorDomain with error code 4
Has anyone gotten this working?
You can convert the html to pdf before saving it to ibooks.

Why does "Failed to load resource" text show for "DOCTYPE HTML" tag with "/undefined?235" request in Symfony 2?

I've found an error in my Symfony2 website, what you can see below with the link:
https://drive.google.com/open?id=0B430tyHOr_s0SDdFXzJ2T1hVVEE&authuser=0
I use SonataPageBundle and SonataSeoBundle for html rendering, but I don't find the source of this bug.
Could anybody say something for this?
Regards,
Norbert

Opening a local XML file in Google Chrome

Our tool will look like below
Input an XML file.
Click Load button will do transformation of the XML file and display it in a table format.
Currently the tool is working fine in IE and Firefox. Now we have the requirement to support it for Chrome also.
Inside html file JavaScript, we are doing the XML transformation using the XSLT file. For the purpose of loading XML we are creating a DOM object for different browsers as below.
if(window.ActiveXObject) {
XMLObject = new ActiveXObject('Microsoft.FreeThreadedXMLDOM');
}
else {
XMLObject = document.implementation.createDocument("", "", null);
}
But for Chrome we are not able to find the Compatible DOM object code. While searching in web found that the below code will work in Chrome.
XMLObject =new XMLHttpRequest();
Tried with the above method , but it is throwing the error “Cross origin requests are only supported for HTTP”.
Also while loading XML file found that the browser is not giving the correct path of the filename, instead its giving like C:\fakepath\Sample.xml.
Any other way to solve this issue?
If you want to use XMLHttpRequest to access files from the local file system then you have to start Chrome with the command line option --allow-file-access-from-files.

Html from Silverlight (not out of browser)

I am trying to open HTML file from the local URI which I use as XML Editor, to edit xml data that come from Silverlight application, then close browser window and return back edited xml data to the Silverlight application.
I tried to use HtmlPage.Window.Navigate but I don't quit like it.
I have tried using a method from: http://weblogs.asp.net/dwahlin/archive/2010/05/10/integrating-html-into-silverlight-applications.aspx
but instanly got an exception "failed to invoke ShowJobPlanIFrame"
Is there any way to handle this task?
"Out of browser" mode doesn't fit.
Thanks.
===========================================================================
Update:
It worked out using IFrame overlay.
Button click invokes the following code in C#:
var scriptObject = (ScriptObject)HtmlPage.Window.GetProperty("ShowJobPlanIFrame");
scriptObject.InvokeSelf(url);
Where "ShowJobPlanIFrame" is as defined at:
http://weblogs.asp.net/dwahlin/archive/2010/05/10/integrating-html-into-silverlight-applications.aspx
This allowed me to pass data into XML editor and then get it back.
An error with JavaScript function invocation I told above, was my fault in JavaScript code itself.
A very similar scenario: https://stackoverflow.com/a/7919065/384316
Try using an iframe overlay, then you can load any HTML-like content.
There is an excellent explanation of how to do this here:
http://www.wintellect.com/cs/blogs/jlikness/archive/2010/09/19/hosting-html-in-silverlight-not-out-of-browser.aspx
It worked out using IFrame overlay.
Button click invokes the following code in C#:
var scriptObject = (ScriptObject)HtmlPage.Window.GetProperty("ShowJobPlanIFrame");
scriptObject.InvokeSelf(url);
Where "ShowJobPlanIFrame" is as defined at:
http://weblogs.asp.net/dwahlin/archive/2010/05/10/integrating-html-into-silverlight-applications.aspx
This allowed me to pass data into XML editor and then get it back.
An error with JavaScript function invocation I told above, was my fault in JavaScript code itself.
Did you try NavigationFramework of Silverlight? It's capability may support your needs in a more simple way than using multiple browser pages.