Click here to Skip to main content
15,921,793 members
Home / Discussions / Java
   

Java

 
GeneralRe: problem with arrays in java Pin
jschell28-Jan-12 4:45
jschell28-Jan-12 4:45 
GeneralRe: problem with arrays in java Pin
Richard MacCutchan28-Jan-12 4:54
mveRichard MacCutchan28-Jan-12 4:54 
QuestionCalling a Shared function from the Client side Pin
Vimalsoft(Pty) Ltd27-Jan-12 6:35
professionalVimalsoft(Pty) Ltd27-Jan-12 6:35 
AnswerRe: Calling a Shared function from the Client side Pin
Richard MacCutchan27-Jan-12 7:11
mveRichard MacCutchan27-Jan-12 7:11 
GeneralRe: Calling a Shared function from the Client side Pin
Vimalsoft(Pty) Ltd28-Jan-12 4:00
professionalVimalsoft(Pty) Ltd28-Jan-12 4:00 
Questionbe project Pin
harendra rai26-Jan-12 19:38
harendra rai26-Jan-12 19:38 
AnswerRe: be project Pin
TorstenH.26-Jan-12 20:44
TorstenH.26-Jan-12 20:44 
Questionjpanel to itext Pin
bijalvadher24-Jan-12 23:32
bijalvadher24-Jan-12 23:32 
Hello,
Can anyone please help me.
I am new to itext and dont know much...
I have a jpanel having approx 380 components.I have to create the respective components on itext pdf document.i am trying to take a graphics 2d of each component and placing it in pdf but how should i reduce the size and give respective cordinates..
its too confusing as jpanel creates its component from top left corner and pdf from bottom left.
i also need to calculate proprtionate width and height.
public void convertPageToIText(Form form, Page page,
PagePanel pagePanel,
PageController pageController,ZipOutputStream zos, String pageModel,int i) throws DocumentException, IOException
{

pageController.resetFieldsChecked();
pageController.prepareBeforeSynchronizeFrom(form, page);
pagePanel.synchronizeFrom(page);
pageController.prepareAfterSynchronizeFrom(form, page);
UI.setEnabled(pagePanel, true);

Document doc = new Document(PageSize.A4);
File file=null;
FileInputStream fis=null;
file = File.createTempFile("IR Mobility1-", ".pdf");
ByteArrayOutputStream baos=new ByteArrayOutputStream();
PdfWriter writer =PdfWriter.getInstance(doc, baos);
writer.setPdfVersion(PdfWriter.VERSION_1_5);

doc.open();

PdfContentByte cb=writer.getDirectContent();

Graphics2D g2 =null;


int pagenumber=1;
for (Field field :pagePanel.getClass().getSuperclass().getDeclaredFields())
{

Object o = pagePanel.get(field);

if (o instanceof JLabel)
{

JLabel jLabel = (JLabel)o;
float llx=jLabel.getX()*(594/750);
float lly=((jLabel.getY()*(842/pagePanel.getHeight()))+(jLabel.getHeight()*(842/pagePanel.getHeight())));

PdfTemplate template = cb.createTemplate(jLabel.getWidth()*0.5f, jLabel.getHeight()*0.5f);

g2 = template.createGraphics(jLabel.getWidth()*0.5f, jLabel.getHeight()*0.5f);
jLabel.print(g2);
g2.dispose();
cb.addTemplate(template, jLabel.getX(),842-jLabel.getY());
// cb.stroke();
// cb.restoreState();


continue;
}

// if (o instanceof JTextField)
// {
// JTextField jLabel = (JTextField)o;
//
// PdfTemplate template = cb.createTemplate(jLabel.getWidth(), jLabel.getHeight());
// template.stroke();
// g2 = template.createGraphics(jLabel.getWidth(), jLabel.getHeight());
// g2.scale(1,1);
//
// jLabel.print(g2);
//
// g2.dispose();
// cb.addTemplate(template, jLabel.getX(), 842-jLabel.getY());
//
// continue;
// }
if (o instanceof JTextArea) {}
if (o instanceof JTextPane) {}
if (o instanceof JCheckBox) {}
if (o instanceof JRadioButton) {}
if (o instanceof JDateField) {}
if (o instanceof SignaturePanel) {

}
if (o instanceof DrawingPanel) {}
if (o instanceof HelperObjectComboBox) {}


}

doc.close();

PdfReader reader = new PdfReader(baos.toByteArray());
PdfStamper stamper =new PdfStamper(reader, new FileOutputStream(file));
stamper.setRotateContents(false);
stamper.setFormFlattening(true);
stamper.close();

fis = new FileInputStream(file);
byte[] b = new byte[1 * 1024];
while (true) {
int k = fis.read(b);
if (k == -1) {
break;
}
zos.write(b, 0, k);
}
fis.close();
fis = null;
file.delete();
file = null;


}

}
AnswerRe: jpanel to itext Pin
Nagy Vilmos25-Jan-12 2:23
professionalNagy Vilmos25-Jan-12 2:23 
AnswerRe: jpanel to itext Pin
TorstenH.25-Jan-12 3:04
TorstenH.25-Jan-12 3:04 
QuestionProblem with ArrayLists java Pin
nikosv21-Jan-12 21:04
nikosv21-Jan-12 21:04 
AnswerRe: Problem with ArrayLists java Pin
Richard MacCutchan21-Jan-12 23:05
mveRichard MacCutchan21-Jan-12 23:05 
QuestionHelp with adding jPanel Form to other form Pin
_T("No name")21-Jan-12 5:53
_T("No name")21-Jan-12 5:53 
AnswerRe: Help with adding jPanel Form to other form Pin
TorstenH.22-Jan-12 21:42
TorstenH.22-Jan-12 21:42 
QuestionMultithreaded proxy server Pin
prateek.rajan8919-Jan-12 16:29
prateek.rajan8919-Jan-12 16:29 
AnswerRe: Multithreaded proxy server Pin
Peter_in_278019-Jan-12 17:41
professionalPeter_in_278019-Jan-12 17:41 
AnswerRe: Multithreaded proxy server Pin
jschell20-Jan-12 12:49
jschell20-Jan-12 12:49 
Questioncode problem Pin
nikhil_kumar19-Jan-12 11:04
nikhil_kumar19-Jan-12 11:04 
AnswerRe: code problem Pin
TorstenH.19-Jan-12 21:34
TorstenH.19-Jan-12 21:34 
GeneralRe: code problem Pin
nikhil_kumar21-Jan-12 9:10
nikhil_kumar21-Jan-12 9:10 
GeneralRe: code problem Pin
♥…ЯҠ…♥12-Feb-12 17:41
professional♥…ЯҠ…♥12-Feb-12 17:41 
AnswerRe: code problem Pin
♥…ЯҠ…♥12-Feb-12 17:14
professional♥…ЯҠ…♥12-Feb-12 17:14 
Questionsource code Pin
bhanu.pratap.9918-Jan-12 2:46
bhanu.pratap.9918-Jan-12 2:46 
AnswerRe: source code Pin
Richard MacCutchan18-Jan-12 3:00
mveRichard MacCutchan18-Jan-12 3:00 
AnswerRe: source code Pin
Nagy Vilmos18-Jan-12 3:03
professionalNagy Vilmos18-Jan-12 3:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.