IFrame inside Dialog

Hello,

Is it possible to set the width and height of a dialog based on the IFrame and its content? I have a variable String that represent HTML file that I would like to display in a Dialog.

Dialog dialog = new Dialog();
IFrame iFrame = new IFrame();

iFrame.setSrcdoc(htmlContent);
iFrame.setSizeFull();

dialog.setResizable(true);

dialog.add(iFrame);
dialog.open();

Some things you can try here: make iframe height dynamic based on content inside- JQUERY/Javascript - Stack Overflow

yeah the challenge is not so much the Dialog but rather making the iframe scale to fit its contents