Search for text embed - javascript

I use embed tag to display 1 pdf file, how do I make when I press Ctrl + F it only searches the pdf file, not the current page. I tried searching on google but no desired result.

You will not find a single answer on google they use two methods themselves.
Generally it should not be possible unless the embedment has control of the pdf search function, You need to understand that a binary pdf viewer embedded in a html page cannot be controlled by the html page, it can pass options like .pdf#search=words during loading. That usually works with Firefox but not Chrome derivatives, but that's as far as cross application security should allow. The best you can target is combine Page and part strings, like this:-
So there are frame controls to assist user in some cases, but not accessible from HTML, nor can the embed see the surrounding HTML.
A Firefox alternative secure Plugin that will ignore both external and internal PDF JavaScript's
Chromium Edge where there is no external control but the PDF may perhaps have scripting allowed.

Related

Can I inject Javascript code into Chrome Custom Tabs

In my app, I am currently using a web view to display some content. Then, I use Javascript injection to quickly fill out the form for the user.
The only issue is, Webviews are incredibly slow compared to Chrome Custom tabs. Is it possible to inject Javascript code into these custom tabs?
For example, here is some code I currently use:
myWebView.loadUrl("javascript:document.getElementById('join_first_name').value='" + name + "';void(0); ");
No; that would be a critical security hole.
Since custom tabs use cookies, settings, and password managers from the user's real Chrome instance, you cannot control them at all.
Chrome prohibits you from doing any of that. If this were allowed then it would be a major security flaw since you can modify the page within the app.
Suppose you have an app that has a facebook sign in. If this were possible, one could also steal someone's login credentials.
With Chrome Custom tabs, you don't have much control over the content that is served. You should probably try an alternative, like passing the first name as a URL parameter and then write a script on that page to read the parameter and fill the form out.
you need to do it like that by using data:text/html, as prefix for your script
Try that in your browser tab
data:text/html,<script>alert("hello")</script>
it will fire the javascript and alert , and as well you can print some in html from url
so i guess you need just to open the tab with the script
String suffix = "data:text/html,"
String script = "<script>document.getElementById('join_first_name').value='" + name + "';</script>"
String url = suffix + script
myWebView.loadUrl(url);
It's browser behaviour in desktop and mobile
I haven't try it in WebView.loadUrl and actually still if it's done by WebView.loadUrl it will be a security hole
There's supposed to be no way to inject Javascript to Chrome web browser.
If you can execute the Javascript queries to chrome via some third party apps, thereby you can read all the cookies, clear every sessions, and whatever the javascript is capable of. Which is really a huge security flaw.
What you can do is to load your URL in webview and execute the javascripts there. That's the only possible i've ever heard of. This is the same technique used for EPUB documents, where we load the complete HTML content in webview then we execute external Javascript queries into that view, so you can modify the HTML, CSS attributes.

Possible to embed javascript in PDF and have it fire when PDF is opened in Browser Window?

Is it possible to embed a piece of javascript in a .pdf doc, and have the script fire when the .pdf is opened in a browser? ... It should not require any user interaction inside the doc (like a click, etc) -- just fire the script when the .pdf is opened in a browser.
I would like to embed some analytics beacons or conversion tracking tags inside .pdfs, if this is possible.
Thanks in advance if you know any possible solutions! :)
Acrobat JavaScript has a method (launchURL()), which would send the message to the URL. You can run the according command in a Document-Level JavaScript (which is embedded in the document, and gets executed when the document opens). More to this method and its implication can be found in the Acrobat JavaScript documentation, which is part of the Acrobat SDK documentation, and downloadable from the developer section of the Adobe website.
However, it requires that the PDF viewing component of the webbrowser supports Acrobat JavaScript. And that limits you pretty much to Acrobat (Reader) using a browser which still supports the Acrobat Browser Plug-in, and the Acrobat Browser Plug-in has to be active. The PDF viewing components built into the browsers are too dumb, and your code will not get executed.
On the plus side, this approach also works when the document is opened outside of a browser; sole condition is that the PDF viewer does support Acrobat JavaScript, and the launchURL() method.
Aside the interesting Acrobat answer of Max, AFAIK it isn't possible to run JavaScript in a PDF without user interaction.
To track these interactions with PDFs in the past, we have instead relied on event clicks on the PDF view link instead.
However, these days consider server side tracking by sending a Measurement Protocol hit when the PDF resource is viewed, ideally taking the same cid from a cookie in the same session.

find pdf text in IE9 browser using selenium

In our application while clicking the link it will open the new window with secure pdf file. We want to validate that using selenium ruby. but We unable to validate this in IE9 [because there is no html/dom element]
We can perform this validation using firefox and chrome browser because there html/DOM element present for that pdf page.
Is another way to validate pdf text from browser URL?
I'm not sure this is possible. Chrome and Firefox, do, indeed render more that is actually there, usually for more powerful embedding, etc.
I can offer a solution however,
Instead of navigating to the PDF, you can validate the href of the link.
here is some pseudo-code from Java on how to accomplish the task...
String href = driver.findElement(By.cssSelector("a[href$='.pdf']")).getAttribute("href");
assertTrue(href.contains("FileName.pdf"));
From these two statements, we'll know two things:
The link is indeed taking you to a PDF file.
The PDF file, is called FileName
If the test fails in any way, that means that the link doesn't exist, or points to the wrong pdf.

How to display HTML5 convert of a PDF on page without using an IFrame?

I do not want to embed the PDF directly as the PDF is itself indexed by Google, and is returned directly in Google search results (If the PDF is displayed on page I can benefit from advertising clicks).
As suggested elsewhere on StackOverflow I have used this conversion tool:
http://www.idrsolutions.com/example_conversions/
However the output from here in the Iframe is not indexed by Google.
Here is an example of the output I desire:
http://www.manualsdir.com/manuals/132858/jaguar-s-type.html
How can I replicate this Functionality?
Google tries to associate framed content with the page containing the frames, but we don't guarantee that we will.
From here: https://support.google.com/webmasters/answer/34445?hl=en
Speculating, what this probably means is that the content should be on the same domain (to ensure it's your content) and only iframed once or a small number of times (so that multiple pages cannot gain credit for the same piece of content).
Did you follow the above ideas and give Google enough time to index the content?
For disclosure, I am a developer at IDRsolutions.
We do have customers who are iframing converted content and having it indexed by Google. You might like to try the singlefile mode that puts all pages into one file so Google is able to easily index content on all of the pages.
If you have any questions specific to the conversion, there are support forums here: http://support.idrsolutions.com/forums/forum/pdf-conversion-forum/

Can't open .PDF or .DOC(X) in iFrame

I'm developing an iPhone app using PhoneGap, Xcode, HTML and JavaScript. I have an iFrame that should view documents (right now I am using a test document instead of allowing the user to choose - that's coming later) that have been downloaded (again, i chose the document). I tried using a .pdf file and a .docx file which are both supported by iPhone, but clicking the button I coded opens them in Safari instead of the iFrame. Here's the code to view the document (JavaScript and HTML);
function viewOnline() {
var site = "file://" + pathToRoot + "/editme.txt"
$('#myIframe').attr('src', site);
}
<button onclick="viewOnline();">View Online</button></li>
<iframe id="myIframe" style="width: 210; height: 210px;" seamless="seamless" src=""></iframe>
Is it just not possible to view .pdf etc files in iFrame or is there something wrong with my code?
** pathToRoot is coded (and tested to be correct) elsewhere in the application - so i don't need to hard-code the file path, which will change when i transfer it to the device instead of the simulator.
** if you need the code where i download the file, then i can give you it - just comment below
** I'm also fairly new to working with Xcode and PhoneGap so if i need to alter something with them if you could give as much detail as possible that would be great - Thanks so much in advance
Edit
I know about the OpenWhitelistURLsInWebView, and have enabled it and allowed the website i'm downloading from in the ExternalHosts array - but it still won't work.
It's not possible. Most of the mobile browsers doesn't come preloaded with Adobe plugins and all. It's not a desktop you see. Its a mobile. So it's not possible unless you create a own browser and include the adobe plugin(meaning you have to write pdf rendition logic because the plugin wont work in mobile).
iFrames are very rarely needed and are often employed for wrong reasons. Often you can achieve the exact same thing you are going for using normal styles and simpler markup.
Also, googling phonegap/cordova iframe gives many results that spell out trouble with iFrames. For the official implications guide on them see iFrame Usage.
In your case these are the things you need to consider:
Enabling iFrames on PhoneGap-iOS requires that you whitelist the
iframe domains and enable "OpenAllWhitelistURLsInWebView". While this
doesn't sound like a problem, many applications want to open specific
sites in MobileSafari (not a ChildBrowser), which cannot be
accomplished easily when "OpenAllWhitelistURLsInWebView" is enabled.
To change OpenAllWhitelistURLsInWebView open the Cordova.plist file in
Xcode.
To whitelist a domain. Add it to the ExternalHosts array in the
Cordova.plist file. Simply press the + next to the ExternalHosts title
and when the item0 appears bellow add your domain to the value section
(in the format example.com).

Categories