Solution for 'Print to PDF button' with JavaScript - javascript

I will be happy if some body help me to get solution for my problem.
I have HTML5 + CSS page i need grab some main DIV and save it in PDF
i tied jsPDF library but it not rendering CSS and have some bugs in Mozilla =(
I found great API what rendering everything and send .PDF file but this project working only off-line and that should be local library.
I already create #print properties to my page and it printing perfectly! But my client want to see 'Save to PDF' button without any other 'dialog boxes'. Does somebody know a solution to silence print(i saw that working only for IE) or another library to render my HTML with CSS.
Thank u!

Related

Problem rendering image inside the amp-truncate-text tag

I am having a problem with AMP.
I'm trying to implement a read more button, but when there are images, videos, advertisements in the amp-truncate-text tag, it doesn't load the images, it gets a loading icon, but without showing the image.
I made an example using the AMP playground using the following code as an example.
Has anyone faced this problem and has any idea how I can solve it?
amp-trunkcate-text ist still in the experimental status. DO you have enable the experimental status?

"Save as...", "View page source" and "View page info" options are disabled in context menu when creating a new window using JS

trying to create a new window (as a pop-up) using JavaScript, the context menu of the new window has the options:
"Save as...",
"View page source",
"View page info"
disabled in Chrome, Opera and IE (11) but it works fine for Firefox.
I am doing so using the instructions:
var j = window.open(myUrl);
j.document.write("<!DOCTYPE html><html><head><title>my page</title></head><body> <p> ciao sample new page </p> </body> </html>");
j.document.close();
The same code was working in our system which was using html 4, now the whole architecture has been passed to html5.
I guess is something related to a security issue but why it does work in Firefox? How can I make that options stil available without writing a custom context menu? Could be a new html5 issue? Am I doing something wrong in the above code?
Thank you
I fixed just using window.open(myPage);
more precisely I had a POST calling via JS and then I was writing the server response using window.write() which caused the problem to me. (anyway the sample I wrote above does not work even in a simple html page with a bit of JS to me).
So I left the POST method that save the page server side, then response returns the id of the html page I wanted to render and then I did:
window.open("myUrl?pageId=" + response.serverResponse.responseText, 'myPage');
which works fine to me without writing other code.
Thank you
I have tried the same code using HTML 4.0 and it worked the same way. I think that this is because of the way view source is handled in Chrome and the other mentioned browsers. In these browsers a refresh is made before view source operations and this is by design. If you want to view source, you can inspect element and it should work fine. It is not a security issue I believe. Can you post the exact HTML 4.0 code that used to be working and that is not working now?

Facebook Comments in iOS with loadHTMLstring

I have problem with Facebook Comments plugin. Is it event possible to embed it on UIWebView in iOS application? I don't mean using loadUrl method ... but using loadHTMLstring ( I want it only localy on my application, without using any messy obj-c code if it's possible ). I'm using HTML5 code for it, but it's not working on simulator ...
Am I doing anything wrong?
I've read similar topics, but haven't found any solution, that might help me.
Thank's in advance for any help!
well, i found some workaround for this problem. what i needed is to load local html page with comments plugin embedded. this html page is stored in resources of project. so the code for me was something like that:
[reviewsView loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:#"comments" withExtension:#"html"]]];
where reviewsView is a UIWebView element. however, it didn't work correctly in the end - comments had loaded, but facebook "loading progress bar" was still animating and for some reason login button was unclickable. so i just returned to the idea with remote html comments page.

Open HTML file in Mac's Text Edit from a web browser

I'd like to use Javascript (or perhaps some more suitable script?) to open an HTML file in Text Edit (I'm on a mac)
I have a local web page made using Text Edit with different tabs that link to more Text Edit files on the page.
I'd like some way of quickly opening the tabs in Text Edit from my browser, then I could edit the HTML files easily in Text Edit and when I refresh the browser it will display my newly edited tab.
Pretty sure this should be simple but I'm a total beginner at Javascript and apart from going through the W3Schools tutorials, I have no knowledge of JScript per se.
Thank you for any help with this in advance.
I don't think TextEdit has a web listener of that sort, like Twitter for Mac has for Safari. I think you would need AppleScript to be able to do this, and that would only be on your local machine.
...wat? Just get a good text editor. I recommend Sublime Text 2 or Espresso.

Trouble between an injected iframe and other web page (Google, Gmail, Pdf)

Well i'm currently developping my Toolbar for Google Chrome as a Extension. The main principe is that i'm all the time injecting the toolbar as an iframe by using the Content Script.
But now i see a couple of bug with gmail, google map/search, pdf an maybe other that i've not yet see...
Let me explain, when i go on gmail, i don't see my toolbar at all...
When i open Google, it seems really normal :
But then when i start a search my toolbar seems to overide the top link (web, images, videos, maps,...) I can't click on them anymore...
Next problem is when i'm trying to go on google map or trying to open a PDF, it seems to give the same css to these web pages from my toolbar...
Google Maps :
PDF :
Hope i where clear enough, do not hesitate to ask me question if necessary ;)
Why don't you use absolute/fixed positioning and style attributes? Using style attributes would remove the issue of the possible spread of CSS.
To remove the toolbar from pdf, you could write something that removes the element when on pdf?
Well, i've find a good solution to resolve the problem with PDF and Google Map it was a problem on my CSS.
About the google Search now it works perfectly by setting the body webpage as a fixed page like NeXXeus tell me but there is still a problem.
Check this out :
EDIT : We don't really see, the argument select/deselect is top: 0px;

Categories