使用 FOP 从 A4 PDF 中提取页面并创建 A3 PDF
Using FOP to pull pages from an A4 PDF and create a A3 PDF
我希望有人能帮助我。
目前我使用 FOP 和 XSLT 创建 A4 文档。我被要求拍摄这些 A4(纵向)页面,然后将它们缝合到 A3 小册子中。因此,例如,我有一个 4 页的 A4 文档,我需要将其转换成一个 2 面的 A3 小册子,并能够使用第 4 和 1 页(并排)订购第一面,然后将另一面作为第 2 和 3 页.
我查看了 PDFBOX 是否可以做到这一点,但没有成功。
有人知道我怎样才能得到我需要的结果吗?
感谢所有帮助!
如果你愿意,你可以用 FOP 做到这一点,如果你安装 PDF Images Plug-In for FOP
<?xml version="1.0" encoding="UTF-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="a3" margin-right="0mm" margin-left="0mm" margin-bottom="0mm" margin-top="0mm" page-width="42cm" page-height="29.7cm">
<fo:region-body margin-left="0mm" margin-top="0mm" margin-bottom="0mm" margin-right="0mm"/>
</fo:simple-page-master>
<fo:page-sequence-master master-name="a3n">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference master-reference="a3" page-position="any"/>
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="a3n">
<fo:flow flow-name="xsl-region-body">
<fo:block-container height="29.7cm" width="20.9cm" top="0mm" left="0mm" position="absolute">
<fo:block>
<fo:external-graphic content-height="29.7cm" content-width="21cm" height="29.7cm" width="21cm" src="yourpathdoc.pdf#page=2"/>
</fo:block>
</fo:block-container>
<fo:block-container height="29.7cm" width="20.9cm" top="0mm" left="209mm" position="absolute">
<fo:block>
<fo:external-graphic content-height="29.7cm" content-width="21cm" height="29.7cm" width="21cm" src="yourpathdoc.pdf#page=3"/>
</fo:block>
</fo:block-container>
<fo:block-container>
<fo:block font-size="0.1pt" page-break-after="always" break-after="page"> </fo:block>
</fo:block-container>
<fo:block-container height="29.7cm" width="20.9cm" top="0mm" left="0mm" position="absolute">
<fo:block>
<fo:external-graphic content-height="29.7cm" content-width="21cm" height="29.7cm" width="21cm" src="yourpathdoc.pdf#page=4"/>
</fo:block>
</fo:block-container>
<fo:block-container height="29.7cm" width="20.9cm" top="0mm" left="209mm" position="absolute">
<fo:block>
<fo:external-graphic content-height="29.7cm" content-width="21cm" height="29.7cm" width="21cm" src="yourpathdoc.pdf#page=1"/>
</fo:block>
</fo:block-container>
</fo:flow>
</fo:page-sequence>
</fo:root>
编辑
如果您想要纵向打印以便于打印,只需切换 simple-page-master 的 page-width 和 page-height 并将包含 position="absolute" 的四个 block-container 行替换为
<fo:block-container height="29.7cm" width="21cm" top="0mm" left="0mm" position="absolute" reference-orientation="270">
...
<fo:block-container height="29.7cm" width="21cm" top="210mm" left="0mm" position="absolute" reference-orientation="270">
...
<fo:block-container height="29.7cm" width="21cm" top="0mm" left="0mm" position="absolute" reference-orientation="270">
...
<fo:block-container height="29.7cm" width="21cm" top="210mm" left="0mm" position="absolute" reference-orientation="270">
如果您的页面超过两页,请不要忘记插入
<fo:block-container>
<fo:block font-size="0.1pt" page-break-after="always" break-after="page"> </fo:block>
</fo:block-container>
中间的任何地方(每隔两张图片之后)
我希望有人能帮助我。
目前我使用 FOP 和 XSLT 创建 A4 文档。我被要求拍摄这些 A4(纵向)页面,然后将它们缝合到 A3 小册子中。因此,例如,我有一个 4 页的 A4 文档,我需要将其转换成一个 2 面的 A3 小册子,并能够使用第 4 和 1 页(并排)订购第一面,然后将另一面作为第 2 和 3 页.
我查看了 PDFBOX 是否可以做到这一点,但没有成功。
有人知道我怎样才能得到我需要的结果吗?
感谢所有帮助!
如果你愿意,你可以用 FOP 做到这一点,如果你安装 PDF Images Plug-In for FOP
<?xml version="1.0" encoding="UTF-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="a3" margin-right="0mm" margin-left="0mm" margin-bottom="0mm" margin-top="0mm" page-width="42cm" page-height="29.7cm">
<fo:region-body margin-left="0mm" margin-top="0mm" margin-bottom="0mm" margin-right="0mm"/>
</fo:simple-page-master>
<fo:page-sequence-master master-name="a3n">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference master-reference="a3" page-position="any"/>
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="a3n">
<fo:flow flow-name="xsl-region-body">
<fo:block-container height="29.7cm" width="20.9cm" top="0mm" left="0mm" position="absolute">
<fo:block>
<fo:external-graphic content-height="29.7cm" content-width="21cm" height="29.7cm" width="21cm" src="yourpathdoc.pdf#page=2"/>
</fo:block>
</fo:block-container>
<fo:block-container height="29.7cm" width="20.9cm" top="0mm" left="209mm" position="absolute">
<fo:block>
<fo:external-graphic content-height="29.7cm" content-width="21cm" height="29.7cm" width="21cm" src="yourpathdoc.pdf#page=3"/>
</fo:block>
</fo:block-container>
<fo:block-container>
<fo:block font-size="0.1pt" page-break-after="always" break-after="page"> </fo:block>
</fo:block-container>
<fo:block-container height="29.7cm" width="20.9cm" top="0mm" left="0mm" position="absolute">
<fo:block>
<fo:external-graphic content-height="29.7cm" content-width="21cm" height="29.7cm" width="21cm" src="yourpathdoc.pdf#page=4"/>
</fo:block>
</fo:block-container>
<fo:block-container height="29.7cm" width="20.9cm" top="0mm" left="209mm" position="absolute">
<fo:block>
<fo:external-graphic content-height="29.7cm" content-width="21cm" height="29.7cm" width="21cm" src="yourpathdoc.pdf#page=1"/>
</fo:block>
</fo:block-container>
</fo:flow>
</fo:page-sequence>
</fo:root>
编辑
如果您想要纵向打印以便于打印,只需切换 simple-page-master 的 page-width 和 page-height 并将包含 position="absolute" 的四个 block-container 行替换为
<fo:block-container height="29.7cm" width="21cm" top="0mm" left="0mm" position="absolute" reference-orientation="270">
...
<fo:block-container height="29.7cm" width="21cm" top="210mm" left="0mm" position="absolute" reference-orientation="270">
...
<fo:block-container height="29.7cm" width="21cm" top="0mm" left="0mm" position="absolute" reference-orientation="270">
...
<fo:block-container height="29.7cm" width="21cm" top="210mm" left="0mm" position="absolute" reference-orientation="270">
如果您的页面超过两页,请不要忘记插入
<fo:block-container>
<fo:block font-size="0.1pt" page-break-after="always" break-after="page"> </fo:block>
</fo:block-container>
中间的任何地方(每隔两张图片之后)