How to convert a swing form to PDF

How to convert a swing form to PDF

Sir, I want to know about how convert a swing form containing textbox,JTable,JPanel,JLabel, Seperator etc swing menus to a PDF file using java code

View Answers

August 3, 2012 at 12:55 PM

import com.stevesoft.phreida.*; import java.awt.*; import java.io.*;

public class Test1 { public static void main(String[] args) throws Exception { // Create the PGraphics object PGraphics pg = new PGraphics("test1.pdf");

// Draw something -- some text with a box around it.
Font f = new Font("Helvetica",Font.PLAIN,25);
pg.setFont(f);
FontMetrics fm = pg.getFontMetrics(f);
int border = 1;
int d = fm.getDescent();
int h = fm.getHeight();
int w = fm.getLeading();
String str = "Hello, world";
int y = (10+fm.getAscent());
pg.drawString(str,10,y);
pg.drawRect(10-border,10-border+d,
            fm.stringWidth(str)+w+2*border,
             h+2*border);

// Finish
pg.dispose(); // writes out file
System.exit(0); // Graphics thread is running still

} }


August 3, 2012 at 12:57 PM

for above reqiuerd download jar file stevesoft phreida









Related Tutorials/Questions & Answers:
How to convert a swing form to PDF
How to convert a swing form to PDF  Sir, I want to know about how convert a swing form containing textbox,JTable,JPanel,JLabel, Seperator etc swing menus to a PDF file using java code
How to Convert PDF into rtf File Java
How to Convert PDF into rtf File Java  Hi, How could in covert the PDF file to rtf file in Java Programming. Please suggest any online example... the online example of Java Convert PDF into rtf File. Thanks
Advertisements
convert excel into pdf
convert excel into pdf  How to convert excel into pdf files
convert an pdf file to html in Java
convert an pdf file to html in Java  Hi all, How to convert an pdf file to html in Java? Currently all my data is generated into a report in pdf and i want to be able to generate it to html page as well. How to go about
convert word document to pdf
convert word document to pdf  Hi, Could you please help me write a java code that converts the word docuemnt into PDF? I have to save the generated..."); f.convert(fos,"pdf"); I would also want to know, what does "OfficeFile" in the code
CONVERT JTable DATA TO PDF FILE
CONVERT JTable DATA TO PDF FILE  HOW TO CONVERT JTable DATA TO .PDF... the jtable data from the jframe and stored the data into the pdf file in the form...); button=new JButton("Save to pdf"); button.addActionListener(new ActionListener
Convert Text File to PDF file
Convert Text File to PDF file  Here is the way how to covert your Text file to PDF File, public class TextFileToPDF { private static void...(inLine); System.out.println("Text is inserted into pdf file
Java code to convert pdf file to word file
Java code to convert pdf file to word file  How to convert pdf file to word file using Java
Convert BLOB to PDF and save it to a location
Convert BLOB to PDF and save it to a location  I have a requirement to convert blob(stored in a DB table) back to .pdf in the UI(for the users... it has to convert each blob to a pdf and zip it, which the user should be able
how to convert doc file into html using java swing
how to convert doc file into html using java swing  i want to convert doc file into html and display it on jtextarea please help me and give the sample code
Convert pdf to rtf and txt - XML
Convert pdf to rtf and txt  Can we convert PDF to RTF and TXT, and how?  Hi Friend, Try the following codes: 1)Convert PDF to RTF...) {} } } 2)Convert PDF to TEXT import java.io.*; import java.util.
Convert PDF to XML in Java
Convert PDF to XML File in Java In this Java tutorial section, you will learn how to convert pdf file to xml using java program. We have used itext api for this purpose. To read hello.pdf file, we have used PDFReader class. The data
Convert Text File to PDF file
Convert Text File to PDF file  import java.io.BufferedReader; import java.io.FileOutputStream; import java.io.FileReader; import...); System.out.println("Text is inserted into pdf file"); document.close
Java convert jtable data to pdf file
Java convert jtable data to pdf file In this tutorial, you will learn how to convert jtable data to pdf file. Here is an example where we have created... have fetched the data from the jtable and save the data to pdf file. Example
convert this html form to jsp
convert this html form to jsp  <html> <head> <script language="javascript" src="images/validationm.js"></script> <...;/tr> <form name="VillageDetailsForm" action="AddVillage.jsp" method
put image on form creating in swing-swing code - Swing AWT
put image on form creating in swing-swing code  i want to display image on swing panel and get the image co ordinate by mouse clicking.and also zoom the image at particular area of image. please give solution on my email id
How to create form in Swings
How to create form in Swings  How to create registration, login and question form in Java Swing?   Creating different forms in Java Swing - Examples how to create registration form in swing swing login form example
to convert html to pdf in java - Java Beginners
to convert html to pdf in java  HI all, i want to convert html to pdf using java. actually i dont need as the tags in the html. but the tags should be removed and i need only the text in that. Thanks in advance
form field mapping with pdf file using java
form field mapping with pdf file using java   Hai all, I have one requirement that i have one html form.i have to map the form fields with pdf... related to the field in pdf file should marked with a color. can any one give
convert data from pdf to text file - Java Beginners
convert data from pdf to text file   how to read the data from pdf file and put it into text file(.txt
how to load pdf on html
how to load pdf on html  how to load pdf on html
convert jpeg to gif - Swing AWT
convert jpeg to gif  i want to convert jpeg file to gif file. in the roseindia's already existing program,i can convert gif to jpeg.But i cant convert jpeg to gif. help me plz....  Hi friend, import java.io.
To convert Html to pdf in java - Java Beginners
To convert Html to pdf in java  Hi all, I want to convert html file to pdf file using java. can any one help me out. Thanks & Regards Santhosh Ejanthkar  Hi Friend, Try the following code: import
Convert pdf to rtf file using Java
Convert pdf to rtf file using Java In this section, you will learn how to convert .pdf file to .rtf file in java programming language. We have used itext api for this purpose. To read resume.pdf  file, we have used PDFReader class
Convert pdf to text file using Java
How to Convert pdf to text file in Java In this section, you will learn how to convert pdf file to text file in Java Programming. We have used itext api for this purpose. To read resume.pdf  file, we have used PDFReader class
SWT login form - Swing AWT
SWT login form  Hi, I want code to create a login form in SWT. My...(2, false)); shell.setText("Login form"); label1=new Label(shell...|SWT.CANCEL); messageBox.setText("Login Form"); messageBox.setMessage
Display Logo on login form using swing
Display Logo on login form using swing In this tutorial, you will learn how to display a logo in login form using swing components. Here is an example where... a logo for this login form, we have used ImageIcon class that accepts the image
how to generate pdf file in struts
how to generate pdf file in struts  I am developing a struts application.I am having one registration form when i am submitting the form the values are stored in database,the database name is registration. In another form i am
how to generate pdf file in struts
how to generate pdf file in struts  I am developing a struts application.I am having one registration form when i am submitting the form the values are stored in database,the database name is registration. In another form i am
Problem when resizing the form - Swing AWT
resizing the form. I have a JTextPane on the JInternalFrame which occupy all the form space at initial stage. we have a button to add a new JTextPane on the form.... But When we resize the form, the old JTextPane moves to its initial position
"Urgent" convert this code to GUI - Swing AWT
"Urgent" convert this code to GUI   please convert for me this code to GUI THE CODES ARE BELOW, CLASS ATMCaseStudy is the driver class that runs all the other classes. its very urgent. //CLASS CashDispenser public class
please convert for me this code to GUI - Swing AWT
please convert for me this code to GUI    THE CODES ARE BELOW, CLASS ATMCaseStudy is the driver class that runs all the other classes. its very urgent. // class ATM import javax.swing.*; import java.awt.*; public
please convert for me this code to GUI - Swing AWT
please convert for me this code to GUI  THE CODES ARE BELOW, CLASS ATMCaseStudy is the driver class that runs all the other classes. its very urgent. // class ATM import javax.swing.*; import java.awt.*; public class ATM
how to print pdf format
how to print pdf format  Hi every body iam doing school project iam using backend as oracle front end java .how to print student marks list /attendence in pdf format. please help me. thanks in advance.   Here
New Problem in Form Resizing - Swing AWT
New Problem in Form Resizing  Hi, I am using a MDI application which have a menu item New which adds My New JInternalFrame form to the desktopPane... of the JInternalFrame form space at initial stage. at initial stage the code part
how to dispaly pdf file on browser
how to dispaly pdf file on browser  In my project i have created one pdf file(by pdfwriter) into my local mechine . after that it need to display in browser as a pdf file . but in jsp i can't display by tag can anyone give me
How to get the position of the comments in the pdf
How to get the position of the comments in the pdf  how to get the postion of comments, in the extracted xml, from pdf
How to get the position of the comments in the pdf
How to get the position of the comments in the pdf  how to get the postion of comments, in the extracted xml, from pdf
Convert ZIP To PDF
Convert ZIP To PDF       Lets discuss the conversion of a zipped file into pdf file..., unzip it and then store it into a byte array. Convert this array of byte
how to display pdf file on browser
how to display pdf file on browser   In my project i have created one pdf file(by pdfwriter) into my local mechine . after that it need to display in browser as a pdf file . but in jsp i can't display by iframe tag can anyone
How to Make a Pdf and inserting data
How to Make a Pdf and inserting data       In this tutorial you will learn how we can make a pdf file and how we can insert a data into the pdf file. This all
Convert Text To PDF
Convert Text To PDF       Here we are discussing the convertion of a text file into a pdf file... into the add() method of the document class to generate a pdf file. Download iText API
Swing login form example
Swing login form example In this example we have described swing login form. We have created one text field "textField" and one jPasswordField and we have set text for username and password. We create one submit button and perform
how to create reports in swing java?
how to create reports in swing java?  how to create reports in swing java
How to convert a String to an int?
How to convert a String to an int?  I my program I am taking the input from user from a HTML form in JSP page. The value retrieved is in the String format. Now I want to convert into int value. Tell me How to convert a String
How to reset a form in jQuery?
How to reset a form in jQuery?  Hi, I have a form where I am using jQuery. I want to reset the form. How I can reset the form grammatically?   Hi, You can use following code: $("#MyFomrName").reset(); Thanks
How to insert a single page PDF file into another multipage PDF file using iText? - Java Beginners
How to insert a single page PDF file into another multipage PDF file using iText?  Hi ALL: I have two PDF files. PDF-A.pdf is a multipage PDF file. PDF-B.pdf is a single page PDF file. I want to insert PDF-B into PDF-A only
how can i display a pdf file in a jtextarea
how can i display a pdf file in a jtextarea  I need to display a pdf file in a jtextfield or in a jtextarea.Atlest i need to displat it in a jframe.I have a button and while clicking on it ,i need to choose the pdf file and need
how to create pdf file using java and itextjar
how to create pdf file using java and itextjar  How to create pdf file having paragraphs and alignments done using java and itextjar 5.10 version.? hope i get quick response
how to create pdf file using java and itextjar
how to create pdf file using java and itextjar  How to create pdf file having paragraphs and alignments done using java and itextjar 5.10 version.? hope i get quick response

Ads