How to allow printing from my website but disallow save as pdf? - html

I'm trying to forbid users to save my website's content as pdf but I still want to allow them to print the content.
<style media="print" type="text/css">* { display: none; }
The above css style hides all content so when user hits (ctrl+p) it doesn't display my content which is good.
But is there a way to only display my content when user tries printing and then if user tries to save as pdf display nothing?
Thank you,

You can't. Most operating systems implement "save as PDF" as part of the print workflow -- there's no distinction from the perspective of a web page.
As an aside, your CSS isn't going to be an effective way of preventing users from printing your content either -- if normal printing doesn't work, they'll find a workaround like taking a screenshot of the page, or copying its text into a text file.

Related

Gravity Forms HTML Block Bug

I recently discovered a bug with gravity forms and I was wondering if you guys could help me and the community.
So, the problem it's with HTML content. I attached the images here. Basically, everything works just fine, when starting a new form, the HTML content it's displayed accordingly.
https://ibb.co/DRJrCzw
But when someone goes to the next page and then comes back to the first one, the content it's displayed like in the image nr.2.
https://ibb.co/Qrz8Wbd
This fixed it for me!
JacKrac (https://www.reddit.com/user/JacKrac/)
Assuming you are a paying customer, have you reached out to support?
With that said, I believe it is because you are using shortcodes in the text.
The second time you visit it, the form content is likely rendered a different way compared to when the page first loads, likely with an Ajax request and/or javascript the second time around and the shortcode is not being processed.
One thing to try would be to copy the generated HTML and paste that into the HTML block in gravity forms, removing all the shortcode.
So, basically:
Open a text editor and save the current content you have in Gravity Forms, so you have a backup of it.
Open a page to view the form and then use your browser's HTML inspector to copy the HTML
Paste the HTML into gravity forms
If that fixes it, I would still reach out to them and ask them about how shortcode is handled within the html block and also let them know you think you found an issue.

Save as a blank html page instead of content

I am using asp.net web form and the content is displayed let just say in the about-us.aspx.
I know it is impossible to disable Save As option in the browser file menus, but is it possible to have users saving it as a blank HTML page instead of the content?
Even if you could disable the "save as" feature, which... no, you can't. But say for an instant you could. Anyone who wanted (a copy of your webpage) could just take a screen shot and print that. Or, they could open the source code and copy/save that. Saving the file isn't the only way that they can grab your content.
Is there a reason that you don't want them to copy it?
Are you trying to prevent people (in general) from seeing the page?
If there is some other consideration, please leave a comment so we can expand on this.

CSS to display Watermark in browser printing function

I have a HTML page which is a report. When I use printing function (Ctrl+P), it is 10 pages long. I want to display a watermark for each page.
Anybody has suggestion?
Thanks.
Use a print stylesheet combined with css fixed positioning to repeat the watermark on each page.
#media print {
…
}
You can use a print styles sheet to add some extra styling (and watermark). it can be a bit tricky on getting it to work with it repeating the watermark across each page. You can view some more information here: http://www.andypemberton.com/css/print-watermarks-with-css/
Typically with reports I tend to use another tool that converts the page into a pdf such as wkhtmltopdf (http://wkhtmltopdf.org/) or PDFtk (https://www.pdflabs.com/docs/pdftk-man-page/). It allows you to input various settings to include watermarks, cover pages, table of contents and even page numbers.

document.execCommand('paste') returning "true"

I am trying to develop a google chrome extension and part of it is chrome.tabs.create( { url: "https://google.com/search?q=" +document.execCommand("paste") } ); and the link comes up as "https://google.com/search?q=true" Any help is great!!! Thanks!
execCommand('paste') does not work that way. It does not return the contents of the clipboard, rather it does exactly what would happen if someone pressed Command+V or Control+V. It would paste the text whereever the text cursor is.
What you probably want to do in your extension is create a textarea in your extension's background HTML page, focus it, then execute the command. From there you can read the text from the textarea.
If you aren't familiar with background pages, you can get the details from Chrome's Documentation.
Using a background page is necessary because Chrome applies different sandbox restrictions to it. execCommand('paste') can only be used in more privileged places, like a background page.
You can use sendMessage to communicate between JS files and your background HTML page.

Separate Address for Page Inside a Page

I am somewhat new to web development, so I'm not sure how "stupid" this question is, but I couldn't find much when searching, so I wanted to ask.
I am creating a page that, when a user presses an Export button, it exports a snapshot of the site as a PDF. The PDF library takes a URL. That works well. However, I want this page inside a larger site. When I print, however, I don't want the larger site to be printed. Is there a way to supply an "internal" HTML address so that my web page can still be accessed. What should I look at to do something like this?
Thanks.
The best way to "hide" the rest of the page when the user prints a web page is to create a print stylesheet and include it in the page header like this:
<link rel="stylesheet" type="text/css" href="print.css" media="print">
Then simply hide the elements of the page that you don't want printing in your print.css file.
I'm wondering if by "larger site" you mean the template surrounding your content. Is that true? If so, a common approach is to provide a parameter that can be added to your request, like print=1, which would suppress the outer template when delivering your content.