2016-04-22 8 views
0

JavaでPDF Clownを使用してプログラムでPDFファイルを作成したいと考えています。私は箇条書きでリストを使う必要があります。これはPDF Clownの現在の安定版を使用して可能ですか?もしそうなら、私はAPIドキュメンテーションでどのクラスを調べるべきですか?私はドキュメントのリストを検索していますが、それについての言及はありません。PDF Clown:リストの作成

私が特定のサポートなしでこれを行うと考えることができる唯一の方法は、Xオフセットを持つBlockComposerを使用することですが、これはBulletポイントを持たないでしょう。どんな解決策ですか?

この機能は、PDF Clown(0.2.0)の次期リリースに向けて計画されていますが、それを待つのは遠すぎます。

答えて

1

あなたは、これが、これがまだ安定していない、新しい0.2.0作曲を使用しています。この enter image description here

import org.pdfclown.documents.Document; 
import org.pdfclown.documents.contents.colors.DeviceRGBColor; 
import org.pdfclown.documents.contents.composition.*; 

. . . 

DocumentComposer composer = new DocumentComposer(document); 

/* 
    We decide that table cells sport a solid border by default (analogous 
    to CSS styles defined through an element type selector). 
*/ 
composer.getStyle(Cell.class) 
    .withBorder(new Border(
    new QuadColor(new DeviceRGBColor(0, 0, 0)), 
    new QuadBorderStyle(BorderStyleEnum.Solid), 
    new QuadLength(new Length(1)), 
    new QuadCornerRadius())) 
    .withPadding(new QuadLength(new Length(5))); 

/* 
    The list will be included in a section. 
*/ 
Section section = new Section("Hello World, this is PDF Clown!"); 

/* 
    This is the actual list composition. 
*/ 
List list = new List(
    new ListItem("Item 1"), 
    new ListItem("Item 2"), 
    new ListItem(
    /* We decide that this list item has an arbitrary 5pt margin. */ 
    new Style().withMargin(new QuadLength(new Length(5))), 
    "Item 3 (margin: 5pt)" 
    ), 
    new ListItem("Item 4"), 
    new ListItem("Item 5"), 
    new ListItem(
    /* We decide that this list item has a custom background color, border and padding. */ 
    new Style() 
     .withBackground(new Background(new DeviceRGBColor(252f/255, 232f/255, 131f/255))) 
     .withBorder(new Border(
     new QuadColor(new DeviceRGBColor(218f/255, 165f/255, 32f/255)), 
     new QuadBorderStyle(BorderStyleEnum.Dotted), 
     new QuadLength(new Length(2)), 
     new QuadCornerRadius(new Size(5)) 
     )) 
     .withPadding(new QuadLength(new Length(10))), 
    new Paragraph("Item 6 (background, border, padding test + nested table)" 
     + "\nLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor " 
     + "incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud " 
     + "exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure " 
     + "dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. " 
     + "Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt " 
     + "mollit anim id est laborum."), 
    /* Nested table. */ 
    new Table(
     new Row(
     new Cell("Cell1,1"), 
     new Cell("Cell1,2"), 
     new Cell("Cell1,3"), 
     new Cell("Cell1,4") 
     ), 
     new Row(
     new Cell("Cell2,1"), 
     new Cell("Cell2,2").withColSpan(2), 
     new Cell("Cell2,4") 
     ) 
    ) 
), 
    new ListItem(
    new Paragraph("Item 7 (sublist test)"), 
    /* Nested list. */ 
    new List(
     /* We decide this nested list sports circle markers. */ 
     new Style().withListStyle(new ListStyle(ListStyleTypeEnum.Circle)), 
     new ListItem("Sublist Item 1"), 
     new ListItem(
     new Paragraph("Sublist Item 2 (Sub-sublist with multiple custom markers mimicking an ordered list)"), 
     /* Level-2 nested list (custom ordered markers). */ 
     new List(
      /* 
      We decide this nested list sports a set of custom numerical symbols mapped 
      as octal codes to ZapfDingbats character set (see PDF Reference 1.7, § D.5, http://www.adobe.com/devnet/pdf/pdf_reference.html). 
      */ 
      new Style().withListStyle(new ListStyle(new char[]{0312, 0313, 0314, 0315, 0316, 0317, 0320, 0321, 0322})), 
      new ListItem("Sub-sublist Item 1"), 
      new ListItem("Sub-sublist Item 2"), 
      new ListItem("Sub-sublist Item 3"), 
      new ListItem("Sub-sublist Item 4"), 
      new ListItem("Sub-sublist Item 5") 
     ) 
     ), 
     new ListItem("Sublist Item 3"), 
     new ListItem(
     new Paragraph("Sublist Item 4 (Sub-sublist with decimal markers)"), 
     /* Level-2 nested list (decimal markers). */ 
     new List(
      new Style().withListStyle(new ListStyle(ListStyleTypeEnum.Decimal)), 
      new ListItem("Sub-sublist Item 1"), 
      new ListItem(
      new Paragraph("Sub-sublist Item 2 (Sub-sub-sublist with lower-latin markers)"), 
      /* Level-3 nested list (lower-latin markers). */ 
      new List(
       new Style().withListStyle(new ListStyle(ListStyleTypeEnum.LowerLatin)), 
       new ListItem("Sub-sub-sublist Item 1"), 
       new ListItem("Sub-sub-sublist Item 2"), 
       new ListItem("Sub-sub-sublist Item 3"), 
       new ListItem("Sub-sub-sublist Item 4"), 
       new ListItem("Sub-sub-sublist Item 5") 
      ) 
      ), 
      new ListItem("Sub-sublist Item 3"), 
      new ListItem("Sub-sublist Item 4"), 
      new ListItem("Sub-sublist Item 5") 
     ) 
     ), 
     new ListItem("Sublist Item 5") 
    ), 
    new Paragraph("End of Item 7") 
    ), 
    new ListItem("Item 8") 
); 
section.add(list); 

composer.show(section); 
composer.close();
+0

のようにそれを行うことができます。 – psycotik