Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2007

Tip: Looking for answers? Try searching our database.

PDF files

Thread view: 
Raspberry - 25 Jun 2007 20:17 GMT
Hi,
I'm a beginner java developer, and I'm developing a desktop
application, it contains form generate reports for user in pdf format
and save it in temporary file.
when user view the archived report, he could save it in another path
(for example: myDocuments)... but the new saved file is empty except
from a logo
this is the code to save the pdf ... can anybody help my to find the
problem? thanx in advance

public void export(){
 Properties m_ctx=Env.getCtx();
 JFileChooser chooser = new JFileChooser();
 chooser.setDialogType(JFileChooser.SAVE_DIALOG);
       chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
       chooser.setDialogTitle(Msg.getMsg(Env.getCtx(), "Export"));
       chooser.addChoosableFileFilter(new
ExtensionFileFilter("pdf" ,Msg.getMsg(m_ctx, "FilePDF")));

       if(chooser.showSaveDialog(this)!= JFileChooser.APPROVE_OPTION)
        return;

       File file =
ExtensionFileFilter.getFile(chooser.getSelectedFile(),
chooser.getFileFilter());
       Viewer viewer = new Viewer();
       try{
        PDFGenerator.getPDFAsStream(new
FileOutputStream(file),layoutEngine.getPageable(false));
        file.createNewFile();

       }catch(Exception e){
        e.printStackTrace();
       }
rossum - 25 Jun 2007 21:29 GMT
>Hi,
>I'm a beginner java developer, and I'm developing a desktop
[quoted text clipped - 26 lines]
>FileOutputStream(file),layoutEngine.getPageable(false));
>         file.createNewFile();
The documentation for createNewFile says: "creates a new, empty file".
Is that "empty" the source of your problem?  After you create it you
seem to exit your method without having put anything into the file.

rossum

>        }catch(Exception e){
>         e.printStackTrace();
>        }


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.