forked from Coded/SIPRP
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
525 lines
19 KiB
525 lines
19 KiB
package siprp.ficha;
|
|
|
|
import java.awt.Color;
|
|
import java.io.ByteArrayOutputStream;
|
|
import java.io.File;
|
|
import java.io.FileNotFoundException;
|
|
import java.io.FileOutputStream;
|
|
import java.io.IOException;
|
|
import java.util.HashMap;
|
|
|
|
import siprp.SingletonConstants;
|
|
|
|
import com.evolute.utils.Singleton;
|
|
import com.lowagie.text.Cell;
|
|
import com.lowagie.text.Chunk;
|
|
import com.lowagie.text.Document;
|
|
import com.lowagie.text.Element;
|
|
import com.lowagie.text.Font;
|
|
import com.lowagie.text.FontFactory;
|
|
import com.lowagie.text.PageSize;
|
|
import com.lowagie.text.Paragraph;
|
|
import com.lowagie.text.Phrase;
|
|
import com.lowagie.text.Table;
|
|
import com.lowagie.text.pdf.BaseFont;
|
|
import com.lowagie.text.pdf.PdfWriter;
|
|
|
|
public class ExamePDF implements FichaAptidaoConstants
|
|
{
|
|
private final Font FONT_BOLD = FontFactory.getFont( "Arial", 8, Font.BOLD );
|
|
private final Font FONT_NORMAL = FontFactory.getFont( "Arial", 8, Font.NORMAL );
|
|
private final Font FONT_ZAPFDINGBATS = new Font( Font.ZAPFDINGBATS , 12, Font.NORMAL, new Color( 0, 0, 0 ) );
|
|
|
|
private BaseFont BASE_WINGDINGS;
|
|
private Font FONT_WINGDINGS;
|
|
|
|
// static
|
|
// {
|
|
// try
|
|
// {
|
|
// //BASE_WINGDINGS = BaseFont.createFont("C:\\WINNT\\Fonts\\WINGDING.TTF", BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
|
|
// BASE_WINGDINGS = BaseFont.createFont("WingDings", BaseFont.CP1252, BaseFont.EMBEDDED);
|
|
// InputStream stream = BaseFont.getResourceStream( "WING", ClassLoader loader)
|
|
// BASE_WINGDINGS = BaseFont.createFont("WingDings", BaseFont.CP1252, BaseFont.EMBEDDED,
|
|
// true, byte[] ttfAfm, null );
|
|
// FONT_WINGDINGS = new Font(BASE_WINGDINGS, 12);
|
|
// }
|
|
// catch( Exception ex )
|
|
// {
|
|
// FONT_WINGDINGS = FONT_NORMAL;
|
|
// System.out.println( "NO FONT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" );
|
|
// }
|
|
// }
|
|
|
|
public ExamePDF()
|
|
{
|
|
FontFactory.registerDirectories();
|
|
String possibleNames[] = new String[]{ "Wingdings", "WingDings", "wingdings", "WINGDINGS" };
|
|
|
|
for( int n = 0; n < 4; n++ )
|
|
{
|
|
FONT_WINGDINGS = FontFactory.getFont( possibleNames[ n ] );
|
|
if( FONT_WINGDINGS.getFamilyname().toLowerCase().equals( "wingdings" ) )
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
public static void main( String[] args )
|
|
{
|
|
try
|
|
{
|
|
HashMap<String,String> ht = new HashMap<String,String>();
|
|
// designacao_social
|
|
// estabelecimentos.nome
|
|
// estabelecimentos.localidade
|
|
// servico_saude_tipo_interno
|
|
// servico_saude_tipo_interempresas
|
|
// servico_saude_tipo_externo
|
|
// servico_saude_tipo_sns
|
|
// servico_saude_designacao
|
|
// servico_higiene_tipo_interno
|
|
// servico_higiene_tipo_interempresas
|
|
// servico_higiene_tipo_externo
|
|
// servico_higiene_outro
|
|
// servico_higiene_designacao
|
|
// trabalhadores.nome
|
|
// sexo
|
|
// data_nascimento
|
|
// nacionalidade
|
|
// numero_mecanografico
|
|
// data_admissao
|
|
// categoria
|
|
// local_trabalho
|
|
// funcao_proposta
|
|
// data_admissao_funcao
|
|
// observacoes
|
|
// exames.data
|
|
// tipo_admissao
|
|
// tipo_periodico
|
|
// tipo_ocasional
|
|
// tipo_apos_doenca
|
|
// tipo_apos_acidente
|
|
// tipo_pedido_trabalhador
|
|
// tipo_pedido_empresa
|
|
// tipo_mudanca_funcao
|
|
// tipo_trabalho
|
|
// tipo_outro
|
|
// resultado_apto
|
|
// resultado_apto_condicionalmente
|
|
// resultado_inapto_temp
|
|
// resultado_inapto_def
|
|
// outra_funcao_1
|
|
// outra_funcao_2
|
|
// outra_funcao_3
|
|
// outra_funcao_4
|
|
// proximo_exame
|
|
// outras_recomendacoes
|
|
// medicos.nome
|
|
// numero_cedula
|
|
|
|
ht.put( TRABALHADORES_NOME, "Trabalhador do com\u00e9rcio" );
|
|
ht.put( SERVICO_SAUDE_DESIGNACAO, "Designacao servico saude" );
|
|
ht.put( SERVICO_SAUDE_TIPO_EXTERNO, "" + Boolean.TRUE );
|
|
ht.put( TIPO_PERIODICO, "" + Boolean.TRUE );
|
|
ht.put( RESULTADO_INAPTO_TEMP, "" + Boolean.TRUE );
|
|
FileOutputStream fos = new FileOutputStream( System.getProperty( "user.home" ) + "\\report.pdf" );
|
|
fos.write( new ExamePDF().createPDF( ht ) );
|
|
fos.close();
|
|
System.out.println( "File saved." );
|
|
Process proc = Runtime.getRuntime().exec( "cmd.exe /c \"" + System.getProperty( "user.home" ) + "\\report.pdf\"" );
|
|
proc.waitFor();
|
|
new File( System.getProperty( "user.home" ) + "\\report.pdf" ).delete();
|
|
System.out.println( "Done." );
|
|
}
|
|
catch( Exception e )
|
|
{
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
public void print( byte []pdf, String nome )
|
|
throws Exception
|
|
{
|
|
// new PDFFilePrinter( pdf, false );
|
|
|
|
// if( true )
|
|
// {
|
|
// return;
|
|
// }
|
|
|
|
long time = System.currentTimeMillis();
|
|
// FileOutputStream fos = new FileOutputStream( System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + "report_ficha" + time + ".pdf" );
|
|
FileOutputStream fos = new FileOutputStream( System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + nome + "_" + time + ".pdf" );
|
|
fos.write( pdf );
|
|
fos.close();
|
|
System.out.println( "File saved ( " + nome + "_" + time + " )." );
|
|
Process proc;
|
|
if( System.getProperty( "os.name" ).startsWith( "Windows" ) )
|
|
{
|
|
//System.out.println( "cmd.exe /c \"" + System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + "report_ficha.pdf\"" );
|
|
// proc = Runtime.getRuntime().exec( "cmd.exe /c \"" + System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + nome + "_" + time + ".pdf\"" );
|
|
|
|
proc = Runtime.getRuntime().exec( new String[]{ System.getProperty( "user.home" ) + "\\open.bat", "c:\\temp\\" + nome + "_" + time + ".pdf" });
|
|
|
|
|
|
proc.waitFor();
|
|
if( !new File( System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + nome + "_" + time + ".pdf" ).delete() )
|
|
{
|
|
System.err.println( "File: report_ficha" + time + ".pdf - NOT DELETED" );
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//System.out.println( "/usr/bin/open \"" + System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + "report_ficha.pdf\"" );
|
|
try{
|
|
proc = Runtime.getRuntime().exec( new String[]{"/usr/bin/open", "" + System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + nome + "_" + time + ".pdf" } );
|
|
}
|
|
catch( Exception ex )
|
|
{
|
|
ex.printStackTrace();
|
|
}
|
|
// proc = Runtime.getRuntime().exec( "/usr/bin/open \"/Users/Shared/teste.pdf.pdf\"" );
|
|
}
|
|
}
|
|
|
|
public void printSilent( byte []pdf, String nome, String printerName ) throws InterruptedException, IOException
|
|
// throws Exception
|
|
{
|
|
long time = System.currentTimeMillis();
|
|
// FileOutputStream fos = new FileOutputStream( System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + "report_ficha" + time + ".pdf" );
|
|
|
|
if( System.getProperty( "os.name" ).startsWith( "Windows" ) )
|
|
{
|
|
Process proc;
|
|
|
|
// FileOutputStream fos = new FileOutputStream( System.getProperty( "user.home" ) + "\\print_fichas_temp\\" + nome + "_" + time + ".pdf" );
|
|
FileOutputStream fos = new FileOutputStream( "c:\\temp\\" + nome + "_" + time + ".pdf" );
|
|
fos.write( pdf );
|
|
fos.close();
|
|
|
|
System.out.println( "File saved ( " + nome + "_" + time + " )." );
|
|
//System.out.println("cmd /c \"c:\\temp\\acrord32.lnk /t \"c:" + System.getProperty( "file.separator" ) + "temp" + System.getProperty( "file.separator" ) + nome + "_" + time + ".pdf\" \"" + printerName + "\"\"");
|
|
// proc = Runtime.getRuntime().exec( new String[]{ System.getProperty( "user.home" ) + "\\print.bat",
|
|
// System.getProperty( "user.home" ) + "\\print_fichas_temp\\" + nome + "_" + time + ".pdf",
|
|
// printerName });
|
|
proc = Runtime.getRuntime().exec( new String[]{ System.getProperty( "user.home" ) + "\\print.bat",
|
|
"c:\\temp\\" + nome + "_" + time + ".pdf",
|
|
printerName });
|
|
proc.waitFor();
|
|
// if( !new File( "c:\\temp\\" + nome + "_" + time + ".pdf" ).delete() )
|
|
// {
|
|
// System.err.println( "File: " + nome + "_" + ".pdf - NOT DELETED" );
|
|
// }
|
|
}
|
|
|
|
}
|
|
|
|
public void cleanSilentPrint()
|
|
throws Exception
|
|
{
|
|
Process proc;
|
|
proc = Runtime.getRuntime().exec( "cmd /c \"del c:\\temp\\*.pdf\"" );
|
|
proc.waitFor();
|
|
}
|
|
|
|
public byte[] createPDF( HashMap<String,String> values )
|
|
{
|
|
Document document = new Document();
|
|
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
|
|
|
document.setPageSize( PageSize.A4 );
|
|
try {
|
|
PdfWriter pdfw = PdfWriter.getInstance( document, bos );
|
|
// try {
|
|
|
|
|
|
document.addTitle( "Ficha de Aptid\u00e3o" );
|
|
String acronym = (String) Singleton.getInstance( SingletonConstants.COMPANY_ACRONYM );
|
|
document.addAuthor( acronym != null ? acronym: "n/a" );
|
|
document.addCreator( "Evolute" );
|
|
|
|
document.open();
|
|
|
|
Paragraph conteudo = new Paragraph();
|
|
|
|
conteudo.add( new Chunk( "\n\nFICHA DE APTID\u00c3O\n",
|
|
FontFactory.getFont( "Arial", 10, Font.BOLD ) ) );
|
|
conteudo.add( new Chunk( "(Portaria n.\u00ba 299/2007, de 16 de Mar\u00e7o)",
|
|
// conteudo.add( new Chunk( "(Portaria n\u00ba1031/2002, de 10 de Agosto)",
|
|
FontFactory.getFont( "Arial", 7, Font.BOLD ) ) );
|
|
|
|
conteudo.setAlignment( Element.ALIGN_CENTER );
|
|
|
|
document.add( conteudo );
|
|
|
|
Table table = new Table( 1 );
|
|
table.setBorderWidth( 1 );
|
|
table.setPadding( 5 );
|
|
table.setOffset( 0 );
|
|
table.setWidth( 100 );
|
|
|
|
table.addCell( new Phrase( "Empresa/Entidade", FONT_BOLD ) );
|
|
|
|
StringBuilder texto = new StringBuilder();
|
|
Phrase ph = new Phrase( 12f );
|
|
|
|
Cell cell = new Cell();
|
|
texto.append( "DESIGNA\u00c7\u00c3O SOCIAL: " + values.get( DESIGNACAO_SOCIAL ) + "\n" );
|
|
texto.append( "ESTABELECIMENTO: " + values.get( ESTABELECIMENTOS_NOME )
|
|
+ " LOCALIDADE: " + values.get( ESTABELECIMENTOS_LOCALIDADE ) + "\n" );
|
|
texto.append( "SERVI\u00c7O DE SA\u00DaDE: Tipo " );
|
|
ph.add( new Chunk( texto.toString(), FONT_NORMAL ) );
|
|
|
|
texto = new StringBuilder( "Interno" );
|
|
ph.add( doCheckedPhrase( texto.toString(), values.get( SERVICO_SAUDE_TIPO_INTERNO ) ) );
|
|
|
|
texto = new StringBuilder( "Interempresas" );
|
|
ph.add( doCheckedPhrase( texto.toString(), values.get( SERVICO_SAUDE_TIPO_INTEREMPRESAS ), true ) );
|
|
|
|
texto = new StringBuilder( "Externo" );
|
|
ph.add( doCheckedPhrase( texto.toString(), values.get( SERVICO_SAUDE_TIPO_EXTERNO ), true ) );
|
|
|
|
texto = new StringBuilder( "Servi\u00e7o Nacional de Sa\u00fade\n" );
|
|
ph.add( doCheckedPhrase( texto.toString(), values.get( SERVICO_SAUDE_TIPO_SNS ), true ) );
|
|
|
|
texto = new StringBuilder();
|
|
|
|
texto.append( "DESIGNA\u00c7\u00c3O: " + values.get( SERVICO_SAUDE_DESIGNACAO ) + "\n" );
|
|
texto.append( "SERVI\u00c7O DE HIGIENE E SEGURAN\u00c7A: Tipo " );
|
|
ph.add( new Chunk( texto.toString(), FONT_NORMAL ) );
|
|
|
|
texto = new StringBuilder( "Interno" );
|
|
ph.add( doCheckedPhrase( texto.toString(), values.get( SERVICO_HIGIENE_TIPO_INTERNO ) ) );
|
|
|
|
texto = new StringBuilder( "Interempresas" );
|
|
ph.add( doCheckedPhrase( texto.toString(), values.get( SERVICO_HIGIENE_TIPO_INTEREMPRESAS ), true ) );
|
|
|
|
texto = new StringBuilder( "Externo" );
|
|
ph.add( doCheckedPhrase( texto.toString(), values.get( SERVICO_HIGIENE_TIPO_EXTERNO ), true ) );
|
|
|
|
texto = new StringBuilder( "Outro\n" );
|
|
ph.add( doCheckedPhrase( texto.toString(), values.get( SERVICO_HIGIENE_TIPO_OUTRO ), true ) );
|
|
|
|
texto = new StringBuilder();
|
|
|
|
texto.append( "DESIGNA\u00c7\u00c3O: " + values.get( SERVICO_HIGIENE_DESIGNACAO ) + "" );
|
|
|
|
ph.add( new Chunk( texto.toString(), FONT_NORMAL ) );
|
|
|
|
cell.addElement( ph );
|
|
table.addCell( cell );
|
|
document.add( table );
|
|
|
|
table = new Table( 1 );
|
|
table.setBorderWidth( 1 );
|
|
table.setPadding( 5 );
|
|
table.setOffset( 0 );
|
|
table.setWidth( 100 );
|
|
|
|
table.addCell( new Phrase( "Trabalhador",
|
|
FONT_BOLD ) );
|
|
|
|
texto = new StringBuilder();
|
|
|
|
texto.append( "NOME: " + values.get( TRABALHADORES_NOME ) + "\n" );
|
|
texto.append( "SEXO: " + values.get( SEXO ) + " DATA DE NASCIMENTO: "
|
|
+ values.get( DATA_NASCIMENTO ) + " NACIONALIDADE: "
|
|
+ values.get( NACIONALIDADE ) + "\n" );
|
|
texto.append( "N\u00daMERO MECANOGR\u00c1FICO/OUTRO: " + values.get( NUMERO_MECANOGRAFICO )
|
|
+ " DATA DE ADMISS\u00c3O: " + values.get( DATA_ADMISSAO ) + "\n" );
|
|
texto.append( "CATEGORIA PROFISSIONAL: " + values.get( CATEGORIA )
|
|
+ " LOCAL DE TRABALHO: " + values.get( LOCAL_TRABALHO ) + "\n" );
|
|
texto.append( "FUN\u00c7\u00c3O PROPOSTA: " + values.get( FUNCAO_PROPOSTA )
|
|
+ " DATA DE ADMISS\u00c3O NA FUN\u00c7\u00c3O: "
|
|
+ values.get( DATA_ADMISSAO_FUNCAO ) + "" );
|
|
|
|
table.addCell( new Phrase( 12f, texto.toString(), FONT_NORMAL ) );
|
|
document.add( table );
|
|
|
|
table = new Table( 1 );
|
|
table.setBorderWidth( 1 );
|
|
table.setOffset( 0 );
|
|
table.setPadding( 5 );
|
|
table.setWidth( 100 );
|
|
|
|
table.addCell( new Phrase( "Observa\u00e7\u00f5es",
|
|
FONT_BOLD ) );
|
|
|
|
texto = new StringBuilder();
|
|
texto.append( values.get( OBSERVACOES ) );
|
|
|
|
table.addCell( new Phrase( 12f, texto.toString(), FONT_NORMAL ) );
|
|
document.add( table );
|
|
|
|
table = new Table( 2 );
|
|
table.setBorderWidth( 1 );
|
|
table.setOffset( 0 );
|
|
table.setPadding( 5 );
|
|
table.setWidth( 100 );
|
|
|
|
cell = new Cell( new Phrase( "Exame M\u00e9dico",
|
|
FONT_BOLD ) );
|
|
|
|
cell.setColspan( 2 );
|
|
table.addCell( cell );
|
|
|
|
texto = new StringBuilder();
|
|
ph = new Phrase( 12f );
|
|
texto.append( "DATA DO EXAME: " + values.get( EXAMES_DATA ) + "\n" );
|
|
texto.append( "TIPO\n" );
|
|
ph.add( new Chunk( texto.toString(), FONT_NORMAL ) );
|
|
|
|
ph.add( doCheckedPhrase( "ADMISS\u00c3O\n", values.get( TIPO_ADMISSAO ) ) );
|
|
|
|
ph.add( doCheckedPhrase( "PERI\u00d3DICO\n", values.get( TIPO_PERIODICO ) ) );
|
|
|
|
ph.add( doCheckedPhrase( "OCASIONAL\n", values.get( TIPO_OCASIONAL ) ) );
|
|
|
|
ph.add( doCheckedPhrase( "AP\u00d3S DOEN\u00c7A\n", values.get( TIPO_APOS_DOENCA ), true ) );
|
|
|
|
ph.add( doCheckedPhrase( "AP\u00d3S ACIDENTE\n", values.get( TIPO_APOS_ACIDENTE ), true ) );
|
|
|
|
ph.add( doCheckedPhrase( "A PEDIDO DO TRABALHADOR\n", values.get( TIPO_PEDIDO_TRABALHADOR ), true ) );
|
|
|
|
ph.add( doCheckedPhrase( "A PEDIDO DO SERVI\u00c7O\n", values.get( TIPO_PEDIDO_EMPRESA ), true ) );
|
|
|
|
ph.add( doCheckedPhrase( "POR MUDAN\u00c7A DE FUN\u00c7\u00c3O\n", values.get( TIPO_MUDANCA_FUNCAO ), true ) );
|
|
|
|
ph.add( doCheckedPhrase( "POR ALTERA\u00c7\u00c3O DAS CONDI\u00c7\u00d5ES DE TRABALHO\n", values.get( TIPO_TRABALHO ), true ) );
|
|
|
|
ph.add( doCheckedPhrase( "OUTRO\n", values.get( TIPO_OUTRO ), true ) );
|
|
|
|
texto = new StringBuilder();
|
|
texto.append( " ESPECIFIQUE: " + values.get( TIPO_OUTRO_TEXTO ) );
|
|
|
|
ph.add( new Chunk( texto.toString(), FONT_NORMAL ) );
|
|
|
|
table.addCell( ph );
|
|
|
|
ph = new Phrase( 12f );
|
|
ph.add( new Chunk( "RESULTADO\n", FONT_NORMAL ) );
|
|
ph.add( doCheckedPhrase( "APTO\n", values.get( RESULTADO_APTO ) ) );
|
|
|
|
ph.add( doCheckedPhrase( "APTO CONDICIONALMENTE\n\n", values.get( RESULTADO_APTO_CONDICIONALMENTE ) ) );
|
|
|
|
ph.add( doCheckedPhrase( "INAPTO TEMPORARIAMENTE\n", values.get( RESULTADO_INAPTO_TEMP ) ) );
|
|
|
|
ph.add( doCheckedPhrase( "INAPTO DEFINITIVAMENTE\n\n", values.get( RESULTADO_INAPTO_DEF ) ) );
|
|
|
|
texto = new StringBuilder();
|
|
texto.append( "OUTRAS FUN\u00c7\u00d5ES QUE PODE DESEMPENHAR\n" );
|
|
texto.append( " 1 " + values.get( OUTRA_FUNCAO_1 ) + "\n" );
|
|
texto.append( " 2 " + values.get( OUTRA_FUNCAO_2 ) + "\n" );
|
|
texto.append( " 3 " + values.get( OUTRA_FUNCAO_3 ) + "\n" );
|
|
texto.append( " 4 " + values.get( OUTRA_FUNCAO_4 ) + "\n" );
|
|
ph.add( new Chunk( texto.toString(), FONT_NORMAL ) );
|
|
table.addCell( ph );
|
|
|
|
document.add( table );
|
|
|
|
table = new Table( 1 );
|
|
table.setBorderWidth( 1 );
|
|
table.setOffset( 0 );
|
|
table.setPadding( 5 );
|
|
table.setWidth( 100 );
|
|
|
|
table.addCell( new Phrase( "Outras Recomenda\u00e7\u00f5es",
|
|
FONT_BOLD ) );
|
|
|
|
texto = new StringBuilder();
|
|
if( ( (Boolean) Singleton.getInstance( SingletonConstants.FICHA_MARCA_EXAMES ) ).booleanValue() )
|
|
{
|
|
System.out.println( "ficha marca exames" );
|
|
texto.append( "PR\u00d3XIMO EXAME: " + values.get( PROXIMO_EXAME ) + "\n" );
|
|
}
|
|
texto.append( "" + values.get( OUTRAS_RECOMENDACOES ) + "" );
|
|
|
|
table.addCell( new Phrase( 12f, texto.toString(), FONT_NORMAL ) );
|
|
document.add( table );
|
|
|
|
|
|
table = new Table( 1 );
|
|
table.setBorderWidth( 1 );
|
|
table.setOffset( 0 );
|
|
table.setPadding( 5 );
|
|
table.setWidth( 100 );
|
|
|
|
texto = new StringBuilder();
|
|
|
|
texto.append( "M\u00c9DICO DO TRABALHO: "
|
|
+ values.get( MEDICOS_NOME ) + " C.P. " + values.get( NUMERO_CEDULA ) + "\n" );
|
|
texto.append( "ASSINATURA _____________________________________________________________________________________\n\n" );
|
|
texto.append( "TOMEI CONHECIMENTO ___________________________________________________________ DATA:____/____/________\n" );
|
|
texto.append( " O RESPONS\u00c1VEL DOS RECURSOS HUMANOS" );
|
|
|
|
table.addCell( new Phrase( 18f, texto.toString(), FONT_NORMAL ) );
|
|
document.add( table );
|
|
|
|
// }
|
|
// catch( Exception e ) {
|
|
// e.printStackTrace();
|
|
// return null;
|
|
// }
|
|
|
|
document.close();
|
|
// PdfWriter pdfw = PdfWriter.getInstance( document, bos );
|
|
// PdfContentByte pdfcb = new PdfContentByte( pdfw );
|
|
//
|
|
// PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
|
|
// // Step 2: Obtain a print job.
|
|
// PrinterJob pj = PrinterJob.getPrinterJob();
|
|
// Graphics2D graphics = pdfcb.createPrinterGraphics( 100.0F, 100.0F, pj );
|
|
// // Step 3: Find print services.
|
|
// PrintService []services = PrinterJob.lookupPrintServices();
|
|
// PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService();
|
|
// if(services.length > 0)
|
|
// {
|
|
// System.out.println("selected printer: " + services[0]);
|
|
// try
|
|
// {
|
|
// PrintService service = defaultService;
|
|
//// PrintService service = ServiceUI.printDialog(null, 200, 200,
|
|
//// services, defaultService, DocFlavor.SERVICE_FORMATTED.PAGEABLE, aset);
|
|
// pj.setPrintService(service);
|
|
// // Step 2: Pass the settings to a page dialog and print dialog.
|
|
//// pj.pageDialog(aset);
|
|
//// if (pj.printDialog(aset))
|
|
//// {
|
|
// // Step 4: Update the settings made by the user in the dialogs.
|
|
// // Step 5: Pass the final settings into the print request.
|
|
// pj.print(aset);
|
|
//// }
|
|
// }
|
|
// catch (PrinterException pe ) {
|
|
// System.err.println(pe);
|
|
// }
|
|
// }
|
|
|
|
}
|
|
catch( Exception e ) {
|
|
e.printStackTrace();
|
|
return null;
|
|
}
|
|
return bos.toByteArray();
|
|
}
|
|
|
|
private Phrase doCheckedPhrase( String text, String phrase, boolean indent )
|
|
{
|
|
boolean checked = CHECKED.equals( phrase );
|
|
Phrase p = new Phrase( 12f );
|
|
//p.add( new Chunk( ( indent ? " " : "" ) + ( char )( checked? 110: 111) + " ", FONT_ZAPFDINGBATS ) );
|
|
//System.out.println( "FAMILY: " + FONT_WINGDINGS.getFamilyname() );
|
|
p.add( new Chunk( ( indent ? " " : "" ) + ( char )( checked? 0xfe: 0xa8), FONT_WINGDINGS ) );
|
|
// p.add( new Chunk( ( indent ? " " : "" ) + ( char )( checked? 'X': '_'), FONT_WINGDINGS ) );
|
|
p.add( new Chunk( text, FONT_NORMAL ) );
|
|
return p;
|
|
}
|
|
|
|
private Phrase doCheckedPhrase( String text, String phrase )
|
|
{
|
|
return doCheckedPhrase( text, phrase, false );
|
|
}
|
|
} |