I have a pdf file stored at some location on my server. On click of a link I want to add a text-watermark to this pdf file and then print it.
something like this:
in aspx say we have a (button a link-button or a simple link)
<a id="abc" href="../test.pdf" onclick="watermarkAndPrintPdf()"> PrintPdf </a>
or
<asp:linkbutton id="abc" runat="server" onclick="watermarkAndPrintPdf()" Text="Print Pdf"/>
Now when user click this link my code should add watermark(which will probably the loged-in user name) and print this document.
I want to know what ['watermarkAndPrintPdf()'] this function will be.......
Note:-It is a web application in C# asp.net 4.0.
(I don't mind if print dialog box opens or It prints without it.)
Please help....
would suggest taking a look at PDFsharp it's an open source dll for producing pdf's through code, there are a number of examples of producing a watermark on this page of the PDFsharp website:
http://www.pdfsharp.com/PDFsharp/index.php?option=com_content&task=view&id=40&Itemid=51
If you need any help using it I am more than willing to lend a hand as I have used this package to produce pdf's in the past.
hope this helps.
Related
I have a document library in SP2013 that is full of forms. My users get confused by the "Check Out Required" box that pops up when they open the file. I keep telling them they need to download a copy, but this seems to be an issue. So, I looked into adding a "Download a Copy" button or link to the library, and came up with this solution, which is put in a snippet on a Web Part Page (source: https://amalhashim.wordpress.com/2013/11/29/sharepoint-2013-document-library-download-a-copy-button/):
<script type="text/javascript">
function runAfterEverythingElse(){
var elementArray = document.getElementsByClassName("ms-vb-lastCell");
var idArray = document.getElementsByClassName("ms-listlink");
for(var i = 0; i < elementArray.length; i++)
{
elementArray[i].innerHTML = '<a unselectable="on" href="javascript:;" onclick="window.open(\''+ idArray[i]['href'] + '\')" class="ms-cui-ctl-large " aria-describedby="Ribbon.Documents.Copies.Download_ToolTip" mscui:controltype="Button" role="button" id="Ribbon.Documents.Copies.Download-Large"><span unselectable="on" class="ms-cui-ctl-largeIconContainer"><span unselectable="on" class=" ms-cui-img-32by32 ms-cui-img-cont-float"><img unselectable="on" alt="" src="/_layouts/15/1033/images/formatmap32x32.png?rev=31" style="top: -409px; left: -35px;"></span></span><span unselectable="on" class="ms-cui-ctl-largelabel">Download a<br>Copy</span></a>';
}
}
_spBodyOnLoadFunctionNames.push("runAfterEverythingElse");
This partially works, in that it puts a button next to each document that says "Download a copy," but the action is actually just open the file in Word (instead of in the browser). The check-out prompt is still there, so I know it's opening the file and not downloading a copy. So while I like the way it looks, but the functionality isn't right.
In the answers to another question here (How to trigger a file download when clicking an html button or javascript), I found some instructions, but I can't figure out how to use them. I tried creating a workflow that created a download link and put it in an html-formatted field, but can't get the formatting right.
I don't really care if the solution is library-based (a field on each document probably created through Nintex Workflow) or Web Part Page based (script/snippet). I'm not fluent with jquery, javascript, or other programming languages. I know HTML, and can fumble my way through with CSS, but I'm pretty much a straight copy-paste from the internet solution kind of girl. I am not a programmer, just the person who manages our SharePoint site alongside may other job functions. :)
Any advice on how to tweak the original code or how to do this better is greatly appreciated. We're using SP2013.
#Kelly I implemented this solution in sharepoint 2010 using Dataview webpart.
Dataview webparts loops through all the documents in doc library and below code allow user to download the file.
Test.docx - Download a copy
I hope it helps. :)
I'm trying to insert piece of my html code(which is actually working in my local html file) in SharePoint. But it is not accepting all my tags which are there in the code, for eg: 'style' tag.
Any help is greatly appreciated. :)
Open page for edit. Then from "Media and Content" group choose "Script Editor" web part. And then click Edit Snipper and paste your html code there.
You can also use Content Editor web part and provide link to your html code.
If you want to change style for whole SharePoint you can modify Master Page or providing Alternate CSS for exiting one (this is possible in Central Administration).
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.).
I have seen webpage with a PDF icon, where you could click on it to print the content of that webpage.
The page i am intending to add the print feature is designed in JSF, so is there anyway where i could add a print button, to get the webpage printed ?
No, you must do this yourself. Get some PDF library (for example iText), then get web page output (plain HTML). Then you will have to iterate thru HTML and create PDF version (for example build iText document). You will probably have to do this yourself, because some elements (javascript powered) will need to turn into static content. Nobody but you knows how the output should look like.
I have to modify text in discussion board new post page. Now it is showing "Items on this list require content approval. Your submission will not appear in public views until approved by someone with proper rights. More information on content approval."
I have to append some text to this message. I am trying to find discussion board newform.aspx page to modify. Please let me know where can I get that?
Assuming your discussion list is called "Public Discussion" at a site called "http://yoursite"
Connect to the site (http://yoursite) with sharepoint designer
Go to All Files -> Lists -> Public Discussion -> NewForm.aspx
Edit file
Look for <asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">
Add content as needed
Save file, it will warn you that you are about to save a customised layout.
The message you describe is injected by sharepoint's content approval framework. To custom the messsage, you will most likely need to use javascript to find the message box and change the text.
On my site the html xpath to the node is something like this:
//span[#id='part1']/table/tbody/tr/td[2]
On the file system it will be here:
$sphome / "Name of your discussion board" (this will be a folder) / Forms / newform.aspx
There is a similar question asked here. It describes custom template controls handle the display of this content.
There is also a link here that describes a solution to do this using css. This would allow you to hide the OOB text and then have your own content displayed instead. However, there is some question of it working on broswers other than IE so include this in your testing.