Package net.sourceforge.rtf

Examples of net.sourceforge.rtf.RTFTemplate


            RTFTemplateBuilder builder = RTFTemplateBuilder.newRTFTemplateBuilder();
           
            /**
             * 2. Get RTFtemplate with Velocity Implementation
             */
            RTFTemplate rtfTemplate = builder.
                newRTFTemplate(RTFTemplateBuilder.DEFAULT_VELOCITY_RTFTEMPLATE);
           
            /**
             * Load XML fields available and set it to the RTFTemplate
             */
            InputStream xmlFieldsStream = RTFTemplateWithVelocityAndXmlFields.class.getResourceAsStream("test.fields.xml");
            rtfTemplate.setXmlFields(xmlFieldsStream);
           
            /**
             * 3. Set the template
             */
            String rtfSourceModel = "test.rtf";
            InputStream inputStream = TestFreemarkerTransformer.class.getResourceAsStream(rtfSourceModel);
            rtfTemplate.setTemplate(inputStream);
           
            /**
             * 4. Put context
             */
            rtfTemplate.put("date", new Date());
           
            /**
             * 5. Merge context with template
             * In this case context will be used to transform RTFDocument
             */ 
            StringWriter writer = new StringWriter();
            rtfTemplate.merge(writer);
           
            // => Result of merge
            System.out.println(writer.getBuffer());                       
           
        }
View Full Code Here


     * @return
     * @throws UnsupportedRTFDocumentTransformer
     */   
    public RTFTemplate newRTFTemplate(String rtfTemplateType)
        throws UnsupportedRTFTemplate {
        RTFTemplate rtfTemplate = (RTFTemplate)
            applicationContext.getBean(rtfTemplateType);
        if (rtfTemplate == null) {
            throw new UnsupportedRTFTemplate(rtfTemplateType);
        }
        return rtfTemplate;
View Full Code Here

           
            /**
             * 3. Get RTFtemplate with Implementation
             */
            String rtfTemplateImpl = getRTFTemplateImpl(request);
            RTFTemplate rtfTemplate = (rtfTemplateImpl != null ? builder.
                newRTFTemplate(rtfTemplateImpl) : builder.newRTFTemplate());
            rtfTemplate.setGroupByPerPageBreak(getGroupByPerPageBreak(request));
           
            /**
             * 4. Put default format
             */
            putDefaultFormat(request, rtfTemplate);
           
            /**
             * 5. Create a common inner context - not required but showing how common context values can be re-used
             */
            IContext ctx = rtfTemplate.getTemplateEngine().newContext();
            putGlobalContext(request, ctx);
           
            /**
             * 6. Set the template
             */
            boolean isAlreadyCached = this.setTemplate(request, rtfTemplate, cacheWitkKey);
           
            /**
             * 8. Put Context
             */         
            putContext(request, rtfTemplate.getContext());
         

    
            /*
             *   set the content type
             */
            setContentType( request, response );
           
            String fileName = getFileNameOfContentDisposition(request);
            if (fileName != null) {
              /*
                 *   set the filename of content disposition
                 */
              setContentDisposition(response, fileName);
            }
           
          /**
             * 10. Write to servlet Output
           *     result of Merge data with RTF model
           */
          Writer writer = response.getWriter();
      rtfTemplate.merge( writer);
           
            if (cacheWitkKey != null &&  !isAlreadyCached) {
                cachedTransformedDocumentMap.put(cacheWitkKey, rtfTemplate.getTransformedDocument());
            }
     

      }
      catch (Exception e)
View Full Code Here

            RTFTemplateBuilder builder = RTFTemplateBuilder.newRTFTemplateBuilder();
           
            /**
             * 2. Get RTFtemplate with Velocity Implementation
             */
            RTFTemplate rtfTemplate = builder.
                newRTFTemplate(RTFTemplateBuilder.DEFAULT_VELOCITY_RTFTEMPLATE);
           
            /**
             * 3. Set the template
             */
            String rtfSourceModel = "test.rtf";
            InputStream inputStream = TestFreemarkerTransformer.class.getResourceAsStream(rtfSourceModel);
            rtfTemplate.setTemplate(inputStream);
           
            /**
             * 4. Put context
             */
            rtfTemplate.put("date", new Date());
           
            /**
             * 5. Merge context with template
             * In this case context will be used to transform RTFDocument
             */ 
            StringWriter writer = new StringWriter();
            rtfTemplate.merge(writer);
           
            // => Result of merge
            System.out.println(writer.getBuffer());                       
           
        }
View Full Code Here

TOP

Related Classes of net.sourceforge.rtf.RTFTemplate

Copyright © 2018 www.massapicom. 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.