Hi List, 

We have a program called PDFFileCreator.java that generates dynamic PDF
files. 

The way we're doing it right now is we design a source PDF (let's call
it blank_order.pdf) using adobe acrobat 5. 
Upon running the PDFFileCreator.java it would then connect to the
database, retrieves the values and displays those values in our PDF
using our source PDF (blank_order.pdf) which would give us the filled up
pdf (let's call it filled_order.pdf). We view our filled_order.pdf using
Acrobat 5 or Adobe Reader 9. Eveything works well until we had a
requirement to display the barcodes. 


here's a snippet of our current codes: 




//======================================================= 

BaseFont bf = BaseFont.createFont(BaseFont.COURIER , BaseFont.CP1252,
BaseFont.NOT_EMBEDDED); 
PdfReader reader = new PdfReader("blank_order.pdf"); 
PdfStamper stamp = new PdfStamper(reader, new
FileOutputStream("filled_order.pdf")); 
AcroFields form1 = stamp.getAcroFields(); 


//we loop through a resultset and this is what happens on each columns 
  form1.setFieldProperty ("NAME", "textfont", bf, null); 
  form1.regenerateField("NAME"); 
  form1.setField("NAME", "Uncle Sam"); 


  form1.setFieldProperty ("BARCODE", "textfont", bf, null);//is there
  Basefont in itext for barcodes? 
  form1.regenerateField("BARCODE"); 
  form1.setField("BARCODE", "29b5"); 
//end 

stamp.setFormFlattening(false); 
stamp.close(); 

//======================================================= 



i have read in this forum to set this: 

        stamp.setFormFlattening(false); 
        

But is that the only thing i have to do? because i tried the above but
what gets displayed is still the "29b5" and not the barcode equivalent. 
Also, i'm curious if there's a Basefont for barcodes? I'm guessing the
reason why the form1.setField("BARCODE", "29b5"); is displaying as
"29b5" is because the Basefont is set to courier and not to a
barcode-specific font. I don't know, I'm really just guessing. 


Now, I also have tried this: 


        Rectangle pagesize = new Rectangle(612, 792); 
        pagesize.setBackgroundColor(new Color(0x64, 0x95, 0xed)); 
        Document document = new Document(pagesize); 
        PdfWriter writer = PdfWriter.getInstance(document, new
        FileOutputStream("BarcodePDF.pdf")); 
        
        document.open(); 
        
        PdfContentByte cb = writer.getDirectContent(); 
        BarcodeEAN codeEAN = new BarcodeEAN(); 
        codeEAN.setCode("0000020099002"); 
        Paragraph p = new Paragraph(); 
        p.add(new Chunk(codeEAN.createImageWithBarcode(cb, null, null),
        0, -5)); 
        codeEAN.setGuardBars(true); 
        p.setLeading(codeEAN.getBarcodeSize().height()); 
        
        document.add(p); 
        document.close(); 


This works excellent but im just wondering if there's a way i could
write the "p" in the filled_order.pdf along with all my other database
values instead of creating a new document and calling the
document.add(p); 



Thanks in advance for enlightening me. 


- k 
-- 
  keesha
  [email protected]

-- 
http://www.fastmail.fm - Or how I learned to stop worrying and
                          love email again


------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to