Examples of RtfWriter2


Examples of com.lowagie.text.rtf.RtfWriter2

      document = new Document(pageSize, marginLeft, marginRight, marginTop, marginBottom);
      imageCache = new RTFImageCache(resourceManager);

      // rtf does not support PageFormats or other meta data...
      final RtfWriter2 instance = RtfWriter2.getInstance(document, new NoCloseOutputStream(outputStream));
      instance.getDocumentSettings().setAlwaysUseUnicode(true);

      final String author = config.getConfigProperty
          ("org.pentaho.reporting.engine.classic.core.modules.output.table.rtf.Author");
      if (author != null)
      {
View Full Code Here

Examples of com.lowagie.text.rtf.RtfWriter2

     */
    public static void main(String[] args) {
        System.out.println("Table of contents and Cell borders");
        LwgDocument document = new LwgDocument();
        try {
            RtfWriter2 writer2 = RtfWriter2.getInstance(document, new FileOutputStream("toc.rtf"));
           
            writer2.setAutogenerateTOCEntries(true);
           
            document.open();
           
            Paragraph para = new Paragraph();
            para.add(new RtfTableOfContents("RIGHT CLICK AND HERE AND SELECT \"UPDATE FIELD\" TO UPDATE."));
View Full Code Here

Examples of com.lowagie.text.rtf.RtfWriter2

    public static void main(String[] args) {
        System.out.println("Test Suite");

        try {
            LwgDocument doc = new LwgDocument();
            RtfWriter2 writer2 = RtfWriter2.getInstance(doc,
                    new FileOutputStream("testNew.rtf"));

            writer2.setAutogenerateTOCEntries(true);

            Table headerTable = new Table(3);
            headerTable.addCell("Test Cell 1");
            headerTable.addCell("Test Cell 2");
            headerTable.addCell("Test Cell 3");
View Full Code Here

Examples of com.lowagie.text.rtf.RtfWriter2

     */
    public static void main(String[] args) {
        System.out.println("Demonstrates creating new, user-defined paragraph stylesheets");
        try {
            LwgDocument document = new LwgDocument();
            RtfWriter2 writer = RtfWriter2.getInstance(document, new FileOutputStream("ExtendingStylesheets.rtf"));

            // Create the new RtfParagraphStyle. The second parameter is the name of
            // the RtfParagraphStyle that this style will inherit default properties from.
            RtfParagraphStyle incorrectStyle = new RtfParagraphStyle("Incorrect", "Normal");
            // Change the desired properties
            incorrectStyle.setColor(Color.RED);
            incorrectStyle.setStyle(LwgFont.STRIKETHRU);
            // Register the new paragraph stylesheet with the RtfWriter2.
            writer.getDocumentSettings().registerParagraphStyle(incorrectStyle);
           
            // Create a new RtfParagraphStyle that does not inherit from any other style.
            RtfParagraphStyle correctStyle = new RtfParagraphStyle("Correct", "Arial",
                    12, LwgFont.NORMAL, Color.GREEN);
            // Register the new paragraph stylesheet with the RtfWriter2.
            writer.getDocumentSettings().registerParagraphStyle(correctStyle);

            // Change the default font name. This will propagate to the paragraph stylesheet
            // that inherits, but not the other one.
            RtfParagraphStyle.STYLE_NORMAL.setFontName("Times New Roman");
           
View Full Code Here

Examples of com.lowagie.text.rtf.RtfWriter2

     */
    public static void main(String[] args) {
        System.out.println("Demonstrates using the RTF table of contents.");
        try {
            LwgDocument document = new LwgDocument();
            RtfWriter2 rtfWriter2 = RtfWriter2.getInstance(document, new FileOutputStream("TableOfContents.rtf"));

            // Create paragraph stylesheets for each heading level. They must be named
            // "toc N" for each heading level you are using
            RtfParagraphStyle tocLevel1Style = new RtfParagraphStyle("toc 1",
                    "Times New Roman", 11, LwgFont.NORMAL, Color.BLACK);
            RtfParagraphStyle tocLevel2Style = new RtfParagraphStyle("toc 2",
                    "Times New Roman", 10, LwgFont.NORMAL, Color.BLACK);
            tocLevel2Style.setIndentLeft(10);
           
            // Register the paragraph stylesheets with the RtfWriter2
            rtfWriter2.getDocumentSettings().registerParagraphStyle(tocLevel1Style);
            rtfWriter2.getDocumentSettings().registerParagraphStyle(tocLevel2Style);
           
            document.open();

            // Create a Paragraph and add the table of contents to it
            Paragraph par = new Paragraph();
View Full Code Here

Examples of com.lowagie.text.rtf.RtfWriter2

    try {
      // step 2:
      // we create 3 different writers that listen to the document
      PdfWriter pdf = PdfWriter.getInstance(document,
          new FileOutputStream("HelloWorldPdf.pdf"));
      RtfWriter2 rtf = RtfWriter2.getInstance(document,
          new FileOutputStream("HelloWorldRtf.rtf"));
      HtmlWriter.getInstance(document,
          new FileOutputStream("HelloWorldHtml.html"));

      // step 3: we open the document
      document.open();
      // step 4: we add a paragraph to the document
      document.add(new Paragraph("Hello World"));
      // we make references
      Anchor pdfRef = new Anchor("see Hello World in PDF.");
      pdfRef.setReference("./HelloWorldPdf.pdf");
      Anchor rtfRef = new Anchor("see Hello World in RTF.");
      rtfRef.setReference("./HelloWorldRtf.rtf");
     
      // we add the references, but only to the HTML page:
     
      pdf.pause();
      rtf.pause();
      document.add(pdfRef);
      document.add(Chunk.NEWLINE);
      document.add(rtfRef);
      pdf.resume();
      rtf.resume();
     
    } catch (DocumentException de) {
      System.err.println(de.getMessage());
    } catch (IOException ioe) {
      System.err.println(ioe.getMessage());
View Full Code Here

Examples of com.lowagie.text.rtf.RtfWriter2

    }

    // 打开rtf文档
    Document document = new Document();
    FileOutputStream myFile = new FileOutputStream(filePath);
    RtfWriter2 rtfWriter2 = RtfWriter2.getInstance(document, myFile);
    document.open();
    // TODO 加文档标题,即项目名 有待居中
    RtfFont projectNameFont = new RtfFont("Arial", 35, RtfFont.STYLE_BOLD);
    Paragraph paragraph = new Paragraph();
    // Use the RtfFonts when creating the text.
    paragraph.add(new Chunk(projectName, projectNameFont));
    Paragraph paragraph2 = new Paragraph();
    // Use the RtfFonts when creating the text.
    paragraph2.add(new Chunk("需求文档", projectNameFont));

    paragraph.setAlignment(1);
    paragraph2.setAlignment(1);
    document.add(paragraph);
    document.add(paragraph2);
    // 加Table of Content
    RtfParagraphStyle tocLevel1Style = new RtfParagraphStyle("toc 1",
        "Times New Roman", 11, Font.NORMAL, Color.BLACK);
    RtfParagraphStyle tocLevel2Style = new RtfParagraphStyle("toc 2",
        "Times New Roman", 10, Font.NORMAL, Color.BLACK);
    tocLevel2Style.setIndentLeft(10);

    // Register the paragraph stylesheets with the RtfWriter2
    rtfWriter2.getDocumentSettings().registerParagraphStyle(tocLevel1Style);
    rtfWriter2.getDocumentSettings().registerParagraphStyle(tocLevel2Style);

    // Create a Paragraph and add the table of contents to it
    Paragraph par = new Paragraph();

    par.add(new RtfTableOfContents("如想查看目录,单击右键选择\"更新域\""));
    par.setAlignment(1);
    document.add(par);

    CompositeDataProxy cdp = CompositeDataProxy.getInstance();
    SingleDataProxy sdp = SingleDataProxy.getInstance();
    Project p = new Project();
    p.setProjectName(projectName);
    p = (Project) sdp.get(p);
    // 得到该项目的所有的场景
    Scenario s = new Scenario();
    s.setProjectId(p.getProjectId());
    scenarios = cdp.query(s);
    if (scenarios.size() > 0) {
      for (int i = 0; i < scenarios.size(); i++) {
        s = (Scenario) scenarios.get(i);
        document.add(new Paragraph(""));
        // 加场景名
        document.add(new Paragraph("场景" + (i + 1) + ": "
            + s.getScenarioName().toString(),
            RtfParagraphStyle.STYLE_HEADING_1));
        // TODO 加用况
        UseCase uc = new UseCase();
        uc.setScenarioId(s.getScenarioId());
        ArrayList ucs = cdp.query(uc);
        if (ucs.size() > 0) {
          for (int j = 0; j < ucs.size(); j++) {

            uc = (UseCase) ucs.get(j);
            document.add(new Paragraph(""));
            document.add(new Paragraph("用况" + (i + 1) + "."
                + (j + 1) + ": "
                + uc.getUseCaseName().toString(),
                RtfParagraphStyle.STYLE_HEADING_2));

            RtfBorderGroup normal = new RtfBorderGroup(
                Rectangle.BOX, RtfBorder.BORDER_SINGLE, 1,
                new Color(0, 0, 0));

            Paragraph title = new Paragraph();
            title.add(new Chunk(uc.getUseCaseName().trim()));
            title.setAlignment(1);
            document.add(title);

            RtfCell useCaseID = new RtfCell("用况编号:");
            useCaseID.setBorders(normal);

            RtfCell useCaseIDC = new RtfCell(uc.getUseCaseId()
                .toString());
            useCaseIDC.setBorders(normal);

            RtfCell useCaseName = new RtfCell("用况名称:");
            useCaseName.setBorders(normal);

            RtfCell useCaseNameC = new RtfCell(uc.getUseCaseName());
            useCaseNameC.setBorders(normal);

            RtfCell useCaseDescription = new RtfCell("用况描述:");
            useCaseDescription.setBorders(normal);

            RtfCell useCaseDescriptionC = new RtfCell(uc
                .getUseCaseDescription());
            useCaseDescriptionC.setBorders(normal);

            RtfCell useCasePriority = new RtfCell("用况优先级:");
            useCasePriority.setBorders(normal);

            RtfCell useCasePriorityC = null;

            if (uc.getUseCasePriority() != null) {
              useCasePriorityC = new RtfCell(uc
                  .getUseCasePriority().toString());
            } else {
              useCasePriorityC = new RtfCell("");
            }

            useCasePriorityC.setBorders(normal);

            RtfCell specialRequirement = new RtfCell("特殊要求:");
            specialRequirement.setBorders(normal);

            RtfCell specialRequirementC = new RtfCell(uc
                .getUseCaseSpecialRequirement());
            specialRequirementC.setColspan(3);
            specialRequirementC.setBorders(normal);

            RtfCell preCondition = new RtfCell("前置条件:");
            preCondition.setBorders(normal);

            RtfCell preConditionC = new RtfCell(uc
                .getUseCasePreconditions());
            preConditionC.setColspan(3);
            preConditionC.setBorders(normal);

            RtfCell fireCondition = new RtfCell("触发条件:");
            fireCondition.setBorders(normal);

            RtfCell fireConditionC = new RtfCell(uc
                .getUseCaseTrigger());
            fireConditionC.setColspan(3);
            fireConditionC.setBorders(normal);

            RtfCell postCondition = new RtfCell("后置条件:");
            postCondition.setBorders(normal);

            RtfCell postConditionC = new RtfCell(uc
                .getUseCasePostConditions());
            postConditionC.setColspan(3);
            postConditionC.setBorders(normal);

            RtfCell failedEndCondition = new RtfCell("失败情况:");
            failedEndCondition.setBorders(normal);

            RtfCell failedEndConditionC = new RtfCell(uc
                .getUseCaseFailedEndCondition());
            failedEndConditionC.setColspan(3);
            failedEndConditionC.setBorders(normal);

            Table table = new Table(4);
            table.addCell(useCaseID);
            table.addCell(useCaseIDC);
            table.addCell(useCaseName);
            table.addCell(useCaseNameC);
            table.addCell(useCaseDescription);
            table.addCell(useCaseDescriptionC);
            table.addCell(useCasePriority);
            table.addCell(useCasePriorityC);
           
            table.addCell(fireCondition);
            table.addCell(fireConditionC);
            table.addCell(preCondition);
            table.addCell(preConditionC);
            table.addCell(failedEndCondition);
            table.addCell(failedEndConditionC);
            table.addCell(postCondition);
            table.addCell(postConditionC);         
            table.addCell(specialRequirement);
            table.addCell(specialRequirementC);

            // 生成Use Case具体描述的标题

            RtfCell userOperation = new RtfCell("用户操作");
            userOperation.setBorders(normal);

            RtfCell systemOperation = new RtfCell("系统操作");
            systemOperation.setBorders(normal);

            RtfCell systemOutput = new RtfCell("系统输出");
            systemOutput.setBorders(normal);

            Table table2 = new Table(3);
            table2.addCell(userOperation);
            table2.addCell(systemOperation);
            table2.addCell(systemOutput);

            // 生成Use Case具体描述的内容
            ArrayList ucis = new ArrayList();

            UseCaseInteraction uci = new UseCaseInteraction();
            uci.setUseCaseId(uc.getUseCaseId());
            OrderRule orderule = new OrderRule();
            orderule.setOrderColumn("sequence");
            orderule.setOrderDirection(OrderDirection.ASC);
            OrderRule[] orderRules = { orderule };
            String temp;
            ucis = cdp.query(uci, orderRules);
            if (ucis.size() > 0) {
              for (int k = 0; k < ucis.size(); k++) {
                temp = ((UseCaseInteraction) ucis.get(k))
                    .getOperatorAction();
                temp = removeHtml(temp);
                RtfCell userOperationC = new RtfCell(temp);
                userOperationC.setBorders(normal);

                temp = ((UseCaseInteraction) ucis.get(k))
                    .getSystemAction();
                temp = removeHtml(temp);
                RtfCell systemOperationC = new RtfCell(temp);
                systemOperationC.setBorders(normal);

                temp = ((UseCaseInteraction) ucis.get(k))
                    .getSystemOutput();
                temp = removeHtml(temp);
                RtfCell systemOutputC = new RtfCell(temp);
                systemOutputC.setBorders(normal);
                table2.addCell(userOperationC);
                table2.addCell(systemOperationC);
                table2.addCell(systemOutputC);
              }

            } else {

            }
            //

            document.add(table);
            document.add(table2);

          }

        } else {
          // TODO 暂无用况的时候
          document.add(new Paragraph(""));
          Paragraph noUseCase = new Paragraph();
          noUseCase.add(new Chunk("暂无用况"));
          document.add(noUseCase);
        }
      }

    } else {
      // TODO 加场景名 暂无场景的时候
    }

    document.close();
    myFile.close();
    rtfWriter2.close();

    return myFilePath;
  }
View Full Code Here

Examples of com.lowagie.text.rtf.RtfWriter2

        System.out.println("Demonstrates setting document settings");
        try {
            LwgDocument document = new LwgDocument();
           
            // Keep a reference to the RtfWriter2 instance.
            RtfWriter2 writer2 = RtfWriter2.getInstance(document, new FileOutputStream("DocumentSettings.rtf"));
           
            // Specify that the document caching is to be done on disk.
            writer2.getDocumentSettings().setDataCacheStyle(RtfDataCache.CACHE_DISK);
           
            // Specify that all \n are translated into soft linebreaks.
            writer2.getDocumentSettings().setAlwaysGenerateSoftLinebreaks(true);
           
            document.open();
            document.add(new Paragraph("This example has been cached on disk\nand all " +
                    "\\n have been translated into soft linebreaks."));
            document.close();
View Full Code Here

Examples of com.lowagie.text.rtf.RtfWriter2

    try {
      // step 2:
      // we create 3 different writers that listen to the document
      PdfWriter pdf = PdfWriter.getInstance(document,
          new FileOutputStream("HelloWorldPdf.pdf"));
      RtfWriter2 rtf = RtfWriter2.getInstance(document,
          new FileOutputStream("HelloWorldRtf.rtf"));
      HtmlWriter.getInstance(document,
          new FileOutputStream("HelloWorldHtml.html"));

      // step 3: we open the document
      document.open();
      // step 4: we add a paragraph to the document
      document.add(new Paragraph("Hello World"));
      // we make references
      Anchor pdfRef = new Anchor("see Hello World in PDF.");
      pdfRef.setReference("./HelloWorldPdf.pdf");
      Anchor rtfRef = new Anchor("see Hello World in RTF.");
      rtfRef.setReference("./HelloWorldRtf.rtf");
     
      // we add the references, but only to the HTML page:
     
      pdf.pause();
      rtf.pause();
      document.add(pdfRef);
      document.add(Chunk.NEWLINE);
      document.add(rtfRef);
      pdf.resume();
      rtf.resume();
     
    } catch (DocumentException de) {
      System.err.println(de.getMessage());
    } catch (IOException ioe) {
      System.err.println(ioe.getMessage());
View Full Code Here

Examples of com.lowagie.text.rtf.RtfWriter2

     */
    public static void main(String[] args) {
        System.out.println("Demonstrates using the RTF table of contents.");
        try {
            Document document = new Document();
            RtfWriter2 rtfWriter2 = RtfWriter2.getInstance(document, new FileOutputStream("TableOfContents.rtf"));

            // Create paragraph stylesheets for each heading level. They must be named
            // "toc N" for each heading level you are using
            RtfParagraphStyle tocLevel1Style = new RtfParagraphStyle("toc 1",
                    "Times New Roman", 11, Font.NORMAL, Color.BLACK);
            RtfParagraphStyle tocLevel2Style = new RtfParagraphStyle("toc 2",
                    "Times New Roman", 10, Font.NORMAL, Color.BLACK);
            tocLevel2Style.setIndentLeft(10);
           
            // Register the paragraph stylesheets with the RtfWriter2
            rtfWriter2.getDocumentSettings().registerParagraphStyle(tocLevel1Style);
            rtfWriter2.getDocumentSettings().registerParagraphStyle(tocLevel2Style);
           
            document.open();

            // Create a Paragraph and add the table of contents to it
            Paragraph par = new Paragraph();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.