Page 1 of 1

Automatically convert .doc/.docx to .pdf

PostPosted:Thu May 09, 2019 2:25 pm
by zaans2
Is it possible to set it up so that the following will happen:
  • User uploads Word document to OpenKM
  • Word document gets converted to PDF
  • Converted PDF gets saved alongside the original Word document

Would be even better if the PDF gets converted again of the Word document is updated.

Is this possible? And if so, how?

Re: Automatically convert .doc/.docx to .pdf

PostPosted:Thu May 09, 2019 10:24 pm
by LauryMenton
+1

Re: Automatically convert .doc/.docx to .pdf

PostPosted:Sat May 11, 2019 9:55 am
by jllort
Is posible create a new document from doc or docx to pdf automatically but is not possible update word document, the reason is that these documents are not the same, the PDF is a new document totally different ( in terms of binary data and mime type ). An option might be, before the corvertion move to the trash automatically.

You should create an automation task for it ( for the conversion , etc.. ):
https://docs.openkm.com/kcenter/view/ok ... ted-).html
in combination with DocConverter.class https://github.com/openkm/document-mana ... erter.java

Re: Automatically convert .doc/.docx to .pdf

PostPosted:Thu May 23, 2019 7:30 pm
by saulhidalgo
Good afternoon.

Yes, It is possible. I would do it using Automated Tasks as recommended in the previous answer.

Regarding if it is possible to convert the PDF again if the Word document is updated, my solution would be to create an automate task associated with the event "Document Update", just delete the PDF (if exists) and convert it again very similarly to what was done in the "Document Create" task.

I hope it helps. In case you need any advice or guide, you can contact me.

Mail: saulhidalgoaular@gmail.com.
Skype: saulhidalgoaular@outlook.com
Phone: +58 426 517 94 59.

Best Regards.
Saul Hidalgo.

Re: Automatically convert .doc/.docx to .pdf

PostPosted:Tue Jul 02, 2019 12:58 pm
by zaans2
I could use some help with the script. I currently have the following
Code: Select all
import com.openkm.util.*;
import com.openkm.api.*;

String dest = OKMDocument.getInstance().getPath(null, uuid);
DocConverter.doc2pdf(null, uuid,  dest)
But this doesn't work (because getPath returns the entire path, including the filename where I only want the parent folder path).
I also need to check if a document being created is already a PDF document since those don't need to get converted. I have no idea where to start doing that.

Re: Automatically convert .doc/.docx to .pdf

PostPosted:Sun Jul 07, 2019 10:52 am
by jllort
The method getProperties will provide you more information:
https://docs.openkm.com/kcenter/view/ok ... Properties

Will be returned a Document object
https://docs.openkm.com/apidoc/com/okm/ ... ument.html
https://docs.openkm.com/apidoc/com/okm/6.3.6/ ( all the classes )

Do you have OpenKM personal development environment, because will be good idea you debug the code. You can find it in the openkm website downloading section https://www.openkm.com/en/download.html