02-02-2019 04:05 AM
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?
02-14-2019 03:04 AM
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.
02-19-2019 02:57 AM
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.
02-19-2019 04:06 AM
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.
04-17-2024 09:10 AM
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.
Explore our Alfresco products with the links below. Use labels to filter content by product module.