In the meantime, I was able to solve my problem.
I added the "BinaryResource:" prefix to the data attribute and passed the BinaryResource handler to the addAttachment method as follows:
public class PrintField extends AbstractHtmlField {
@Override
protected void execInitField() {
try {
BinaryResource pdfContent = TableExporter.getAsPDF(parentTable);
addAttachment(pdfContent);
setValue("object:<center><object data=\"binaryResource:" + pdfContent.getFilename() + "\" type=\"application/pdf\" width=\"100%\" height=\"100%\"><p>No PDF document</p></object></center>");
} catch (Exception e) {
e.printStackTrace();
}
}
}
Now it works :-)
I also discovered that an alternative effect can be obtained by using an AbstractBrowserField field like this:
public class BrowseField extends AbstractBrowserField {
@Override
protected void execInitField() {
BinaryResource pdfContent = TableExporter.getAsPDF(parentTable);
setBinaryResource(pdfContent);
}
@Override
protected boolean getConfiguredScrollBarEnabled() {
return true;
}
}
[Updated on: Wed, 07 August 2019 12:59]
Report message to a moderator