hello,
I want to show student info and picture in an rs_student ... es_student section. I have learn how to make this in the two docmosis guides, so i have a java ArrayList for input and have insert a bookmark (bm_photo) on picture in the word template (french version). But, the picture not change in any situation that i try (all other student infos are ok). Have you an example to insert a picture in a repeat section ? Here is my java in "buildDataProvider" :
private DataProvider buildDataProvider3() {
DataProviderBuilder fda = new DataProviderBuilder();
List list = ctrl.getStudentList();
fda.add("TitreDoc", "LISTE DES ETUDIANTS");
fda.addJavaObject(list);
int i = 0;
for (Student stu : list) {
fda.add("student."+i+".photo", "[image:"+ stu.getAccesPhoto() +"]"); <<<< how to make this with ?
i++;
}
return fda.getDataProvider();
}
stu.getAccesPhoto() give a standard file jpg access on a picture in windows XP. Example :
key="student.0.photo" --> value="[image:C:/Java/Projects/Photos/008691.jpg]"
Thanks.
OK, i have found how to make
OK, i have found how to make this with a "photo" field in java bean and this code in :
public InputStream getPhoto() {
photo = null;
String pictPath = SAFApp.getPrefValue("pict_folder"); // other for you
String f=pictPath.replace("\\", "/") + "/" + getNoIdent() + ".jpg";
if (!FileLib.isFileExists(f)) {
String lan = getLangue().getAbrev().toLowerCase();
f = pictPath+"/nopic"+ lan + ".jpg"; // a default picture
}
try {
photo = new BufferedInputStream(new FileInputStream(f));
} catch (Exception e) {
}
return photo;
}
... and in the word template a "bm_photo" bookmark on a placeholder picture.
With 1300 students, it takes about 4 minutes (local machine) to product 3 documents of 20Mo (doc), 17Mo (odt) and 15 Mo (pdf).
A enhancement for docmosis : the posibility to include picture i an other way (only link) for Word documents :
{ INCLUDEPICTURE { MERGEFIELD photo } /d } <-- this don't work actually
Finally, i think that docmosis is a good product. Thanks to the developpers.
Alternative Solution
Hi jcstritt
There is also an alternative solution to your requirements. What you want can also be done using multiple data provider builders as follows:
private DataProvider buildDataProvider3() {
DataProviderBuilder fda = new DataProviderBuilder();
List list = ctrl.getStudentList();
fda.add("TitreDoc", "LISTE DES ETUDIANTS");
fda.addJavaObject(list);
for (Student stu : list) {
DataProviderBuilder studentBuilder = new DataProviderBuilder();
studentBuilder.addImage("photo", stu.getAccesPhoto());
studentBuilder.addJavaObject(stu, "details");
fda.add(studentBuilder.getDataProvider(), "student");
}
return fda.getDataProvider();
}
The template would look something like the following (in the simplest case):
<<rs_student>>
Student Name: <<details.name>>
Image: <<bm_photo>>
<<es_student>>
With this solution, you won't need to worry about using InputStreams.