Reputation: 486
Is there a way to open a PDF document using JavaScript (or C#) and have it automatically open with Acrobat, let the user edit document and upon the the user closing document, save back to server.
From my research, I found people recommend iTextsharp, but I don't think that will do what I'm trying to accomplish.
Basically I am trying to mimic the Check Out/Check In functionality of SharePoint.
Upvotes: 2
Views: 1903
Reputation: 3399
Ignoring the browser, so assuming you're working in a C# application, this is quite possible and not as complex as it might seem. The details will depend on your exact setup, but I'd suggest a la:
Download the file from the server and store it in a temporary location with a .PDF extension. Your download may be over HTTP or via a UNC path or mapped drive. Make sure the location you save to is one you can read/write and delete files to - the standard temp folder should suffice.
Use Process.Start to launch Acrobat. If Acrobat (or another suitable editor) will be registered on the user's system as the default program which opens when the user double clicks a PDF, you can just Process.Start the document itself with no particular verb (command) specified. Otherwise you can look up and specify the correct verb or launch Acrobat itself and specify the filename.
You can either wait for the user to close Acrobat, i.e. for the Acrobat process to finish, or watch the file for changes and react when it does. Bear in mind if watching for changes that Acrobat may retain an exclusive lock on the file until the user closes either that document or Acrobat, so you may need to either wait for Acrobat to finish or after detecting changes, check (poll) periodically until you can get access to the file.
Upload the file back to the server via whatever means seems most appropriate.
Upvotes: 3
Reputation: 7048
A lot probably depends on what exactly you are trying to accomplish and how much control you have over your environment / users. Looking at what Acrobat X and SharePoint do, it looks like support for SharePoint is built into Acrobat X.
This can easily (well :-)) be done by creating an Acrobat plug-in. Plug-ins are capable of monitoring a myriad events within Adobe Acrobat and reacting on that. They can do complex things such as adding a file system (which allow you to open and save files that are actually stored in a database for example) but there are certainly more simple strategies imaginable.
Imagine a plug-in living in Adobe Acrobat that monitors each file that is opened by the user. Upon seeing a file opened from your server it marks that document as one of yours and checks it out with the server (however you want to implement that). When the user saves the document that notification would be received as well (both before and after the actual save) and again appropriate action can be taken.
So the general answer is yes, this is doable under certain circumstances, if you are willing to write a plug-in and if you have control enough over your environment that you can make sure all users actually have this plug-in installed in Adobe Acrobat.
Upvotes: 4
Reputation: 515
To save document back to SharePoint there should be support in client application. If I correctly understand Acrobat X supports this http://pdfdevjunkie.host.adobe.com/pdf/AcrobatXandMicrosoftSharePoint.pdf . Isn't that that are you looking for?
Upvotes: 3
Reputation: 23047
As I am aware there is no JS solutions to edit PDF (26.06.13), but there is a way to preview them, for example with pure JS solution PDF.JS.
You need to generate PDF files on server side using pure submitted data.
Upvotes: 1