docx4j PDF导出忽略文本方向
我正在使用最新的docx4j(3.3.7)和generate table,其中包含一个文本旋转90度的单元格docx4j PDF导出忽略文本方向,pdf,pdf-generation,docx4j,export-to-pdf,Pdf,Pdf Generation,Docx4j,Export To Pdf,我正在使用最新的docx4j(3.3.7)和generate table,其中包含一个文本旋转90度的单元格docx输出是正确的,但当导出到pdf时,此单元格中的文本不会旋转,只是从左到右常规方向旋转 Plutext的商用PDF转换器(默认情况下启用)和docx4j export fo具有相同的行为 如何强制表格单元格中的文本旋转? 用于在tableCell中旋转文本的代码(在docx中工作正常,在pdf导出过程中被忽略): 我也试过这个,效果也一样: TextDirection td = ne
docx
输出是正确的,但当导出到pdf
时,此单元格中的文本不会旋转,只是从左到右常规方向旋转
Plutext的商用PDF转换器(默认情况下启用)和docx4j export fo
具有相同的行为
如何强制表格单元格中的文本旋转?
用于在tableCell中旋转文本的代码(在docx
中工作正常,在pdf
导出过程中被忽略):
我也试过这个,效果也一样:
TextDirection td = new TextDirection();
td.setVal("tbRl");
paragraph.setPPr(new PPr());
paragraph.getPPr().setTextDirection(td);
我正在使用以下方法导出为PDF:
Docx4J.toPDF(wordprocessingMLPackage, fileOutputStream);
由于XSL FO具有属性引用方向,因此应该可以在docx4j导出FO中实现:
<?xml version="1.0" encoding="utf-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<layout-master-set
xmlns="http://www.w3.org/1999/XSL/Format"
xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml"
xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml"
xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing">
<simple-page-master margin-bottom="12mm"
margin-left="1in" margin-right="1in" margin-top="12mm"
master-name="s1-simple" page-height="297mm" page-width="210mm">
<region-body column-count="1" column-gap="12mm"
margin-bottom="36.0pt" margin-left="0mm" margin-right="0mm"
margin-top="36.0pt" />
<region-before extent="0.0pt"
region-name="xsl-region-before-simple" />
<region-after extent="0.0pt"
region-name="xsl-region-after-simple" />
</simple-page-master>
<page-sequence-master master-name="s1">
<repeatable-page-master-alternatives>
<conditional-page-master-reference
master-reference="s1-simple" />
</repeatable-page-master-alternatives>
</page-sequence-master>
</layout-master-set>
<fo:page-sequence force-page-count="no-force"
id="section_s1" format="" master-reference="s1">
<fo:flow flow-name="xsl-region-body">
<fo:table border-bottom-color="#000000"
border-bottom-style="solid" border-bottom-width="0.5pt"
border-collapse="collapse" border-left-color="#000000"
border-left-style="solid" border-left-width="0.5pt"
border-right-color="#000000" border-right-style="solid"
border-right-width="0.5pt" border-top-color="#000000"
border-top-style="solid" border-top-width="0.5pt"
display-align="before" start-indent="1.12in" table-layout="fixed"
width="3.12in">
<fo:table-column column-number="1"
column-width="3.12in" />
<fo:table-body start-indent="0in">
<fo:table-row height="0.79in"
keep-together.within-page="always">
<fo:table-cell border-bottom-color="#000000"
border-bottom-style="solid" border-bottom-width="0.5pt"
border-left-color="#000000" border-left-style="solid"
border-left-width="0.5pt" border-right-color="#000000"
border-right-style="solid" border-right-width="0.5pt"
border-top-color="#000000" border-top-style="solid"
border-top-width="0.5pt" padding-bottom="0mm"
padding-left="1.91mm" padding-right="1.91mm" padding-top="0mm">
<fo:block-container reference-orientation="90">
<block xmlns="http://www.w3.org/1999/XSL/Format"
font-size="11.0pt" line-height="100%" space-after="0in"
start-indent="2mm">
<inline font-family="Calibri">Bottom up</inline>
</block>
</fo:block-container>
</fo:table-cell>
</fo:table-row>
<fo:table-row height="0.79in"
keep-together.within-page="always">
<fo:table-cell border-bottom-color="#000000"
border-bottom-style="solid" border-bottom-width="0.5pt"
border-left-color="#000000" border-left-style="solid"
border-left-width="0.5pt" border-right-color="#000000"
border-right-style="solid" border-right-width="0.5pt"
border-top-color="#000000" border-top-style="solid"
border-top-width="0.5pt" padding-bottom="0mm"
padding-left="1.91mm" padding-right="1.91mm" padding-top="0mm">
<fo:block-container
reference-orientation="-90">
<block xmlns="http://www.w3.org/1999/XSL/Format"
font-size="11.0pt" line-height="100%" space-after="0in"
start-indent="2mm">
<inline font-family="Calibri">Top down</inline>
</block>
</fo:block-container>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
<fo:block font-size="11.0pt" line-height="107%"
space-after="0.11in" white-space-treatment="preserve">
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
自下而上
自上而下
文本按预期旋转,但在一种情况下显示在单元格外
另见
如果您进一步研究这个问题,您可能会得出一些额外的fo属性是必需的,或者这是FOP中的一个bug。请在此处的评论中分享您的发现
另外,XHTML输出中也有类似的行为。对不起,我不明白。docx4j 3.3.7是否可以实现,或者此功能未实现?我的回答在3.3.7中未实现,旨在为您提供足够的信息“搔痒”。现在实现了,但根据上面的编辑,可能需要调整。哇,谢谢-没想到!在我的项目中刚刚使用了github版本,TextDirection工作正常。我有你提到的bug,我会尝试自己修复它。
<?xml version="1.0" encoding="utf-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<layout-master-set
xmlns="http://www.w3.org/1999/XSL/Format"
xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml"
xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml"
xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing">
<simple-page-master margin-bottom="12mm"
margin-left="1in" margin-right="1in" margin-top="12mm"
master-name="s1-simple" page-height="297mm" page-width="210mm">
<region-body column-count="1" column-gap="12mm"
margin-bottom="36.0pt" margin-left="0mm" margin-right="0mm"
margin-top="36.0pt" />
<region-before extent="0.0pt"
region-name="xsl-region-before-simple" />
<region-after extent="0.0pt"
region-name="xsl-region-after-simple" />
</simple-page-master>
<page-sequence-master master-name="s1">
<repeatable-page-master-alternatives>
<conditional-page-master-reference
master-reference="s1-simple" />
</repeatable-page-master-alternatives>
</page-sequence-master>
</layout-master-set>
<fo:page-sequence force-page-count="no-force"
id="section_s1" format="" master-reference="s1">
<fo:flow flow-name="xsl-region-body">
<fo:table border-bottom-color="#000000"
border-bottom-style="solid" border-bottom-width="0.5pt"
border-collapse="collapse" border-left-color="#000000"
border-left-style="solid" border-left-width="0.5pt"
border-right-color="#000000" border-right-style="solid"
border-right-width="0.5pt" border-top-color="#000000"
border-top-style="solid" border-top-width="0.5pt"
display-align="before" start-indent="1.12in" table-layout="fixed"
width="3.12in">
<fo:table-column column-number="1"
column-width="3.12in" />
<fo:table-body start-indent="0in">
<fo:table-row height="0.79in"
keep-together.within-page="always">
<fo:table-cell border-bottom-color="#000000"
border-bottom-style="solid" border-bottom-width="0.5pt"
border-left-color="#000000" border-left-style="solid"
border-left-width="0.5pt" border-right-color="#000000"
border-right-style="solid" border-right-width="0.5pt"
border-top-color="#000000" border-top-style="solid"
border-top-width="0.5pt" padding-bottom="0mm"
padding-left="1.91mm" padding-right="1.91mm" padding-top="0mm">
<fo:block-container reference-orientation="90">
<block xmlns="http://www.w3.org/1999/XSL/Format"
font-size="11.0pt" line-height="100%" space-after="0in"
start-indent="2mm">
<inline font-family="Calibri">Bottom up</inline>
</block>
</fo:block-container>
</fo:table-cell>
</fo:table-row>
<fo:table-row height="0.79in"
keep-together.within-page="always">
<fo:table-cell border-bottom-color="#000000"
border-bottom-style="solid" border-bottom-width="0.5pt"
border-left-color="#000000" border-left-style="solid"
border-left-width="0.5pt" border-right-color="#000000"
border-right-style="solid" border-right-width="0.5pt"
border-top-color="#000000" border-top-style="solid"
border-top-width="0.5pt" padding-bottom="0mm"
padding-left="1.91mm" padding-right="1.91mm" padding-top="0mm">
<fo:block-container
reference-orientation="-90">
<block xmlns="http://www.w3.org/1999/XSL/Format"
font-size="11.0pt" line-height="100%" space-after="0in"
start-indent="2mm">
<inline font-family="Calibri">Top down</inline>
</block>
</fo:block-container>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
<fo:block font-size="11.0pt" line-height="107%"
space-after="0.11in" white-space-treatment="preserve">
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>