So, what are you using to read the file that shows the unexpected character(s)?

Howard

----- Original Message ----
From: Henry Lu <[EMAIL PROTECTED]>
To: Post all your questions about iText here 
<[email protected]>
Sent: Thursday, February 14, 2008 10:14:30 AM
Subject: Re: [iText-questions] rtf - strange character at the beginning

Thank you for your quick response. Here is my code:

private int MARGIN_LEFT = 5;
  private int MARGIN_RIGHT = 5;
  private int MARGIN_TOP = 30;
  private int MARGIN_BOTTOM = 30;

  public String makeCv(String MCV_ID,  // MCV_ID
        String rec_id,                // cv id
        OutputStream outStream)
  {
      int i, n;
      List list;
      String[] ss, name_ss;
      Phrase  ph;
      Cell    cel;

      // ////////////////////////////////////////////////////////////
      // get employee info
      Employee emp = m_employee.selectEmployee_mcv_id(MCV_ID);
      if (emp == null)
      {
        return null;
      }

      name_ss = makeNameForCV(emp);
      if (name_ss == null) {
        return null;
      }
      // ////////////////////////////////////////////////////////////
      // get address

      Address adr = m_address.selectAddress(MCV_ID, "W");

      ss = makeAddressForCV(adr);

      Document document = null;

      RtfFont boldFont = new RtfFont("Times New Roman", 12, RtfFont.BOLD);
      RtfFont boldFont14 = new RtfFont("Times New Roman", 14, RtfFont.BOLD);
      RtfFont bold_underline_Font12 = new RtfFont("Times New Roman", 12,
            RtfFont.BOLD + RtfFont.UNDERLINE);
    
      RtfFont plainFont = new RtfFont("Times New Roman", 12, 
RtfFont.STYLE_NONE);
      RtfFont plainItalicFont = new RtfFont("Times New Roman", 12,
            RtfFont.ITALIC);
      RtfFont plainFont10 = new RtfFont("Times New Roman", 10,
            RtfFont.STYLE_NONE);

      Paragraph newline_p = new Paragraph(" ", plainFont);
      Paragraph none_p = new Paragraph("        None", plainFont);

      Paragraph p;
    
      try
      {
        // step 1: creation of a document-object
        document = new Document(PageSize.A4, 50, 50, 50, 50);

        // step 2:
        // we create a writer that listens to the document
        // and directs a RTF-stream to a file

        RtfWriter2 rw2 = RtfWriter2.getInstance(document, outStream);

        // //////////////////////////////////////////////////////////
        // header and footer mus be added
        // after RtfWriter2.getInstance()
        // 
/////////////////////////////////////////////////////////////////
        // * Create different headers for the title page and all following
        // * pages
        //

        Table footerTable = new Table(3);
        footerTable.setBorderColor(new Color(255, 255, 255));
        footerTable.setDefaultCellBorderColor(new Color(255, 255, 255));

        footerTable.setWidth(100);
        footerTable.setAlignment("LEFT");
        footerTable.setWidths(new int[] { 34, 32, 34 });

        ph = new Phrase(name_ss[0].trim(), plainFont10);
        cel = new Cell(ph);
        cel.setHorizontalAlignment("LEFT");

        footerTable.addCell(cel);

        ph = new Phrase(emp.getEMPLID(), plainFont10); // date
        cel = new Cell(ph);
        cel.setHorizontalAlignment("CENTER");

        footerTable.addCell(cel);

        cel = new Cell();
        cel.setHorizontalAlignment("RIGHT");
        cel.add(new RtfPageNumber());
        footerTable.addCell(cel);

        RtfHeaderFooter footer_table = new RtfHeaderFooter(footerTable);
        document.setFooter(footer_table);

        /*
          * Create different headers for the title page and all 
following pages
          */
        rw2.setMargins(MARGIN_LEFT, MARGIN_RIGHT, MARGIN_TOP, 
MARGIN_BOTTOM);

        // step 3: we open the document
        document.open();

        document.add(new RtfPageNumber());
        // step 4: we add a paragraph to the document

        if (name_ss != null)
        {
            for (i = 0; i < name_ss.length; i++)
            {
              p = new Paragraph(name_ss[i].trim(), plainFont);
              p.setAlignment("CENTER");
              document.add(p);
            }
        }
        
        if (ss != null)
        {
            for (i = 0; i < ss.length; i++)
            {
              p = new Paragraph(ss[i], plainFont);
              p.setAlignment("CENTER");
              document.add(p);
            }
        }

        // //////////////////////////////////////////////////
        for (i = 0; i < 2; i++)
        {
            document.add(newline_p);
        }

        // //////////////////////////////////////////////////

        Table t = new Table(2, 14 * 2);

        // t.setBorder(Rectangle.NO_BORDER);
        // t.setDefaultCellBorder(Rectangle.NO_BORDER);

        t.setBorderColor(new Color(255, 255, 255));
        t.setDefaultCellBorderColor(new Color(255, 255, 255));

        t.setWidth(100);
        t.setAlignment("LEFT");
        t.setWidths(new int[] { 90, 10 });

        Cell cl;
        for (i = 1; i <= 14; i++)
        {
            ph = new Phrase(table_contents[i], boldFont);
            cl = new Cell(ph);
            t.addCell(cl);

            cl = new Cell("Page");
            t.addCell(cl);

            cl = new Cell(newline_p);
            cl.setColspan(2);
            t.addCell(cl);
        }
        document.add(t);

        // //////////////////////////////////////////////////
        // next page
        document.newPage();
        
......

-Henry

Howard Shank wrote:
> Henry,
>
> Are you opening the RTF file with MS Office 2003 or some other reader 
> application?
> Are you attempting to open the "text" of the RTF using a text editor?
>
> What are the "First few line:" of your code?
>
> Regards,
>
> Howard
>
> ----- Original Message ----
> From: Henry Lu <[EMAIL PROTECTED]>
> To: Post all your questions about iText here 
> <[email protected]>
> Sent: Thursday, February 14, 2008 10:04:44 AM
> Subject: [iText-questions] rtf - strange character at the beginning
>
> There is a strange/special/unexpected character at the very beginning of 
> my rtf file if i have following code after first few line:
>
>
>        Table t1 = new Table(2, (table_contents.length-1) * 2);
>
>        // t.setBorder(Rectangle.NO_BORDER);
>        // t.setDefaultCellBorder(Rectangle.NO_BORDER);
>
>        t1.setBorderColor(new Color(255, 255, 255));
>        t1.setDefaultCellBorderColor(new Color(255, 255, 255));
>
>        t1.setWidth(100);
>        t1.setAlignment("LEFT");
>        t1.setWidths(new int[] { 90, 10 });
>
>      Chunk    chnk;
> //        Cell cl;
>        for (i = 1; i < table_contents.length; i++)
>        {
>            chnk = new Chunk(table_contents[i], boldFont);
>            cl = new Cell(chnk);
>            t1.addCell(cl);
>
>            cl = new Cell("Page");
>            t1.addCell(cl);
>
>            cl = new Cell(newline_p);
>            cl.setColspan(2);
>            t1.addCell(cl);
>        }
>
>        document.add(t1);
>
> Could someone help me out?
>
> -Henry
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> iText-questions mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
> Buy the iText book: http://itext.ugent.be/itext-in-action/
>
>
>      
> ____________________________________________________________________________________
> Looking for last minute shopping deals?  
> Find them fast with Yahoo! Search.  
> http://tools.search.yahoo.com/newsearch/category.php?category=shopping
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> iText-questions mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
> Buy the iText book: http://itext.ugent.be/itext-in-action/
>
>
>  

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/


      
____________________________________________________________________________________
Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  
http://tools.search.yahoo.com/newsearch/category.php?category=shopping


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to