Package com

Source Code of com.smi

package com;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.util.Iterator;
import java.util.List;

import javax.ws.rs.*;
import javax.ws.rs.core.Response;

import com.itextpdf.text.Document;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;

@Path("helloworld")
public class smi
{
  @GET
  @Produces("application/pdf")
  public Response getmessage(@QueryParam("json") String s)
  {
    int i =0;
    //SessionFactory f=new Configuration().configure().buildSessionFactory();
    //Session s=f.openSession();
    System.out.println(s);
    System.out.println("welcome parthesh");
       
    String st = s;
      String[] temp;
    
    
      String delimiter = ",";
    
      temp = st.split(delimiter);
       for( ; i < temp.length; i++)
       {
        System.out.println(temp[i])
       }
   
   
      
      
    Document doc=new Document();
    ByteArrayOutputStream ba=new ByteArrayOutputStream();
    try {
      //ManyToOne mo=new ManyToOne();
      //process s1;
      List<process> list=main.viewRecord(temp);
     
      System.out.println(list.size());
     
      PdfWriter.getInstance(doc, ba);
      doc.open();
      PdfPTable table=new PdfPTable(i);
      Iterator it =list.iterator();
            while(it.hasNext())
            {
              Object o[]=(Object [])it.next();
             
              //                   System.out.println(o[0] + "==" + o[1]);
                 
               //  String str=(String) it.next();
                 for(int j=0; j<i; j++ )
                 {
                   System.out.println(o[j]);
                  
        //table.addCell(o[j]);//String.valueOf(list.get(i).getProcessName()));
        table.addCell(String.valueOf(o[j]));
       
      }}
            System.out.println("loop complate");
      doc.add(table);
      System.out.println("add table complate");
     
      doc.close();
      System.out.println("document complate");
     
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
   
    ByteArrayInputStream byteArray=new ByteArrayInputStream(ba.toByteArray());
    System.out.println("bytearray");
   
    return  Response.ok().entity(byteArray).header("Content-Disposition","attachment; filename=hello.pdf").type("application/pdf").build();

   
    //return "ok";
   
  }
 
 
 
 
}

TOP

Related Classes of com.smi

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.