4

Client is having a requirement, whenever document status was changed to approved, then document has to be converted into pdf and should upload to another document library.

I thought of doing with event receiver which is a sandbox solution(of course not suggested but no other option for me), because client doesn't have any azure licences to host provider hosted app. Word automation services are not available in SharePoint online. I am having one more though on it like, convert word document to html and html to pdf, but the issue here is again I have to upload that converted pdf to document library.

How I can accomplish this in SharePoint online?

  • I would avoid the sandbox solution, as there's no guarantee that Microsoft will continue to allow them to be added to SharePoint Online. How are you converting it to html/pdf? – wjervis Feb 16 '16 at 16:12
  • There are some libraries available to convert from docx to html like blog.innovatejs.com/?p=184, github.com/evidenceprime/html-docx-js – Mihir Feb 17 '16 at 5:09
  • I don't see this being possible, at least not in an automated manner. You would at the least need to browse to a page for the library you linked to execute, and once that's done, you can use REST or JSOM to upload it to the library, but that cannot be automated. – wjervis Feb 17 '16 at 11:30
1

This is a bit too... involved to handle inside of your own browser (although if someone has created a JavaScript docx to pdf converter, that would be awesome to behold). What you'd probably have to do is create a webservice of your own that does this conversion and then send the Word document there. That's like 90% or more of the way there to a cloud-hosted solution (as you'd still need to set up an Apache server or something to set up the service), but that would be the way you would need to handle it.

0

This can be all done using JavaScript. You can use JSOM or ASMX. I'm unaware of an operation that'll get you the base64 for a document in REST, but hopefully it exists. Using ASMX, the GetItem operation is all you need to get the base64.

Example code from http://spservices.codeplex.com/wikipage?title=Copy:

var binary =""; $().SPServices({ operation: "GetItem", Url: "http:/mysite/site1/testdoclib/report.pdf", completefunc: function(xData, Status){ $(xData.responseXML).SPFilterNode("Stream").each(function(){ binary = $(this).text(); }); $().SPServices({ operation: "CopyIntoItems", SourceUrl: "http:/mysite/site1/testdoclib/report.pdf", DestinationUrls: ["http:/mysite/site2/anotherdoclib/report.pdf"], Stream: binary, Fields: ["<FieldInformation DisplayName='TestField' Type='Text' Value='Cricket' />","<FieldInformation DisplayName='ChoiceTest' Type='Choice' Value='A' />"] }); } });

Using this library, you can convert documents into PDFs. I'd use the Image method, since it takes a base64. http://mrrio.github.io/jsPDF/

The larger the document, the longer this will take FYI.

  • This is great idea. But have you ever tried this to convert? – Mihir Mar 1 '16 at 6:07
  • I've never been paid to do so. ;) – iOnline247 Mar 3 '16 at 4:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.