Discussion: Using Itext to create a report
In the previous quiz, Online Java Quiz, we tested our experience gained from the course.
Member
7 messages from 7 displayed.
//= Settings::TRACKING_CODE_B ?> //= Settings::TRACKING_CODE ?>
In the previous quiz, Online Java Quiz, we tested our experience gained from the course.
Please, use the </>
button to insert source codes to the
forum. The AppData folder is specified at the start of your code:
String dataFolder = System.getenv("APPDATA") + "/Stock reports/" + ch + ".pdf";
To make the user select a path in Java Swing, use JFileChooser instead:
JFileChooser chooser = new JFileChooser();
chooser.setCurrentDirectory(new java.io.File("."));
chooser.setDialogTitle("Choose the destination path");
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // Only folders
chooser.setAcceptAllFileFilterUsed(false);
if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
String dataFolder = chooser.getCurrentDirectory() + ch + ".pdf";;
} else {
// Show error message here or perform any failure action you want to
}
Also consider switching to JavaFX.
am highly grateful it worked as i wanted. PERFECT.
Please Mr. David with respect to the JavaFX i have no idea but if you can give
me tutorial notes .pdf on it i will do perfectly well.
hope to get that help from you because I Love working with java than any other
platform.
thanks very much.
from Jones.
please the directory is ook but the pdf becomes empty without leaving the
file (pdf) in it.
what should i do.
And are you sure that the code generating the PDF file works? If so, try to print what is in the dataFolder variable at the end:
System.out.println(dataFolder);
What does it print? Maybe I forgot to add a slash:
chooser.getCurrentDirectory() + "/" + ch + ".pdf";
the pdf file comes alright but cant save to the folder like my first
code.
so please help me Boss
Try to print the path as I wrote in the last message and to add the extra slash.
7 messages from 7 displayed.