RE: OpenOffice Integrated successfully but css not supporting in liferay6.2

vel murugan, modified 7 Years ago. Junior Member Posts: 31 Join Date: 5/19/17 Recent Posts

OpenOffice Integrated successfully but css not supporting in liferay6.2.Is anything i have to add in ext properties

 

thumbnail
Samuel Kong, modified 7 Years ago. Liferay Legend Posts: 1902 Join Date: 3/10/08 Recent Posts

Can you elaborate on your issue? CSS is definitely supported in Liferay Portal 6.2. CSS also isn't really related  to OpenOffice.

vel murugan, modified 7 Years ago. Junior Member Posts: 31 Join Date: 5/19/17 Recent Posts
Samuel Kong:

Can you elaborate on your issue? CSS is definitely supported in Liferay Portal 6.2. CSS also isn't really related  to OpenOffice.

Hi Samuel ,

 Thanks for your reply. Please advice me to resolve this issue

I have attached  my html with  inline style.

I have attached converted pdf (Css is missing)

I have attached converting html with css screenshot in chrome

I followed the below link for integration openoffice with liferay (only css not supported openoffice doc conversion)

http://www.liferaysavvy.com/2013/11/liferay-document-conversion-portlet.html

 

 

 

 

Conversion code is below

@Override
    public void processAction(
            ActionRequest actionRequest, ActionResponse actionResponse)
        throws IOException, PortletException {
         UploadPortletRequest uploadPortletRequest =PortalUtil.getUploadPortletRequest(actionRequest);
        String destinationExtension=ParamUtil.getString(uploadPortletRequest,"destinationExtension");
         File sourceFile = uploadPortletRequest.getFile("sourceFile");
         String extension = "";
         String fileName=sourceFile.getName();
         int i =fileName.lastIndexOf('.');
         Timestamp stamp = new Timestamp(System.currentTimeMillis());
         File destinationFile=null;
         if (i > 0) {
             extension = fileName.substring(i+1);
         }
         InputStream inputStream = new FileInputStream(sourceFile);
         InputStream is =null;
         HttpServletResponse httpResponse = PortalUtil.getHttpServletResponse(actionResponse);
         HttpServletRequest httpRequest = PortalUtil.getHttpServletRequest(actionRequest);
         try {
             destinationFile=DocumentConversionUtil.convert(String.valueOf(stamp.getTime()),inputStream,extension,destinationExtension);
             is = new BufferedInputStream(new FileInputStream(destinationFile));
             ServletResponseUtil.sendFile(httpRequest,httpResponse ,destinationFile.getName(), is,getCotentType(destinationExtension));
        } catch (Exception e) {
            if(e instanceof SystemException){
            SessionMessages.add(actionRequest.getPortletSession(),"error-message",e.getMessage());
            actionResponse.setRenderParameter("mvcPath","/html/docconverteraction/view.jsp");
            e.printStackTrace();
            }
        }
         finally{
             inputStream.close();
             is.close();
         }
    }
    
     public String getCotentType(String destinationExtension){
         Map<String, String> fileExtensionMap = new HashMap<String, String>();
            // MS Office
            fileExtensionMap.put("doc", "application/msword");
            fileExtensionMap.put("dot", "application/msword");
            fileExtensionMap.put("docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
            fileExtensionMap.put("dotx", "application/vnd.openxmlformats-officedocument.wordprocessingml.template");
            fileExtensionMap.put("docm", "application/vnd.ms-word.document.macroEnabled.12");
            fileExtensionMap.put("dotm", "application/vnd.ms-word.template.macroEnabled.12");
            fileExtensionMap.put("xls", "application/vnd.ms-excel");
            fileExtensionMap.put("xlt", "application/vnd.ms-excel");
            fileExtensionMap.put("xla", "application/vnd.ms-excel");
            fileExtensionMap.put("xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
            fileExtensionMap.put("xltx", "application/vnd.openxmlformats-officedocument.spreadsheetml.template");
            fileExtensionMap.put("xlsm", "application/vnd.ms-excel.sheet.macroEnabled.12");
            fileExtensionMap.put("xltm", "application/vnd.ms-excel.template.macroEnabled.12");
            fileExtensionMap.put("xlam", "application/vnd.ms-excel.addin.macroEnabled.12");
            fileExtensionMap.put("xlsb", "application/vnd.ms-excel.sheet.binary.macroEnabled.12");
            fileExtensionMap.put("ppt", "application/vnd.ms-powerpoint");
            fileExtensionMap.put("pot", "application/vnd.ms-powerpoint");
            fileExtensionMap.put("pps", "application/vnd.ms-powerpoint");
            fileExtensionMap.put("ppa", "application/vnd.ms-powerpoint");
            fileExtensionMap.put("pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation");
            fileExtensionMap.put("potx", "application/vnd.openxmlformats-officedocument.presentationml.template");
            fileExtensionMap.put("ppsx", "application/vnd.openxmlformats-officedocument.presentationml.slideshow");
            fileExtensionMap.put("ppam", "application/vnd.ms-powerpoint.addin.macroEnabled.12");
            fileExtensionMap.put("pptm", "application/vnd.ms-powerpoint.presentation.macroEnabled.12");
            fileExtensionMap.put("potm", "application/vnd.ms-powerpoint.presentation.macroEnabled.12");
            fileExtensionMap.put("ppsm", "application/vnd.ms-powerpoint.slideshow.macroEnabled.12");
            // Open Office
            fileExtensionMap.put("odt", "application/vnd.oasis.opendocument.text");
            fileExtensionMap.put("ott", "application/vnd.oasis.opendocument.text-template");
            fileExtensionMap.put("oth", "application/vnd.oasis.opendocument.text-web");
            fileExtensionMap.put("odm", "application/vnd.oasis.opendocument.text-master");
            fileExtensionMap.put("odg", "application/vnd.oasis.opendocument.graphics");
            fileExtensionMap.put("otg", "application/vnd.oasis.opendocument.graphics-template");
            fileExtensionMap.put("odp", "application/vnd.oasis.opendocument.presentation");
            fileExtensionMap.put("otp", "application/vnd.oasis.opendocument.presentation-template");
            fileExtensionMap.put("ods", "application/vnd.oasis.opendocument.spreadsheet");
            fileExtensionMap.put("ots", "application/vnd.oasis.opendocument.spreadsheet-template");
            fileExtensionMap.put("odc", "application/vnd.oasis.opendocument.chart");
            fileExtensionMap.put("odf", "application/vnd.oasis.opendocument.formula");
            fileExtensionMap.put("odb", "application/vnd.oasis.opendocument.database");
            fileExtensionMap.put("odi", "application/vnd.oasis.opendocument.image");
            fileExtensionMap.put("oxt", "application/vnd.openofficeorg.extension");
            fileExtensionMap.put("pdf", "application/pdf");
            return fileExtensionMap.get(destinationExtension.trim());
    }

 

 

thumbnail
Minhchau Dang, modified 7 Years ago. Liferay Master Posts: 598 Join Date: 10/22/07 Recent Posts
vel murugan:

I have attached  my html with  inline style.

I have attached converted pdf (Css is missing)

When you open the HTML file inside of OpenOffice directly, you will find that the inline CSS is missing there as well. It's a known limitation of OpenOffice (see the question OpenOffice HTML & CSS : JODConverter on StackOverflow), so you'll need to use a different tool if you want to convert an HTML file into a nicer-looking PDF.

For example, the StackOverflow post suggests using Chrome and its Print to PDF command line switch to do the PDF conversion. If your server machine is running on Linux, the Print to PDF command line switch mentioned in the StackOverflow post is also available on chromium-browser.

vel murugan, modified 7 Years ago. Junior Member Posts: 31 Join Date: 5/19/17 Recent Posts

Can you guide me, which tool is better for generating pdf from html.Can you send me that link 

thumbnail
Minhchau Dang, modified 7 Years ago. Liferay Master Posts: 598 Join Date: 10/22/07 Recent Posts
vel murugan:

Can you guide me, which tool is better for generating pdf from html.Can you send me that link 

Unfortunately, HTML to PDF conversion isn't perfect because it relies on something to render (and that rendering changes depending on what the renderer thinks is the correct canvas size), so every tool has its limitations. You'll need to check them against your own HTML files to see if you are comfortable with whatever limitations the tool will have.

For some scenarios, OpenOffice conversion would have been sufficient.

If the page is static (the UI isn't rendered with Javascript), tools like wkhtmltopdf (the default driver for HTML to PDF conversion if you try to use pandoc) might meet your needs. At least, the example from their website shows that Wikipedia pages, which are mostly static, are rendered reasonably well.

The specific example from the OpenOffice HTML & CSS : JODConverter question on StackOverflow uses chrome in headless mode, and chromium-browser (the open source project behind Chrome) also provides the same command line flags.

If you prefer a different browser engine for rendering the page, a feature request for a Firefox headless mode references an add-on you can install to Firefox to get command-line access to Firefox's Print to PDF capabilities (the command line access isn't natively available in Firefox yet).

If you're unhappy with all of those options, then if you are in control of whatever program generates the HTML files, you can choose to not write HTML, but instead write a different format where you are generating an actual printed page rather than generating markup for an arbitrarily sized window.

If you want to use the OpenOffice conversion, you can generate .odt (OpenDocument Text) files directly for OpenOffice conversion, but this has a steep learning curve. You might also consider TeX, which is used in a lot of academic settings, but this has a very steep learning curve.

vel murugan, modified 7 Years ago. Junior Member Posts: 31 Join Date: 5/19/17 Recent Posts

Thanks for your advice. I have got the solution with another tool itextpdf