Hi Fatbob.
In fact there is no special trick in translating C# code to Java code since interfaces and method names are the same in C# stubs and Java stubs generated by ComfyJ code generator. Please find the translated method below:
private void removeWatermark(_Document document) {
_Application application = document.getApplication();
Selection selection = application.getSelection();
Sections sections = document.getSections();
Section first = sections.item(new Int32(1));
Range range = first.getRange();
range.select();
Window activeWindow = application.getActiveWindow();
Pane activePane = activeWindow.getActivePane();
View view = activePane.getView();
view.setSeekView(new WdSeekView(WdSeekView.wdSeekCurrentPageHeader));
HeaderFooter headerFooter = selection.getHeaderFooter();
Shapes shapes = headerFooter.getShapes();
//Considering that you do not know the exact name of the watermark shape you will have to iterate over
//the shape array looking for something that looks like watermark
Int32 shapesCount = shapes.getCount();
long shapesCountValue = shapesCount.getValue();
for (long i = 1; i <= shapesCountValue; i++) {
Variant shapeNumber = new Variant(i);
Shape item = shapes.item(shapeNumber);
String itemName = item.getName().toString();
if(itemName.contains("WaterMark")){
item.delete();
}
}
view.setSeekView(new WdSeekView(WdSeekView.wdSeekMainDocument));
}
Please try it and let me know the results.
Sincerely,
Yuriy.