views:

238

answers:

3

This is primarily a question of possibilities more than instructions. I'm a programming consultant working on a WSS project site system for my client. We have a document library in which files are uploaded to go through a complex approval process. With multiple stages in this process, we have an extra field which dictates what the current status of the document is.

Now, my client has become enamored with the idea of PDF watermarking. He wants the document (which is already a PDF) to be affixed with a watermark corresponding to the current status, such that with each stage of the approval process the watermark will change.

One method, the traditional method for PDF watermarking, of accomplishing this is to have one "clean" copy of the document somewhere hidden on the site, and create a new PDF from it that has the watermark at each stage of the approval process. Since the filename will never change, this new PDF can be uploaded continually to a public library, always overwriting the old version and simulating a "dynamically changing watermark". However, in the various stages there will also be people uploading clean copies with corrections and suggestions, nevermind the complex nature of juggling around two libraries and the fact we double the number of files stored. My client and I agree that this is not a practical path to choose.

What we would like to do is be able to "modify" the watermark in a PDF, so that we only have to keep one copy of the file. Unfortunately, from what I've seen, in most cases when you make something like a watermark, which in its nature is supposed to be "unmodifyable", you won't be able to edit it later. So, is it possible to have a part of a PDF which cannot be changed by anyone who downloads the file, but can be changed as part of a workflow or other object model process? Thanks in advance!

A: 

It sounds to me like you want to allow people to modify the PDF they download, but not modify its watermark. This is probably going to be nigh on impossible if the watermark is embedded in the PDF (afaict) but what if the watermark image is external to the PDF; is it possible to embed a watermark in a PDF that is sourced via HTTP? Then you could embed:

<watermark image="http://sharepoint/site/_vti_bin/docstatus.asmx?id=5"&gt;

Of course, I have no idea about PDFs, so this might not be possible but you get the concept.

-Oisin

x0n
I can comprehend the concept of your answer, but I'm uncertain about its implementation. I've never worked with sourcing things via HTTP myself, so I wouldn't know if it would work with PDFs, but I'm willing to give it a shot. Could you give a bit more detail on how I would try to implement such an external watermark? For example, what files I would have to make changes to.
ccomet
+1  A: 

You could use Event Handlers such that code was run every time a document was checked in. In that code you could perform the fixup/check that made the watermark be what you wanted it to be. This assumes you can write code that manipulates a PDF's internal structure such that it has the watermark that you desire.

Mark Mascolino
Determining when the change would occur is not an issue. While Event Handlers would do the job nicely, I would actually tie it in with the workflow or form action (different stages of our process use one or the other) that actually changes the Status field of the file (which is what would dictate the watermark). What I'm searching for is the ability to manipulate a PDF's internal structure. To clarify, I can modify some parts of a PDF, but when I set something to read-only, it cannot be undone later in the process with what I have. Thanks for the suggestion, though.
ccomet
+1  A: 

PDF Watermarking in SharePoint is a common request. I have written extensively on this topic. See:

  1. Adding a dynamic watermark to a PDF file from a SharePoint Workflow
  2. Adding a (static) watermark to a PDF file from a SharePoint Workflow
  3. Use SharePoint Workflows to inject JavaScript into PDFs and print the ‘open date’
Muhimbi
I enjoyed reading what you've written. However, what you've shown me only solves half the problem (basing a watermark on a variable field), and specifically not the half I need answered (changing an already-existing watermark to something different without needing a clean copy of the file). Points for the very useful links nonetheless. Thanks for your help.
ccomet
Look at the 'Injecting JavaScript' example. If you always write the watermark in a PDF form field then you can easily change it's contents.
Muhimbi
Hm... missed that. Reading it again... this will even retain the script when someone downloads it. So that's a big plus, it should even work with the custom bulk downloader I wrote. I would probably have to configure the script to also add some hidden variable that stores the Status somewhere, since that's not something that can just be "looked up" like a current date. Two questions. Will this work without SharePoint Designer? And you don't quite specify it, but I'm assuming the form field created in this fashion cannot be editted by someone who opens the file?
ccomet
Okay... took a dive into your code. Saw that you marked the field as Read-Only, so that answers the second question. Considering the bulk of the method appears to be the C# code provided, the SPD workflow only serves as a launch-point for the code. As such I should be able to use a code-based approach without needing to use SPD. To store the status I'll just set the inserted JavaScript based on the status, so nothing has to be looked up. Then all I have to do is add a check to avoid making extra fields with each time the process is run. Overall, it should solve this thing. Thanks a bunch!
ccomet