I'm building a program allows me to answer questions with radio buttons, and then save a list of the questions and the selected answers to a .txt file which I can convert to a .pdf from Word or some other program. Im using a PrintWriter to write the file, and everything is working as expected for all of that.
My problem is that I also need to write a .png image to the bottom of that text file. I used an imageReader to get the image into my code, and I know that part is working correctly because I can save the image to a different file than my text file...but I can't figure out a way to get it into my .txt file. I'll put the code below. Thanks in advance for any ideas.
private void writeToFile(PrintWriter out) {
list= new String[22];
int ii = 0;
for(int i = 0;i< buttons.length;i++){
if(buttons[i]){
int j = i%3;
if(j==2){
list[ii]="N/A";
ii++;
}
else if(j==1){
list[ii]="No";
ii++;
}
else{
list[ii]="Yes";
ii++;
}
}
}
img = null;
try {
img = ImageIO.read(new File("resources/sig.png"));
} catch (IOException e) {
ta.setText("Error: IO.read method"+ e);
}
try {
bi = img; // retrieve image
outPutFile = new File("testFileToSeeIfImageIO.readLoadedTheImageAsExpected.png");
ImageIO.write(bi, "png", (outPutFile));
} catch (IOException e) {
ta.setText("Error: IO.write method" + e);
}
String format = "%1$-70s%2$-10s\n";
out.println();
out.println();
out.println();
out.println();
out.println(" Integrated Construction");
out.println("P.O. Box 0000");
out.println("North Conway, NH 00000");
out.println();
out.println();
out.println();
out.println("Property Address: "+ addressList.getSelectedItem() );
out.println();
out.println();
out.println();
for(int i =0;i<questions.length;i++){
out.format(format, questions[i],list[i]);
}
}
Thanks
Scott