Hi All!
I have a problem specifying Troy secure font in Itext without registering it.
Font is loaded in the printer and from the java code I need to send font
information along with the text without loading the font that I want to print.
Since the font is not loaded in the pc, pdf will have some secure code and once
that goes to the printer it prints the correct information. Please let me know
how to achieve this.
Program looks like this:
package com.ezcorp.ezsystem.reports;
import java.awt.print.PrinterException;
import com.ezcorp.ezsystem.reports.formatter.PrintPdf;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.pdf.BaseFont;
import com.itextpdf.text.pdf.PdfContentByte;
import com.itextpdf.text.pdf.PdfWriter;
import com.lowagie.text.Font;
import com.lowagie.text.FontFactory;
import com.lowagie.text.Paragraph;
public class TestingPDF {
/** The resulting PDF. */
ByteArrayOutputStream baos = null;
/**
* Creates a PDF document.
* @param filename the path to the new PDF document
* @throws DocumentException
* @throws IOException
* @throws PrinterException
*/
public void createPdf() throws IOException, DocumentException,
PrinterException {
// step 1
Document document = new Document();
this.baos = new ByteArrayOutputStream();
// step 2
PdfWriter writer = PdfWriter.getInstance(document, this.baos);
// step 3
document.open();
PdfContentByte pdfContentByte = writer.getDirectContent();
BaseFont bf = BaseFont.createFont();
pdfContentByte.beginText() ;
pdfContentByte.setFontAndSize(bf, 9);
BaseFont micrFont= null;
try{
micrFont = BaseFont.createFont("secure Font",BaseFont.SYMBOL,
BaseFont.NOT_EMBEDDED,false);
(tried below code too)
// micrFont = BaseFont.createFont();
// micrFont.setDirectTextToByte(true);
// micrFont.setPostscriptFontName("secure Font");
}
catch(Exception e){
e.printStackTrace();
}
pdfContentByte.setFontAndSize(micrFont, 14);
pdfContentByte.setTextMatrix(100, 100) ;
pdfContentByte.showText("secure Text here");
pdfContentByte.endText() ;
document.close();
byte[] bytes = this.baos.toByteArray();
writer.close();
PrintPdf printPdf = new PrintPdf(bytes, "testing testing");
printPdf.print();
}
/**
* @param args
* @throws PrinterException
*/
public static void main(String[] args)throws IOException,
DocumentException, PrinterException {
new TestingPDF().createPdf();
}
}
Need help badly
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php