PrintDataGrid’s DataGridColumn – Embedded image not printing when you use TextFlow in the item rende
I’m printing a datagrid using something like this… |||
If the images have to be loaded, they won’t show up right away. You will
need to preload them or find a way to wait.
|||
Thanks!
The text is fetched from the database and has urls to the images.
So, I should
1. parse the text and create the collection of such urls
2. create an array of flash.display.Bitmap objects by loading images from the urls
3. replace all the <img source=url with <img source=bitmap object
Does this look like a fair approach?
I couldn’t find the syntax for specifying bitmap object as img tag’s source?
|||
That might work. I’m not sure you can specify source in
markup. I
think you have to actually create your own InlineGraphicElements and hand
them the bitmaps.
Another factor is whether the images have already been seen and are in a
cache somewhere. If you think they will load quickly, you can probably just
wait a few frames before calling addObject/addPage.
|||
No success so far in printing images in PrintDataGrid. |||
Try using callLater. Then post a 20-line test case.
|||
Instead of Timer callback, I now have callLater(). In the callLater function, I make a call to printJob.addObject() and get similar error message.|||
Post a 20-line test case and I will look into it.
|||
I’ve spent quite a bit of time on this but am still unable to fix this issue. Please help!
I’ve trim down the test / sample application’s code to bare minimum and hosted 2 different versions of the test app on my server. I’ve enabled View Source.
When the application comes up, just click on Print button to print the 3 rows you see on the screen.
http://208.109.190.155:9080/printImagesError/PrintImages.htmlThis version does printJob.addObject(thePrintView) in callLater.|||
I was unable to access the link. Is that IP address public and fixed?
|||
It’s a public and fixed IP address. Is it possible that Adobe’s firewall policy prevents accessing IP-based url? I’ve had that experience in the past. If that’s the case, I can copy-paste the 3 program files here. Let me know.
|||
Not sure what our firewall rules are. Anyway, below is a quick test case I put together. I can submit the job later by pressing the submit button (within 15 seconds of starting the job). See if this test case works for you.
<?xml version=”1.0″ encoding=”utf-8″?>
<s:Application xmlns:fx=”http://ns.adobe.com/mxml/2009“
xmlns:s=”library://ns.adobe.com/flex/spark”
xmlns:mx=”library://ns.adobe.com/flex/mx”
xmlns:comps=”comps.*”
>
<!<fx:Style source=”Accessibility.css” />>
<s:layout>
<s:VerticalLayout paddingLeft=”20″ paddingRight=”20″
paddingTop=”20″ paddingBottom=”20″ />
</s:layout>
<s:controlBarContent>
<s:Label id=”sdkVer” initialize=”sdkVer.text = mx_internal::VERSION;” />
</s:controlBarContent>
<fx:Script>
<![CDATA[
import mx.printing.FlexPrintJob;
private var pj:FlexPrintJob;
private function printIt():void
{
pj = new FlexPrintJob();
if (pj.start())
{
swfldr.source = "umbrellas.jpg";
}
}
private function imageComplete():void
{
submit.visible = true;
}
private function submitJob():void
{
pj.addObject(pnl);
pj.send();
}
]]>
</fx:Script>
<s:Panel id=”pnl” title=”Print in Background Test”
width=”75%” height=”100%”
horizontalCenter=”0″ verticalCenter=”0″>
<s:VGroup left=”10″ right=”10″ top=”10″ bottom=”10″>
<s:Label width=”100%” color=”blue”
text=”Background Print Job Test”/>
<s:Button label=”foo” click=”printIt()”/>
<s:Button id=”submit” label=”submit” click=”submitJob()” visible=”false”/>
<s:List id=”list”>
<s:dataProvider>
<s:ArrayList source=”[1, 2, 3, 4]” />
</s:dataProvider>
</s:List>
<mx:SWFLoader id=”swfldr” complete=”imageComplete()” />
</s:VGroup>
</s:Panel>
</s:Application
|||
Thanks… the test case worked for me! I can print the panel with the image.
Let me try to implement this approach in my application where I have a DataGroup and the DataGroup’s renderer has RichText. I’ll need to figure out how to determine when images in the RichText’s textFlow are loaded.
|||
I could successfully implement your approach in my sample but now I’m struggling to implement it in my main application that requires multipage printing involving PrintDataGrid control.
In multipage printing, you check if the printDataGrid has validNextPage and if so call nextPage method on it, do validateNow and add it to the print job.
Since adding to the print job is a manual process (upon button click), the user will have to click on the button to add each page to the print job that has already started? I implemented timer and adding to the print job in the TimerEvent.TIMER event handler. This approach actually sends the page to the printer but also throws Error: Error #2057: The page could not be added to the print job.
Any suggestions on how to make the approach work in multipage printing situation?
Thanks a lot
|||
Here’s a version that uses a timer instead of a button and submits two pages.
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:comps="comps.*"
>
<!--<fx:Style source="Accessibility.css" />-->
<s:layout>
<s:VerticalLayout paddingLeft="20" paddingRight="20"
paddingTop="20" paddingBottom="20"></s:VerticalLayout>
</s:layout>
<s:controlBarContent>
<s:Label id="sdkVer" initialize="sdkVer.text = mx_internal::VERSION;"></s:Label>
</s:controlBarContent>
<fx:Script>
<![CDATA[
import mx.printing.FlexPrintJob;
private var pj:FlexPrintJob;
private function printIt():void
{
pj = new FlexPrintJob();
if (pj.start())
{
swfldr.source = "umbrellas.jpg";
}
}
private function imageComplete():void
{
setTimeout(submitPage1, 2000);
}
private function submitPage1():void
{
pj.addObject(pnl);
lbl.text = "This is page 2";
setTimeout(submitPage2, 2000);
}
private function submitPage2():void
{
pj.addObject(pnl);
pj.send();
}
\]\]\>
</fx:Script>
<s:Panel id="pnl" title="Print in Background Test"
width="75%" height="100%"
horizontalCenter="0" verticalCenter="0">
<s:VGroup left="10" right="10" top="10" bottom="10">
<s:Label id="lbl" width="100%" color="blue"
text="Background Print Job Test"></s:Label>
<s:Button label="foo" click="printIt()"></s:Button>
<s:List id="list">
<s:dataProvider>
<s:ArrayList source="[1, 2, 3, 4]"></s:ArrayList>
</s:dataProvider>
</s:List>
<mx:SWFLoader id="swfldr" complete="imageComplete()"></mx:SWFLoader>
</s:VGroup>
</s:Panel>
</s:Application>
|||
Thank you very much… the suggestion really helped me and I’m very close to finally solving it!
I took your approach and implemented in my test case that has PrintDataGrid with variable number of rows. The test case application prints all the pages except for the last one and on statement printJob.addObject(thePrintView); for the last page, throws the following error:
You can compare the sr no on the screen and the printout to confirm that the last page is not printed.
Error: Error #2057: The page could not be added to the print job.
at Error$/throwError()
at flash.printing::PrintJob/addPage()
at mx.printing::FlexPrintJob/addObject()[E:\dev\4.5.1\frameworks\project s\framework\src\mx\printing\FlexPrintJob.as:438]
at PrintImages/doPrintMultiple()[C:\projects\PrintImages\src\PrintImages .mxml:108]
at Function/http://adobe.com/AS3/2006/builtin::apply()
at SetIntervalTimer/onTimer()
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()
I’m pasted the test case code below that will allow you to recreate this error condition.
Could you please try out the test case and let me know if there is issue with the way I’m implementing it or it’s a Flex bug?
PrintImages.mxml
=================
<?xml version=”1.0″ encoding=”utf-8″?>
<s:Application
xmlns:fx=”http://ns.adobe.com/mxml/2009”
xmlns:s=”library://ns.adobe.com/flex/spark”
xmlns:mx=”library://ns.adobe.com/flex/mx”
minWidth=”955″ minHeight=”600″
initialize=”initData();”
viewSourceURL=”srcview/index.html”
>
<s:layout>
<s:VerticalLayout
paddingLeft=”20″ paddingRight=”20″
paddingTop=”20″ paddingBottom=”20″
/>
</s:layout>
<fx:Declarations>
</fx:Declarations>
<mx:DataGrid id=”myDataGrid” dataProvider=”{dgProvider}”>
<mx:columns>
<mx:DataGridColumn
dataField=”srNo”
/>
<mx:DataGridColumn>
<mx:itemRenderer>
<fx:Component>
<mx:Image height=”49″ source=”assets/images/formula.gif”/>
</fx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
<mx:Button
id=”startDG”
label=”Start”
click=”doStart();”
/>
<fx:Script>
<![CDATA[
import flash.utils.setTimeout;
import mx.collections.ArrayCollection;
import mx.printing.*;
import mx.utils.OnDemandEventDispatcher;
[Bindable]
public var dgProvider:ArrayCollection;
public var dgProviderPrint:ArrayCollection;
public var printJob:FlexPrintJob;
public var thePrintView:FormPrintView;
public var timer:Timer = new Timer(5000);
public var lastPage:Boolean;
public function initData():void {
dgProvider = new ArrayCollection();
dgProviderPrint = new ArrayCollection();
for (var z:int=0; z<25; z++) {
var row:Object = new Object();
row.srNo = z+1;
var title:Object = new Object();
title.srNo = z+1;
title.titleText =
“<TextFlow whiteSpaceCollapse=’preserve’ xmlns=’http://ns.adobe.com/textLayout/2008‘>” +
“<img width=’53′ height=’49′ source=’assets/images/formula.gif’/>” +
“</TextFlow>”;
dgProvider.addItem(row);
dgProviderPrint.addItem(title);
}
}
public function doStart():void {
printJob = new FlexPrintJob();
lastPage = false;
if (printJob.start()) {
thePrintView = new FormPrintView();
addElement(thePrintView);
thePrintView.width=printJob.pageWidth;
thePrintView.height=printJob.pageHeight;
thePrintView.printDataGrid.dataProvider = dgProviderPrint;
thePrintView.showPage(“single”);
if(!thePrintView.printDataGrid.validNextPage) {
setTimeout(doPrintSingle, 1000);
} else {
thePrintView.showPage(“first”);
setTimeout(doPrintMultiple, 1000);
}
}
}
public function doPrintSingle():void {
printJob.addObject(thePrintView);
removeElement(thePrintView);
printJob.send();
}
public function doPrintMultiple():void {
printJob.addObject(thePrintView);
thePrintView.printDataGrid.nextPage();
thePrintView.showPage(“last”);
if(!thePrintView.printDataGrid.validNextPage) {
setTimeout(doPrintMultiple, 1000);
lastPage = true;
} else {
thePrintView.showPage(“middle”);
setTimeout(doPrintMultiple, 1000);
}
if (lastPage) {
removeElement(thePrintView);
printJob.send();
}
}
]]>
</fx:Script>
</s:Application>
FormPrintView.mxml
===============
<?xml version=”1.0″?>
<mx:VBox
xmlns:fx=”http://ns.adobe.com/mxml/2009“
xmlns:s=”library://ns.adobe.com/flex/spark”
xmlns:mx=”library://ns.adobe.com/flex/mx”
xmlns:MyComp=”myComponents.*”
backgroundColor=”#FFFFFF”
paddingTop=”50″ paddingBottom=”50″ paddingLeft=”50″
>
<fx:Script>
<![CDATA[
import mx.core.*
public function showPage(pageType:String):void {
validateNow();
}
]]>
</fx:Script>
<mx:PrintDataGrid
id=”printDataGrid”
width=”60%”
height=”100%”
showHeaders=”false”
borderVisible=”false”
horizontalGridLines=”false”
variableRowHeight=”true”
>
<mx:columns>
<mx:DataGridColumn
itemRenderer=”MyPrintRenderer”
/>
</mx:columns>
</mx:PrintDataGrid>
</mx:VBox>
MyPrintRenderer.mxml
=================
<?xml version=”1.0″ encoding=”utf-8″?>
<s:MXDataGridItemRenderer
xmlns:fx=”http://ns.adobe.com/mxml/2009”
xmlns:s=”library://ns.adobe.com/flex/spark”
xmlns:mx=”library://ns.adobe.com/flex/mx”
xmlns:bslns=”com.knownomy.bsl.view.component.*”
>
<s:layout>
<s:VerticalLayout
paddingLeft=”5″
paddingRight=”5″
paddingTop=”3″
paddingBottom=”3″
gap=”5″
horizontalAlign=”left”
clipAndEnableScrolling=”true”
/>
</s:layout>
<fx:Declarations>
</fx:Declarations>
<s:HGroup
width=”100%”
gap=”5″
verticalAlign=”middle”
>
<s:Label
text=”{data.srNo}”
color=”0×000000″
fontFamily=”Verdana”
fontSize=”10″
/>
<s:RichText
id=”title”
width=”700″
textFlow=”{myTextFlow}”
color=”0×000000″
fontFamily=”Verdana”
fontSize=”10″
/>
</s:HGroup>
<fx:Metadata>
</fx:Metadata>
<s:states>
<s:State name=”normal” />
<s:State name=”hovered” />
<s:State name=”selected” />
</s:states>
<fx:Script>
<![CDATA[
import flashx.textLayout.conversion.TextConverter;
import flashx.textLayout.elements.TextFlow;
import mx.controls.Alert;
import mx.core.FlexGlobals;
import mx.events.CloseEvent;
import spark.utils.TextFlowUtil;
[Bindable]
private var myTextFlow:TextFlow;
override public function set data(value:Object) : void {
if (value != null) {
super.data = value;
// generate textflows from the text
myTextFlow =
TextConverter.importToFlow(
data.titleText,
TextConverter.TEXT_LAYOUT_FORMAT
);
}
}
]]>
</fx:Script>
</s:MXDataGridItemRenderer>
|||
The documentation states that you have to get a page added every 15 seconds.
I would not recommend using setTimeout in a production application. You want to use events.
|||
I tested the code with 15 second timeout and it still throws the same error.
If I were to use events instead of setTimeout, what events can I use? The images are loaded via RichText’s textFlow that’s in PrintDataGrid’s renderer. Also, since PrintDataGrid has variable number of rows, I wouldn’t know how many row (renderers) are there in a page being printed!
|||
I’m not sure what your first sentence meant. If you take over 15 seconds, you will get such an error. The question is whether the last page is taking more than 15 seconds from the prior page.
I believe there are events from the TextFlow elements when images load.
|||
After struggling for 4+ days on using timer / events for printing PrintDataGrid with embedded images in RichText’s textFlow, I tried your other suggestion… to convert <img> tags to InlineGraphicElement and give it Bitmap from image loaded from a .gif file. The approach works but the printout skips images in a few rows!
I’ve this test case in which, every time I print, it skips printing image in the second row! I also implemented this approach in a more complex test case and depending on the total number of rows, it would skip printing image in different number of rows. I’m suspecting that even if you construct InlineGraphicElement from bitmap loaded from an image, PrintDataGrid’s renderer still skips printing image intermittently.
I would very much appreciate it if you could create small project from my following code and verify this behavior. I’m at my wit’s end in getting this printing to work.
PrintImagesTest.mxml
=================
<?xml version=”1.0″ encoding=”utf-8″?>
<s:Application
xmlns:fx=”http://ns.adobe.com/mxml/2009”
xmlns:s=”library://ns.adobe.com/flex/spark”
xmlns:mx=”library://ns.adobe.com/flex/mx”
minWidth=”955″ minHeight=”600″
initialize=”initData();”
viewSourceURL=”srcview/index.html”
>
<s:layout>
<s:VerticalLayout
paddingLeft=”20″ paddingRight=”20″
paddingTop=”20″ paddingBottom=”20″
/>
</s:layout>
<mx:Button
label=”Print”
click=”printClickHandler();”
/>
<fx:Script>
<![CDATA[
import flash.utils.setTimeout;
import flashx.textLayout.elements.InlineGraphicElement;
import flashx.textLayout.elements.ParagraphElement;
import flashx.textLayout.elements.SpanElement;
import flashx.textLayout.elements.TextFlow;
import mx.collections.ArrayCollection;
import mx.printing.*;
import mx.utils.OnDemandEventDispatcher;
public var contentData:ArrayCollection;
private var embeddedImages:ArrayCollection;
private var numberOfImagesLoaded:int;
public var printJob:FlexPrintJob;
public var thePrintView:FormPrintView;
public var lastPage:Boolean;
private var textFlowNS:Namespace = new Namespace("http://ns.adobe.com/textLayout/2008");
public function initData():void {
contentData = new ArrayCollection();
var page:int = 0;
for (var z:int=0; z<20; z++) {
var content:Object = new Object();
content.srNo = z+1;
content.contentText =
"<TextFlow whiteSpaceCollapse='preserve' xmlns='http://ns.adobe.com/textLayout/2008'>" +
"<span>some text</span>" +
"<img width='53' height='49' source='assets/images/formula.gif'/>" +
"</TextFlow>";
contentData.addItem(content);
}
}
public function printClickHandler():void {
convertToTextFlow();
}
private function convertToTextFlow():void {
embeddedImages = new ArrayCollection();
numberOfImagesLoaded = 0;
for each (var contentElement:Object in contentData) {
extractImageInfo(contentElement.contentText);
}
if (embeddedImages.length > 0) {
loadImage(embeddedImages.getItemAt(0).source);
} else {
printData();
}
}
private function extractImageInfo(contentText:String):void {
var textXml:XML = new XML(contentText);
var imageList:XMLList = textXml.textFlowNS::img;
for each (var img:XML in imageList) {
var embeddedImage:Object = new Object();
embeddedImage.source = String(img.@source);
embeddedImage.width = parseInt(img.@width);
embeddedImage.height = parseInt(img.@height);
embeddedImages.addItem(embeddedImage);
}
}
private function loadImage(imageSource:String):void {
var loader:Loader = new Loader();
var urlRequest:URLRequest = new URLRequest(imageSource);
loader.load(urlRequest);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
}
private function imageLoaded(e:Event):void {
embeddedImages.getItemAt(numberOfImagesLoaded).bitmap = (Bitmap)(e.target.content);
embeddedImages.getItemAt(numberOfImagesLoaded).width = ((Bitmap)(e.target.content)).width;
embeddedImages.getItemAt(numberOfImagesLoaded).height = ((Bitmap)(e.target.content)).height;
++numberOfImagesLoaded;
if (numberOfImagesLoaded < embeddedImages.length) {
loadImage(embeddedImages.getItemAt(numberOfImagesLoaded).source);
} else {
// all the images have been loaded... convert to textflow
buildContent();
printData();
}
}
private function buildContent():void {
var contentIndex:int = 0;
for each (var contentElement:Object in contentData) {
if (hasImage(contentElement.contentText)) {
buildTextFlow(contentElement, contentIndex);
++contentIndex;
}
}
}
private function buildTextFlow(content:Object, contentIndex:int):void {
var textXml:XML = new XML(content.contentText);
var p:ParagraphElement = new ParagraphElement();
for each(var child:XML in textXml.children()) {
switch (child.localName()) {
case "span":
var span:SpanElement;
span = new SpanElement();
span.text = child;
span.fontSize = 10;
p.addChild(span);
break;
case "img":
var image:InlineGraphicElement;
image = new InlineGraphicElement();
image.source = embeddedImages.getItemAt(contentIndex).bitmap;
image.width = embeddedImages.getItemAt(contentIndex).width;
image.height = embeddedImages.getItemAt(contentIndex).height;
p.addChild(image);
break;
}
}
content.textFlow = new TextFlow();
content.textFlow.addChild(p);
}
private function hasImage(contentText:String):Boolean {
var textXml:XML = new XML(contentText);
var imageList:XMLList = textXml.textFlowNS::img;
if (imageList.length() > 0) {
return true;
} else {
return false;
}
}
private function printData():void {
printJob = new FlexPrintJob();
lastPage = false;
if (printJob.start()) {
thePrintView = new FormPrintView();
addElement(thePrintView);
thePrintView.width=printJob.pageWidth;
thePrintView.height=printJob.pageHeight;
thePrintView.printDataGrid.dataProvider = contentData;
thePrintView.showPage("single");
if(!thePrintView.printDataGrid.validNextPage) {
printJob.addObject(thePrintView);
} else {
thePrintView.showPage("first");
printJob.addObject(thePrintView);
while (true) {
thePrintView.printDataGrid.nextPage();
thePrintView.showPage("last");
if(!thePrintView.printDataGrid.validNextPage) {
printJob.addObject(thePrintView);
break;
} else {
thePrintView.showPage("middle");
printJob.addObject(thePrintView);
}
}
}
removeElement(thePrintView);
}
printJob.send();
}
]]>
</fx:Script>
</s:Application>
FormPrintView.mxml
===============
<?xml version=”1.0″?>
<mx:VBox
xmlns:fx=”http://ns.adobe.com/mxml/2009“
xmlns:s=”library://ns.adobe.com/flex/spark”
xmlns:mx=”library://ns.adobe.com/flex/mx”
xmlns:MyComp=”myComponents.*”
backgroundColor=”#FFFFFF”
paddingTop=”50″ paddingBottom=”50″ paddingLeft=”50″
>
<fx:Script>
<![CDATA[
import mx.core.*
public function showPage(pageType:String):void {
validateNow();
}
]]>
</fx:Script>
<mx:PrintDataGrid
id=”printDataGrid”
width=”60%”
height=”100%”
showHeaders=”false”
borderVisible=”false”
horizontalGridLines=”false”
variableRowHeight=”true”
>
<mx:columns>
<mx:DataGridColumn
itemRenderer=”MyPrintRenderer”
/>
</mx:columns>
</mx:PrintDataGrid>
</mx:VBox>
MyPrintRenderer.mxml
=================
<?xml version=”1.0″ encoding=”utf-8″?>
<s:MXDataGridItemRenderer
xmlns:fx=”http://ns.adobe.com/mxml/2009”
xmlns:s=”library://ns.adobe.com/flex/spark”
xmlns:mx=”library://ns.adobe.com/flex/mx”
xmlns:bslns=”com.knownomy.bsl.view.component.*”
>
<s:layout>
<s:VerticalLayout
paddingLeft=”5″
paddingRight=”5″
paddingTop=”3″
paddingBottom=”3″
gap=”5″
horizontalAlign=”left”
clipAndEnableScrolling=”true”
/>
</s:layout>
<fx:Declarations>
</fx:Declarations>
<s:HGroup
width=”100%”
gap=”5″
verticalAlign=”middle”
>
<s:Label
text=”{data.srNo}”
color=”0×000000″
fontFamily=”Verdana”
fontSize=”10″
/>
<s:RichText
id=”title”
width=”700″
textFlow=”{myTextFlow}”
color=”0×000000″
fontFamily=”Verdana”
fontSize=”10″
/>
</s:HGroup>
<fx:Metadata>
</fx:Metadata>
<s:states>
<s:State name=”normal” />
<s:State name=”hovered” />
<s:State name=”selected” />
</s:states>
<fx:Script>
<![CDATA[
import flashx.textLayout.elements.TextFlow;
[Bindable]
private var myTextFlow:TextFlow;
override public function set data(value:Object) : void {
if (value != null) {
super.data = value;
myTextFlow = data.textFlow;
}
}
]]>
</fx:Script>
</s:MXDataGridItemRenderer>
|||
I’ve hosted this test case on my server and since it’s a domian based URL, I’m hoping that you’ll be able to view the application.
http://www.blueskylearning.com/printImages/PrintImagesTest.html
When I access the URL and click on Print button, it prints 2 pages and on each page, it skips image in row 2.
I’ve turned View Source on.
|||
Here is one more test case with ‘better’ data:
http://www.blueskylearning.com/printMoreImages/PrintImages.html
Even in this test case, when I access the URL and click on Print button, it prints 2 pages and on each page, it skips image in row 2.
I’ve turned View Source on.
|||
Not sure when I’ll have time to dig in, but a quick look says you are not copying the bitmap so if a bitmap is used in more than one row it won’t show in all of them.
|||
I have an even simpler example to bring out this issue that I’ve been encountering.
Go to http://www.blueskylearning.com/printBitmaps/PrintBitmaps.html
and click on Print button.
You’ll see that bitmap in the second row is missing!
This example simply constructs InlineGraphicElement from a filled circle and uses it along with some static text to build TextFlow.
PrintDataGrid DataGridColumn’s renderer prints the TextFlow and when doing so, skips what’s in InlineGraphicElement in the second row of the PrintDataGrid.
The behavior looks like a bug to me.
|||
Did you verify you are copying and not re-using bitmaps?
|||
InlineGraphicElement object is recreated in the loop and the Sprite object that’s the source of InlineGraphicElement object is also recreated in the loop.
|||
Hi Flex harUI,
Any suggestion on how to resolve this issue? I’m inclined to file this as a bug so that it gets looked into. In my experience, display as well as printing TextFlow with embedded images via renderers has issues / bugs and need to be addressed.
|||
I think it is a bug in the TLF library. You can file a bug if you want, but they usually don’t like large Flex test cases. I’m hoping to find time to pare it down to basics and maybe find a workaround.
|||
I finally got a chance to look into this some more. I’m pretty sure it isn’t a bug per-se. The issue is that the data items are can be assigned to more than one renderer. There is a hidden renderer used to measure renderers and I’m pretty sure it is stealing the icon from that one row. PrintDataGrid basically can’t handle display objects in the data items. I’ll see if I can find time to find a workaround.
-Alex
|||
Workaround is just fine… anything to make this work!
In the meanwhile, I’ve switched to iText to generate PDF documents users of my web application need to generate.
|||
I spent a couple of hours on a workaround and gave up. There is no good way to control the recycling and re-use of renderers and in this case, when the TextFlow gets rendered.
So, the only way I can get it to work is to clone or generate the TextFlow in the renderer. Hope that helps.
-Alex
|||
I made changes to my program where I generate bitmaps from images in advance. In the renderer, I create InlineGraphicElement from the bitmap and use it to create paragraph and textflow for the RichText element. Even this produces unpredictable result. In various runs of the application, different images are missing from the printout.
I’ve tried most of the possible approaches but it looks like printing complex data that involve textflow and embedded images doesn’t seem to be possible with the current version of Flex SDK (4.5.1). In my opinion, it needs to be looked into because this is a significant hurdle in the use of Text Layout Framework in an application that needs to generate printout.
|||
Please file a bug with your test case. Basically, the only robust solution for now would be to generate the textflow and its objects on the fly in each renderer. You cannot cache them in the dataprovider.
|||
Bug #SDK-31893
Related posts:
- PrintDataGrid’s DataGridColumn – Embedded image not printing when you use TextFlow in the item rende
- PrintDataGrid’s DataGridColumn – Embedded image not printing when you use TextFlow in the item rende
- Printing PDFs to PDF Very Slow
- Adobe Reader 9 printing issue
- Datagrid colum item renderer HELP!!!!!
Related posts brought to you by Yet Another Related Posts Plugin.