繁体   English   中英

如何使用 xsl-fo 创建包含两列的 PDF 页面

[英]How can I create a PDF page with two columns with xsl-fo

我想从两个块创建一个 pdf 文件。 第一个块应始终面向页面的左侧,第二个块应始终面向右侧。 第二个块始终面向右侧非常重要。 即使块中的文本将是几页,它也应该只在右侧。

来看看。 我用微软Word做了一个例子。 请打开它以确切了解我的意思:

使用 ms-word 制作的示例

注意:它不重要,应该使用什么(表,块,容器..等)。 只要我能够拥有跨页面流动的列,这就是重要的。

fo:block-container溢出时会发生什么有点模糊。 有一个overflow="repeat"选项,但我不知道它的实施、使用或理解的广泛程度。 (见https://www.w3.org/TR/xsl11/#overflow

我之前的回答确实将fo:block-container选项限定为“块不会跨页”。 您可以通过将每一侧放在单独的表格单元格中来处理超过一页的内容:

<fo:table>
  <fo:table-column column-width="50%" />
  <fo:table-column column-width="50%" />
  <fo:table-body>
    <fo:table-row>
      <fo:table-cell padding-right="6pt">
    <fo:block>:::::: Frist Block :::::::</fo:block>
      </fo:table-cell>
      <fo:table-cell padding-left="6pt">
    <fo:block>Lots of text</fo:block>
      </fo:table-cell>
    </fo:table-row>
  </fo:table-body>
</fo:table>

除了在表格单元格上放置填充外,另一种在两列之间获得间距的方法是在两列文本之间放置一个窄列。

         *<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
            <fo:layout-master-set>
               <fo:simple-page-master master-name="DIN-A4" page-height="297mm" page-width="210mm">
                  <fo:region-body region-name="inhalt" margin="2cm" />
                </fo:simple-page-master>
              </fo:layout-master-set>
            
              <fo:page-sequence master-reference="DIN-A4">
                <fo:flow flow-name="inhalt">
                 <fo:table>
              <fo:table-column column-width="50%" />
              <fo:table-column column-width="50%" />
              <fo:table-body>
                <fo:table-row>
                  <fo:table-cell padding-right="6pt">
                <fo:block>:::::: Frist Block :::::::</fo:block>
                  </fo:table-cell>
                  <fo:table-cell padding-right="6pt">
                <fo:block> Choosing which university fits your interests and academic background is an important decision 
        that will greatly influence the success of your university study. In the UK alone, there are hundreds of
         choices and therefore you need to be strategic in making a shortlist of universities and narrowing down
          your choices into second and first choice. This involves weighing some factors such as your motivation 
          and aspiration, your personality, your location, and your budget.
    
    People attend university for different reasons, so ask yourself what you want from your target university and
     what you want to do after you graduate. Many people attend top universities because of the prestige without 
     considering their choice of future career. If you have interest in a particular career, you should find 
     universities with a better reputation for your career choice than others. With a degree from a university 
     that is most respected in the profession you want to enter, it will be easy for you to get your dream job 
     and you will be able to climb the career ladder fast.
    
    Your personality types also play an important role in your success as a university student. A scholarly type
     student usually has self-motivation to work hard in order to ace exams and achieve high grades. This type of
      person will find comfort in a highly academic environment offered by top world universities such as Oxford
       or Cambridge. On the contrary, if you are not a type of person who can study for hours and getting top 
       grades is not your main priority, you better go to a university with a more laid-back academic environment 
       so that you will not be stressful all the time and can enjoy your life at university.
    
    
    Coming home could be a good escape during your hard time at university, so think about the distance between
     your home and the target university. If you get homesick easily,

you should not consider choosing a university
      outside your hometown or which takes more than a day to travel by land or water. However, if distance is not 
      a problem for you, you might want to consider studying abroad, especially at a university whose reputation is
       better than the universities in your home country.


</fo:block>
                  </fo:table-cell>
                </fo:table-row>
              </fo:table-body>
            </fo:table>
            
                </fo:flow>
              </fo:page-sequence>
            </fo:root>*

所以现在我添加了一些有意义的文本。 我看到的 PDF 就像: PDF

PDF中没有显示这部分:

不要考虑选择家乡以外的大学,或者陆路或水路需要一天以上的大学。 但是,如果距离对您来说不是问题,您可能需要考虑出国留学,尤其是在声誉优于本国大学的大学。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM