Page 1 of 1

DOCX to PDF

PostPosted: Tue May 19, 2020 5:56 pm
by ppg04
Hi ,

I am trying to convert docx to pdf using the docx4j api :
Code: Select all
Docx4J.toPDF(wordPorcessingMLPackage, os);


But the issue I am facing is that, I have implemented docx shapes as per wps standards and while converting docx to pdf , <mc: choice> is getting ignored. It goes to fallback block. The xml is of the following structure:

Code: Select all
            <mc:AlternateContent>
               <mc:Choice Requires="wps">
                  <w:drawing>.....
                  </w:drawing>
               </mc:Choice>
               <mc:Fallback>


I inspected the foSettings.xml but found that wps namespace is missing in the <fo:root>, as shown below
Code: Select all
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">


How will I be able to get wps enabled in the fo settings file? Am I missing anything?
Please provide your inputs.

Thanks & Regards,
Prachi

Re: DOCX to PDF

PostPosted: Thu May 21, 2020 5:30 pm
by ppg04
Hi Jason,

I realized that in docx2fo.xslt file, the support for wps is missing as shown below.

Code: Select all
  <xsl:template match="w:drawing">
   <xsl:apply-templates select="*"/>
  </xsl:template>

  <xsl:template match="wp:inline|wp:anchor">
     <xsl:variable name="wpinline" select="."/>     
     <xsl:choose>
        <!--  sanity check -->
        <xsl:when test="./a:graphic/a:graphicData/pic:pic">        
            <xsl:copy-of select="java:org.docx4j.model.images.WordXmlPictureE20.createXslFoImgE20(
                  $conversionContext,
                 $wpinline)" />        
        </xsl:when>


I want something like this to be enabled :

Code: Select all
<xsl:when test="./a:graphic/a:graphicData/wps:wsp">


Is there a way I can add this feature?

Please provide your inputs.

Thanks,
ppg04