I am trying to convert docx file to pdf using java.
I have tried following code.
String fileName=new Date().getTime()+".pdf";
Map<QName, Serializable> props = new HashMap<QName, Serializable>(1);
props.put(ContentModel.PROP_NAME, fileName);ContentService contentService = serviceRegistry.getContentService();
NodeRef pdfNodeRef = this.nodeService.createNode(nodeService.getPrimaryParent(nodeRef).getParentRef(), ContentModel.ASSOC_CONTAINS,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, fileName), ContentModel.TYPE_CONTENT, props)
.getChildRef();ContentReader pptReader = contentService.getReader(nodeRef, ContentModel.PROP_CONTENT);
ContentWriter pdfWriter = contentService.getWriter(pdfNodeRef, ContentModel.PROP_CONTENT, true);
pdfWriter.setMimetype(MimetypeMap.MIMETYPE_PDF);
contentService.transform(pptReader, pdfWriter);
It is giving me error like this.
No transformation exists between mimetypes application/vnd.openxmlformats-officedocument.wordprocessingml.document and application/pdf.
Am I missing something here?
Is there any other to convert docx to pdf?
You can use libreoffice api bootstrap by yourself
There is also docx4j, but as libreoffice should already be installed on your alfresco instance, it is more prefferable.
Hi Sanjay Bandhniya,
The best option to transform docx files to pdf files is deploying your own Microsoft Transformation Server and integrating it with your Alfresco.
Basically, you will be able to transform docx file to pdf with libreoffice, but files with tables, lists... won’t be exactly similar in the result pdf file because you need libraries from Microsoft.
Regards.
Nevertheless, Alfresco uses the libreoffice to convert docx to pdf, doesn't it?
As far as I understand, as Microsoft Transformation Server you mean instance of installed Microsoft Office, used for convertion.
According to this description Techno: A high quality transformation server based on Microsoft Office ⋆ Contezza
I suppose it's a good idea to combine libreoffice as fast convertion tool and Microsoft Office as a tool for pure pdf.
We use both docx4j and libreoffice for the conversion,
I should say, quality of free docx4j conversion is close to that of libreoffice.
But docx4j has a commercial option with declared pure docx to pdf conversion. I suppose using docx4j for pure pdf would be more natural for Alfresco, than Microsoft Office instance.
Besides docx4j is platform independent.
Have you got running transform-core-aio? If you dont connect some transform core (like on local dev where thumbnails don't work too) then no transform is possible.
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.