Examples of RTFDocument


Examples of com.lowagie.text.rtf.document.RtfDocument

     */
    public void close() {
        if (open) {
            rtfDoc.writeDocument(os);
            super.close();
            this.rtfDoc = new RtfDocument();
        }
    }
View Full Code Here

Examples of net.sourceforge.rtf.document.RTFDocument

             * 3. Get RTF Document of the rtf source model
             */
            String rtfSourceModel = "test.rtf";
            InputStream inputStream = TestFreemarkerTransformer.class.getResourceAsStream(rtfSourceModel);
            parser.parse(inputStream);
            RTFDocument document = parser.getRTFDocument();
           
            /**
             * 4. Prepare RTF context fields
             * => set the field which must be transformed
             * In test.rtf, there is a mergefield called "date"
             */
            RTFContextFields context = new RTFContextFields();
            RTFContextField field = new RTFContextField();
            field.setName("$date");
            context.addMergeField(field);           
           
           /**
            * 5. Get the RTF velocity transformer
            */
            IRTFDocumentTransformer velocityTransformer =
                builder.
                newRTFDocumentTransformer(RTFTemplateBuilder.VELOCITY_TRANSFORMER);
            RTFDocument transformedDocument = velocityTransformer.transform(document, context);
           
            /**
             * 6. Display transformed RTFDocument
             */
            Reader reader = transformedDocument.getReader();
            BufferedReader br = new BufferedReader(reader);
            int c;
            while ((c = br.read()) != -1) {
                System.out.print((char)c);
            }
View Full Code Here

Examples of net.sourceforge.rtf.document.RTFDocument

            throw new IOException("RTFDocumentTransformer must be defined. Use setTransformer method to set it.");
       
        /**
         * 1. Parse RTF reader to transform it with macoro of template engine.
         */
        RTFDocument document = null;
        if (rtfSourceInputStream != null)
            parser.parse(this.rtfSourceInputStream);
        else
            parser.parse(this.rtfSourceReader);       
        document = parser.getRTFDocument();
View Full Code Here

Examples of net.sourceforge.rtf.document.RTFDocument

    }
   
    private boolean setTemplate(HttpServletRequest request, RTFTemplate rtfTemplate, String cackeWitkKey) throws Exception {
        // test if RTF model is cached
        if (cackeWitkKey != null) {
            RTFDocument cachedTransformedDocument = (RTFDocument)cachedTransformedDocumentMap.get(cackeWitkKey);
            if (cachedTransformedDocument != null) {
                // Use cached Transformed Document
                rtfTemplate.setTransformedDocument(cachedTransformedDocument);
                return true;
            }
View Full Code Here

Examples of net.sourceforge.rtf.document.RTFDocument

            throws IOException {
        this.currentLevel = level; // store level of current group
        if (level == 1) {
            // start parsing of RTF source
            // Create RTFDocument object which is root of RTF source.
            document = new RTFDocument();
            currentRTFElement = document;
            getCurrentRTFElement().addRTFString(
                    String.valueOf(startGroupCharacter));
        } else {
            // store start group character '{'.
View Full Code Here

Examples of net.sourceforge.rtf.document.RTFDocument

        /**
         * 8. Put Context
         */
        putContext(rtfTemplate.getContext());
        if (saveTransformedDocument) {
            RTFDocument transformedDocument = rtfTemplate.transform();
            transformedDocument.save(new File(rtfTransformedDocumentOutput));
        }

        /**
         * 9. Merge template and context
         */
 
View Full Code Here

Examples of net.sourceforge.rtf.document.RTFDocument

    public RTFDocument transform(RTFDocument document,
            RTFContextFields contextFields) throws IOException {
        Map contextFieldsMap = (contextFields == null ? new HashMap()
                : contextFields.getMergeFieldsMap());
        RTFDocument documentTransformed = new RTFDocument(document);
        transform(documentTransformed, documentTransformed.getElementList(),
                contextFieldsMap);
        // Replace element Bookmark end by #end, if Bookmark start were replace
        // by #foreach
        for (Iterator iter = bookmarkEndMap.keySet().iterator(); iter.hasNext();) {
            String endBookmarkName = (String) iter.next();
View Full Code Here

Examples of net.sourceforge.rtf.document.RTFDocument

             * 3. Get RTF Document of the rtf source model
             */
            String rtfSourceModel = "test.rtf";
            InputStream inputStream = TestFreemarkerTransformer.class.getResourceAsStream(rtfSourceModel);
            parser.parse(inputStream);
            RTFDocument document = parser.getRTFDocument();
           
            /**
             * 4. Prepare RTF context fields
             * => set the field which must be transformed
             * In test.rtf, there is a mergefield called "date"
             */
            RTFContextFields context = new RTFContextFields();
            RTFContextField field = new RTFContextField();
            field.setName("$date");
            context.addMergeField(field);
           
           /**
            * 5. Get the RTF freemarker transformer
            */
            IRTFDocumentTransformer freemarkerTransformer =
                builder.
                newRTFDocumentTransformer(RTFTemplateBuilder.FREEMARKER_TRANSFORMER);
            RTFDocument transformedDocument = freemarkerTransformer.transform(document, context);
           
            /**
             * 6. Display transformed RTFDocument
             */
            Reader reader = transformedDocument.getReader();
            BufferedReader br = new BufferedReader(reader);
            int c;
            while ((c = br.read()) != -1) {
                System.out.print((char)c);
            }
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.