my code is this 

package pdfaplication;

/**
 *
/*
 * HelloWorld.java
 *
 * Created on September 11, 20012, 2:45 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

/**
 *
 * @author rathit
 */
/*
 * $Id: HelloWorld.java 2365 2006-09-14 22:52:48Z xlv $
 * $Name$
 *
 * This code is part of the 'iText Tutorial'.
 * You can find the complete tutorial at the following address:
 * http://itextdocs.lowagie.com/tutorial/
 *
 * This code is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * [email protected]
 */

//package com.lowagie.examples.general;

import com.lowagie.text.Annotation;
import com.lowagie.text.Annotation;
import com.lowagie.text.Cell;
import com.lowagie.text.Chunk;
import com.lowagie.text.Element;
import com.lowagie.text.Font;
import com.lowagie.text.FontFactory;
import com.lowagie.text.HeaderFooter;
import com.lowagie.text.Image;
import com.lowagie.text.List;
import com.lowagie.text.ListItem;
import com.lowagie.text.PageSize;
import com.lowagie.text.Phrase;
import com.lowagie.text.Table;
import com.lowagie.text.pdf.PdfDictionary;
import com.lowagie.text.pdf.PdfPage;
import com.lowagie.text.pdf.PdfRectangle;
import com.sun.org.apache.bcel.internal.classfile.JavaClass;
import com.sun.rowset.internal.Row;
import java.awt.Color;
import java.io.BufferedReader;
import java.io.File;

import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import com.lowagie.text.Rectangle;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfWriter;
import java.net.URL;
import java.sql.Array;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Vector;

/**
 
 * 
 * @author blowagie
 */

public class RitesTestReport {

    String[] str = {"Rites" , "56 C.R Avenue","employee wise sales
report","easter publication pvt. ltd"};
    Vector v2=new Vector();
  public URL url;
    private Cell cell;

   
        public Vector  Demo(){
                
                System.out.println();
                System.out.println("Adding elements dynamically to the vector: 
");
 
                v2 = new Vector();
 
                for (int i = 0; i < str.length; i++){
                        v2.add(str[i]);
                }
 
                System.out.println(""  + v2);
                return v2;
        }
 
        /**
         * Generates a PDF file with the text 'Hello World'
         * 
         * @param args no arguments needed here
         */
        
        public void generatePDF(Vector headers, Vector footers,Vector
row_name1,Vector row_data1,Vector row_name2,Vector row_data2 ,String
barcode,String remarks,Vector note,String testreport,String case_no,Vector
typetest,String test_name,String logoprint_status){
           String headerconcatination="";
           String footersconcatination="";
            String image_file="";
           Image image_rites;
           String filename=test_name.replace('&','_')+"_"+barcode+".pdf";
          // String path="C://Program Files//Tomcat
5.5.1//webapps//RitesLtdReportGeneration//report//"+filename;
            String path=ReadPathFromFile()+filename;
           File ff=new File(path);
         // System.out.println("testing file name " + ff);
           SimpleDateFormat df=new SimpleDateFormat("dd-MM-yyyy");
            String today=df.format(new Date());
                System.out.println("Hello World" + ff);
               float leftside=30.01f;
                float bottom=30.01f;
                float top=80.01f;     
                float rightside=30.01f;
                // step 1: creation of a document-object
                Document document = new Document();
                 document.setMargins(leftside,rightside,top,bottom);
                document.setPageSize(PageSize.A4);
               
                 Cell cell=null;
                float m=1.11f;
                float n=1.0f;
                float kk=110.01f;     
                float f=141.1f;
               
                try {
                        // step 2:
                        // we create a writer that listens to the document
                        // and directs a PDF-stream to a file
                        PdfWriter.getInstance(document,
                                        new FileOutputStream(ff));
                        
                        
                        // step 3: we open the document
                        /* befopre open in the document we have to set
                         *header and footer like this
                         *document.setHeader(header); 
                         * document.setFooter(footer);
                         *document.open();
                         */
                        Table table2 = new Table(2);
                          table2.setPadding(1);
                      //  table.setSpacing(5);

                        table2.setBorderWidth(0);
                        table2.setWidth(kk);
                        table2.setBorderColor(new Color(0, 0, 0)); 
                         
                      
                       footers.add("Conclusion/Remarks:    "+remarks);
                       footers.add(" ");
                    
                for(int k=0;k<note.size();k++){
                 //Phrase p = new Phrase(note.elementAt(k).toString(),
FontFactory.getFont(FontFactory.HELVETICA, 8, Font.BOLDITALIC, new Color(0,
0, 0)));
                footers.add(note.elementAt(k).toString());
               
                }
               // Phrase as = new Phrase("AUTHORISED SIGNATURE",
FontFactory.getFont(FontFactory.HELVETICA, 10, Font.BOLDITALIC, new Color(0,
0, 0)));
                
                footers.add("                                                   
                                                           
AUTHORISED SIGNATURE");
               // Phrase asend = new Phrase("                                   
                                                                         
for RITES Laboratory", FontFactory.getFont(FontFactory.HELVETICA, 12,
Font.BOLDITALIC, new Color(0, 0, 0)));
                //asend.setAlignment("right");
               footers.add("                                                    
                                                             
for RITES Laboratory");
                        
                  if(logoprint_status.equals("yes"))
                    image_file="headerlogo.jpg";
               if(logoprint_status.equals("no"))
                    image_file="header.jpg"; 
               image_rites= Image.getInstance("C://Program Files//Apache
Software Foundation//Tomcat
5.5.1//webapps//RitesLtdReportGeneration//report//"+image_file);
              
               Chunk chunk = new Chunk(image_rites,30,-1);
                     
               HeaderFooter header = new  HeaderFooter(new
Phrase(chunk),false); 
                header.setBorder(0);                  
                        
                        
                for(int k=0;k < headers.size();k++){
                headerconcatination+=headers.elementAt(k).toString()+"\n";
                }
                  Phrase ph=new Phrase(headerconcatination);
                 // HeaderFooter header = new HeaderFooter(ph, false);
                  header.setAlignment(1);
                  for(int j=0;j< footers.size();j++){
                footersconcatination+=footers.elementAt(j).toString()+"\n";
                }
                  Phrase ph1=new Phrase( footersconcatination);
                  HeaderFooter footer = new HeaderFooter(ph1,true);
                  footer.setAlignment(3);
                  document.setHeader(header); 
                  document.setFooter(footer);
                  document.addAuthor("Mettle Technologies:Sudip Mondal");
                   document.open();
                  
     Font fon=new Font();
        
         //int tab_i=v_colname.size();   
        Table table = new Table(2);
     table.setPadding(1);
     //  table.setSpacing(5);

    table.setBorderWidth(1);
   table.setWidth(kk);
   table.setBorderColor(new Color(0, 0, 0));
   table.setPadding(0);
   table.setSpacing(0);
  
  Phrase ce = new Phrase("Ref./Order No/Case No"+case_no+"\n Date"+today,new
Font(Font.HELVETICA, 8, Font.BOLD, new Color(0, 0, 255)) );

  Phrase rptno = new Phrase("Test Report No:"+barcode+"\n Date \n Page
No",new Font(Font.HELVETICA, 8, Font.BOLD, new Color(0, 0, 0)) );
 Cell ref=new Cell(ce.toString().replace('[',' ').replace(']',' '));
 Cell rpt=new Cell(rptno.toString().replace('[',' ').replace(']',' '));
 ref.setBorder(0);
 rpt.setBorder(0);
table.addCell(ref);
table.addCell(rpt);
table.setAutoFillEmptyCells(true);

for(int i=0;i<row_name1.size();i++){
Phrase ce2 = new Phrase(row_name1.elementAt(i).toString()+" :
"+row_data1.elementAt(i).toString(),new Font(Font.HELVETICA, 8, Font.BOLD,
new Color(0, 0, 0)) );
Phrase ce3 = new Phrase(row_name2.elementAt(i).toString()+" :
"+row_data2.elementAt(i).toString(),new Font(Font.HELVETICA, 8, Font.BOLD,
new Color(0, 0,0)) );

Cell headerdataleft=new Cell(ce2.toString().replace('[',' ').replace(']','
'));
headerdataleft.setBorder(0);
table.addCell(headerdataleft);
Cell headerdataright=new Cell(ce3.toString().replace('[',' ').replace(']','
'));
headerdataright.setBorder(0);
table.addCell(headerdataright);
//table.addCell(ce3);

}
table.complete();
 Table tablemiddle = new Table(2);
      tablemiddle.setPadding(1);
     //  table.setSpacing(5);

     tablemiddle.setBorderWidth(0);
    tablemiddle.setWidth(kk);
  tablemiddle.setBorderColor(new Color(0, 0, 0));
Cell resob=new Cell("Result Obtained");
resob.setHorizontalAlignment(1);
resob.setBorder(0);
resob.setColspan(2);

 tablemiddle.addCell(resob);
  tablemiddle.complete();

Table tableresult = new Table(2);
      tableresult.setPadding(1);
     //  table.setSpacing(5);

     tableresult.setBorderWidth(1);
    tableresult.setWidth(kk);
  tableresult.setBorderColor(new Color(0, 0, 0));

 /*   for(int l=0;l<testreport.size();l++){
             Phrase cat = new Phrase(typetest.elementAt(l).toString(),new
Font(Font.HELVETICA, 9, Font.BOLD, new Color(0, 0, 0)) );   
             Cell type_ana=new Cell(cat);
            type_ana.setColspan(2);
            tableresult.addCell(type_ana);   
            Phrase test = new
Phrase(testreport.elementAt(l).toString().trim(),new Font(Font.HELVETICA, 9,
Font.BOLD, new Color(0, 0, 0)) );
             
            Cell result_tb=new Cell(test);
            result_tb.setColspan(2);
            tableresult.addCell(result_tb);
            tableresult.setTableFitsPage(true);   
        } */
//Paragraph test = new Paragraph(testreport.trim(),new Font(Font.HELVETICA,
9, Font.BOLD, new Color(0, 0, 0)));
  System.out.println(testreport);
   Phrase test = new Phrase(testreport.trim(),new Font(Font.HELVETICA, 9,
Font.BOLD, new Color(0, 0, 0)) );
   System.out.println("After phrase-----"); 
   System.out.println(test);  
            Cell result_tb=new Cell(testreport);
            result_tb.setColspan(2);
            tableresult.addCell(result_tb);
            tableresult.setTableFitsPage(true); 
  tableresult.setTableFitsPage(true);
  System.out.println("After cell....");
  System.out.println(tableresult);
 
document.add(tablemiddle);
document.add(tableresult);


if(test_name.equals("CHEM_SPECTRO"))
          RunPdf(filename);
                // step 4: we add a paragraph to the document                  
                        
                } catch (DocumentException de) {
                        System.err.println(de.getMessage());
                } catch (IOException ioe) {
                        System.err.println(ioe.getMessage());
                }

                // step 5: we close the document
            
                document.close();
        }
        
      public void  RunPdf(String f_name){
        try {
          //  String uu=us.toString();
            Runtime.getRuntime().exec("cmd /c start  iexplore
http://128.0.5.149:9999/RitesLtdReportGeneration/report/"+f_name+"";);
        } catch (IOException ex) {
            ex.printStackTrace();
        }
      }  
     
       private String ReadPathFromFile(){
      
        String path_name="";
        try{
          FileReader frpath=new FileReader("pdfsave.mettle");  
           BufferedReader br= new BufferedReader(frpath);
            String temp= br.readLine();
            if(temp!=null){
             path_name=temp.substring(temp.indexOf('>')+1,
temp.lastIndexOf('<')); 
            // System.out.println("test sudip"+path_name);
            }
        }catch(Exception e){
            e.printStackTrace();
        }
        return path_name;
    }
}

problem is aligment in not proper 
> my problem is when i add a string in pdf this not proper in 
> pdf file when i
> take format text from data base
> 
> 1                          Carbon                             
>      0.60                                   
> %                                       00000.589 
> 2                          Manganese                          
>      1.20                                   
> %                                       00000.603 
> 3                          Molybdenum                         
>      0.15                                   
> %                                       0000.0121 
> 4                          Phoshorus                          
>      0.040                                  
> %                                       0000.0746 
> 5                          Sulphur                            
>      0.035                                  
> %                                       0000.0649]
> 
> like that but not add proper plz give solution
> thax
> Sudip


Aviso Legal:

Esta mensagem é destinada exclusivamente ao destinatário. Pode conter
informação confidencial ou legalmente protegida. A incorrecta transmissão
desta mensagem não significa a perca de confidencialidade. Se esta mensagem
for recebida por engano, por favor envie-a de volta para o remetente e
apague-a do seu sistema de imediato. É proibido a qualquer pessoa que não o
destinatário de usar, revelar ou distribuir qualquer parte desta mensagem. 



Disclaimer:

This message is destined exclusively to the intended receiver. It may
contain confidential or legally protected information. The incorrect
transmission of this message does not mean the loss of its confidentiality.
If this message is received by mistake, please send it back to the sender
and delete it from your system immediately. It is forbidden to any person
who is not the intended receiver to use, distribute or copy any part of this
message.




-------------------------------------------------------------------------
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/



-- 
View this message in context: 
http://www.nabble.com/problem-in-pdf-tp14996105p14996884.html
Sent from the iText - General mailing list archive at Nabble.com.


-------------------------------------------------------------------------
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