Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Enquiry on converting a *.txt file to a *.pdf file

807580Jul 18 2010 — edited Jul 23 2010
Enquiry on converting a *.txt file to a *.pdf file


Aim of this software: Let the user to choose a *.txt file to convert it to a *.pdf file.


1. User clicks a choose file button. [chooseFileButton]
2. User clicks the Export 2 button [exportButton2]
3. User clicks the Text -> PDF button [pdfConverterButton]


-------------------------------------------------------------------


After choosing the file and click the choose file button:


System prints out (for debbuging use...)


---------------------------Print from Trans.java - method transMemory--------------------


File's name: file.txt



File's path: C:\Users\charles\Desktop\netbean\Pdfproject1\file.txt
-----------------------------------------------------------



After clicking the Export 2 button, system prints out:


---------------Print out the File's name - from DataOut.java - getData() Method-------------------------



File's Name: file.txt



---------------------------------------------------------
----------------Print out the file's path - from DataOut.java - getData() Method--------------



File's path: C:\Users\charles\Desktop\netbean\Pdfproject1\file.txt



---------------------------------------------------------
The file now being read by the system: transNameData.txt
The data being copied to this file: copyOfFileName.txt Destination
This file has been copied: file.txt Original



The following content has been copied:

---start of content - from TheFile.java - save2() method---

Some content.....................................

--------end of content--------
Jul 18, 2010 3:32:04 PM mainFrame1 exportButton2ActionPerformed
SEVERE: null
java.io.IOException: Permission denied
at java.io.FileInputStream.readBytes(Native Method)
at java.io.FileInputStream.read(FileInputStream.java:199)
at java.io.DataInputStream.read(DataInputStream.java:132)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:264)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:306)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:158)
at java.io.InputStreamReader.read(InputStreamReader.java:167)
at java.io.BufferedReader.fill(BufferedReader.java:136)
at java.io.BufferedReader.readLine(BufferedReader.java:299)
at java.io.BufferedReader.readLine(BufferedReader.java:362)
at TheFile.save2(TheFile.java:144)
at mainFrame1.exportButton2ActionPerformed(mainFrame1.java:168)
at mainFrame1.access$200(mainFrame1.java:30)
at mainFrame1$3.actionPerformed(mainFrame1.java:79)
at java.awt.Button.processActionEvent(Button.java:392)
at java.awt.Button.processEvent(Button.java:360)
at java.awt.Component.dispatchEventImpl(Component.java:4630)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)




After clicking the text -> PDF button, system prints out:



The following data is called by the PDF converter button...



---------------Print out the File's name - from DataOut.java - getData() Method-------------------------



File's Name: file.txt



---------------------------------------------------------
----------------Print out the file's path - from DataOut.java - getData() Method--------------



File's path: C:\Users\charles\Desktop\netbean\Pdfproject1\file.txt



---------------------------------------------------------



MakePdf.java is loading... - createPdf() method



File you have chosen and this file will be converted to a PDF file: file.txt

And the content of the file is:

---start of content--- (Info from MakePdf.java)

Some content.....................................

---end of content---


Print out the content again: Some content..................................... ---> Info from SubClass DocToPdf of MakePdf.java
Exception in thread "AWT-EventQueue-0" ExceptionConverter: java.io.IOException: The document has no pages.
at com.lowagie.text.pdf.PdfPages.writePageTree(Unknown Source)
at com.lowagie.text.pdf.PdfWriter.close(Unknown Source)
at com.lowagie.text.pdf.PdfDocument.close(Unknown Source)
at com.lowagie.text.Document.close(Unknown Source)
at MakePdf$DocToPdf.createDoc(MakePdf.java:140)
at MakePdf.createPdf(MakePdf.java:97)
at TheFile.forPdfUse(TheFile.java:267)
at mainFrame1.pdfConverterButtonActionPerformed(mainFrame1.java:184)
at mainFrame1.access$300(mainFrame1.java:30)
at mainFrame1$4.actionPerformed(mainFrame1.java:86)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6263)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:6028)
at java.awt.Container.processEvent(Container.java:2041)
at java.awt.Component.dispatchEventImpl(Component.java:4630)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
at java.awt.Container.dispatchEventImpl(Container.java:2085)
at java.awt.Window.dispatchEventImpl(Window.java:2478)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
BUILD SUCCESSFUL (total time: 1 minute 41 seconds)
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 19 2010
Added on Jul 18 2010
21 comments
1,241 views