I'm having an issue with the PDF displaying outside the viewable area of the mx:HTML control in Flex. When the application starts up - the mx:HTML is set to a certain size, but can be enlarged if the application is maximized. These are the following conditions to replicate it:
- Issue only happens in Windows (Windows 7, not on Mac)
- Issue only happens with Reader X installed (not with previous versions)
- Issue only happens when running the built app, does not happen in debug / development mode from FlashBuilder
Here is some code to reproduce the issue. It looks a bit messy with the groups within groups, but there is other stuff in our application that I've stripped out just to have a small test app to reproduce the issue:
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="1004" height="510" backgroundColor="#000000" >
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
protected function press_clickHandler():void
{
htmlContent.location = "vt1_04_using_flash_builder.pdf";
}
]]>
</fx:Script>
<fx:DesignLayer>
<mx:HDividedBox id="myDividedBox" left="10" right="5" top="39" bottom="61" liveDragging="false">
<mx:Panel id="pnlTreeCtrl" width="250" height="100%" headerHeight="0">
<s:Button id="press" buttonMode="true" click="press_clickHandler()"
right="84" top="8" label="Press"/>
</mx:Panel>
<s:Group id="groupCourseMain" height="100%" >
<s:Group id="groupCourseHTML" right="0" top="30" bottom="0" width="100%">
<mx:HTML id="htmlContent" top="0" bottom="0" width="100%" />
</s:Group>
</s:Group>
</mx:HDividedBox>
</fx:DesignLayer>
</s:WindowedApplication>
Edit: The red arrow shows where the floating grey bar in Reader X appears outside the viewable area:
This seems to be a known bug with no fix.
A workaround is to re-size the browser width after the document is loaded and every time its parent group is re-sized. The trick is to re-size one pixel off to force a redraw. The following code seems to work. That's the best I could do, there may be better solutions.