Dear Sir

We've application that creates a report in text format.

from that text report i'm creating PDF copy of that.

But to my surprise it is not keeping same spacing & alignment as text format.

can you give me a solution for that ?

below is my present working - code

regards 

vishal r shah

---------------------------------------------------------------------------------------

public void convert(String pdfDoc,String txtDoc) throws Exception
 {
  this.pdfDoc=pdfDoc;//+".pdf";
  this.txtDoc=txtDoc;//+".txt";
  Document document = new Document(PageSize.A4, 50, 50, 50, 50);
  //try {
  System.out.println("In convert...");
  // creation of the different writers
  //HtmlWriter.getInstance(document, System.out);
  PdfWriter.getInstance(document, new FileOutputStream(this.pdfDoc));
  System.out.println("pdf object ...");
  // we add some meta information to the document
  document.addAuthor("vishal r shah");
  document.addSubject("Report");

  // we define a header and a footer
  HeaderFooter header = new HeaderFooter(new Phrase("This is a
header."), false);
  HeaderFooter footer = new HeaderFooter(new Phrase("This is page "),
new Phrase("."));
  footer.setAlignment(Element.ALIGN_CENTER);
  document.setHeader(header);
  document.setFooter(footer);
  
  //document.marginMirroring=true;
  // we open the document for writing
  document.open();
  System.out.println("header footer created...");
  BufferedReader br = new BufferedReader(new FileReader(this.txtDoc));
  String strLine="";
  while((strLine=br.readLine()) != null)
  {
   document.add(new Paragraph(strLine));
   //System.out.println("Read Line : "+(i+1));
  }
  System.out.println("going to close...");
  br.close();
  document.close();
  System.out.println("pdf created...");
   //}catch(Exception e) {System.err.println(e.getMessage());}
   
 }

-- 
Regards,

Vishal R Shah
Senior Software Engineer,
Starnet Software (I) Ltd.


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to