sponsored ads

How to make Initial Configuration for generating a PDF Using Java

sponsored ads

I am going to generate a PDF Using Java , before i complete it , what the initial configuration i need to do Asked Aug, 07 2011
add commentflag 

sponsored ads

answer this question

1 answers

1 .Download and install Eclipse.

2 .Download the iText Java Library .

3 .Open Eclipse and click "File," "New," "Java Project." Name the project "iText" and click "Finish."

4 .In the "Package Explorer" , double-click the "iText" folder and select "Properties."

5 .Select "Java Build Path", and then click the "Libraries" tab .

6 .Click the "Add External JARs..." button. Navigate to the directory where you saved your ".jar" file and click "Open" and then "OK." Answered Aug, 07 2011
add comment|flag 
vote up 1 vote down

If you're referring to the configuration usually done during Windows installation and setup, the only way I'm aware of to do that would be to reinstall Windows.

If you're going to do that, you'll probably want to back up any data/files you need to keep before you do because reinstalling Windows will more than likely format your drive, unless you specifically tell it to save your user data. Answered Nov, 25 2010
vote up 2 vote down

1 .In Eclipse, go to "File," "New," "Class." Type "Test" in the Name field, under the "Which method stubs would you like to create?" select "public static void main" and click "Finish."

2 .In the Java editor window, select "public Class Test {" and type or copy-paste the following three "import" statements:
import java.io.FileOutputStream;
import com.itextpdf.text.*;
import com.itextpdf.text.pdf.*;

3 .Select "public static void main(String[] args) {" and type or copy-paste the following code:
Document document = new Document(PageSize.A4, 50, 50, 50, 50);
try{
PdfWriter writer = PdfWriter.getInstance(document,
new FileOutputStream("iTextTest.pdf"));
document.open();
document.add(new Paragraph("My First PDF document."));
document.close();
} catch (Exception e){
System.err.println(e.getMessage());
}

4 .Click the green play button to run your program.

5 .Navigate to the iText folder in your Eclipse Workspace directory. Double-click the "iTextTest.pdf" file. Answered Aug, 07 2011
vote up 1 vote down

Currently, I am using iText to convert my jTable data to pdf.
You can do it as i did.Good luck!

code :

private void print() {
Document document = new Document();

try {

PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("jTable.pdf"));

document.open();

PdfContentByte cb = writer.getDirectContent();

cb.saveState();

Graphics2D g2 = cb.createGraphicsShapes(800, 500);

Shape oldClip = g2.getClip();

g2.clipRect(0, 0, 800, 500);

jTable.print(g2);

g2.setClip(oldClip);

g2.dispose();

cb.restoreState();

} catch (Exception e) {

System.err.println(e.getMessage());

}

document.close();

} Answered Dec, 19 2010
vote up 1 vote down

Your Answer

community wiki:

The Verified Code is to stop spamming. It will be hidden once your reputation reached 100.
or
Create one

Options

sponsored ads

Download related software from AFC

HTML+Java 0.5.13022.28751

Last Updated: May 23, 2011
License:
Filesize: 282KB

Continue to downloadPower by Afreecodec.com