Should I use PurePDF or AlivePdf - apache-flex

My company has only two flex pdf libraries available, AlivePDF and PurePDF.
I am having trouble finding very good documentation related to what I need to do so I hope to get some feedback from people who have used these libs.
The primary thing I need to do is paste a group of DisplayObjects into a pdf, with decent quality of the image. I had used org.alivepdf.pdf.PDF.addImage(..) function before but the image quality was very poor and somehow the process cropped off parts of the image, making it unusable.
Here is an example of something that might need to be pasted into a pdf:
<s:HGroup id="imageGroup">
<s:Label text="Chart Title" />
<mx:Legend dataProvider="myChart" />
<mx:LineChart id="myChart">
<!-- do chart stuff here -->
</mx:LineChart>
</s:HGroup>

PDF.addImage() generates low resolution graphics. For higher quality, use this instead:
take a snapshot of the image group using ImageSnapshot.captureImage(), setting the dpi to 300
add the resulting bytearray to the PDF using addImageStream()
I have used AlivePDF for a while. There are a few quirks and the documentation is sparse, but this is workable and the results are great.

Related

How can I use svg graphics in a responsive wordpress page and get them to behave the same way the bitmaps do?

I've been doing a little hacking with wordpress ..via the editor.
I'm placing svg images and I've installed the SVG Support plugin
https://wordpress.org/plugins/svg-support/
When I insert a regular image (a png file) the code looks like this:
<img class="alignnone wp-image-146 size-medium"
src="mydomain/2-300x246.png" alt="2" width="300" height="246" />
and then the theme I'm using scales it as the browser scales up and down, which is what I desire with the svg image.
When I insert an SVG file, it does not show up until I modify the code by taking out the first class tag and add a new class tag:
class="style-svg"
like this..
<img class="style-svg"
src="mydomain/convo_and_notes2.svg" alt="convo_and_notes" width="1" height="1" />
Maybe I need to use a different wordpress theme or modify the one I'm using.. but first I want to know is it possible to get the same responsive behavior from an SVG file (I'm guessing it is ...but how?)
The wordpress theme I'm using is Flat by YoArts if that's helpful information.
Sorry if this is not the right way to phrase this question.. I'm not sure what I'm doing so it's hard to know what to ask.
In a nutshell, I want the SVG files to behave like the bitmaps and would love some advice on how to do that.
The wordpress uploader adds
height="1" wudth="1"
remove that and add
width="300px"
or something like that.
also to keep the responsive behavior don't remove the
class=""alignnone wp-image-146 size-medium"
that's it. The height and width were causing the problem.

Display HTML text in the Adobe Air Label

I am trying to display HTML text inside the Label in my Adobe Air mobile application, so far
I realized that Label doesn't support HTML, I went through the few solutions I found so far on the web:
Instead of Label - User TextArea and then use:
StyleableTextField(message.textDisplay).htmlText = messageText;
and in the TextArea declaration - specify mobile skin
<s:TextArea editable="false" selectable="false" skinClass="spark.skins.mobile.TextAreaSkin" id="message" x="0" y="0" width="100%" height="100%" paddingLeft="5" paddingRight="5" textAlign="left"/>
First of all, HTML still doesn't work, instead of converted HTML it just shows me ..... garbage, but even if it would have worked - TextArea component looks different than Label and doesn't feet in the design I am implementing.
User RichText component - unfortunately it's not supported in mobile apps
Any other ideas?
Yes, HTML is not supported in the Label and TextArea components for Spark (it was supported in Halo, or the mx components).
The only Flex components that officially do support it are RichText and RichEditableText. The skins for these components are not mobile optimized, but they run on mobile just fine. You may run into some speed issues when using massive amounts of it, but you can still use them (as you can with most, if not all, other components that aren't mobile optimized).

Loss of image quality when zooming in Flex Mobile application

i have a mobile application that i am creating in Adobe Flex (Flash Builder 4), and i am trying to create a zoom function. The one i have works, but the point is to be able to more easily read words that are in the image (the images are .jpg files). The images are 2550x3300 originally, but as soon as you zoom, the image quality reduces drastically, and nothing is readable.
My code for the zoom function is included below.
protected function onZoom(e:TransformGestureEvent, img:Image):void
{
img.transformAround(new Vector3D(e.localX, e.localY, 0), new Vector3D(img.scaleX*e.scaleX, img.scaleY*e.scaleY, 0));
}
and this is the code for the image object:
<s:Image id="titlepage" includeIn="title_page" x="0" y="0" width="320" height="415"
gesturePan="onPan(event, titlepage)"
gestureSwipe="onSwipe(event)"
gestureZoom="onZoom(event, titlepage)"
source="#Embed('assets/myImage.jpg')"/>
Image quality would be improved by setting smooth to true for anti-aliasing.
<s:Image smooth="true" />
There are many ways to handle registration issues - you might be interested in Yahoo Astra utils DynamicRegistration class.
Maybe something like this?
<fx:Script>
<![CDATA[
import com.yahoo.astra.utils.DynamicRegistration;
protected function image_gestureZoomHandler(event:TransformGestureEvent):void
{
DynamicRegistration.scale(image,
new Point(event.localX, event.localY),
image.scaleX *= event.scaleX,
image.scaleY *= event.scaleY);
}
]]>
</fx:Script>
<s:Image id="image"
smooth="true"
gestureZoom="image_gestureZoomHandler(event)" />
I'm not positive on this, but I think the 'transform' functions creates a bitmap out of your Image which is why you're losing quality. Try using the 'smoothing' attribute on your image.
From there, it's simply scaling and moving your image incrementally. However, what I'm not sure about is if the localX/Y property is from the original place of touch, or of the new position on the container (ie. if you're pinch/zooming from the middle and it scales, will the point still be on the middle or slightly top left).
I'll try to test this out on my phone and see what I come up with.

Flex UI Inconsistencies

I am having some issue with consistency across different machines with my flex application.
There are three things that I have noticed with my application. On my development machine (Windows XP) I can not reproduce these issues.
I have noticed them on a Windows Vista machine as well as a Windows 7 machine.
The three things that I have found are:
Label's will be truncated with '...'
Tabs in a tab navigator will be truncated with a '...'
Some Images will be rendered with an inconsistent width and height
My labels are defined pretty simply
<mx:Label x="261" y="15" text="Date Prepared" fontWeight="bold" width="113"/>
Tabs are custom components but defined in a pretty standard format:
<mx:TabNavigator borderStyle="solid"
x="10" y="10" width="665" height="450" id="tabs" creationPolicy="all">
<local:FormPanel id="formPanel" name="formPanel"
label="Incident Details "
width="665" height="450"/>
</mx:TabNavigator>
You may notice extra white space following the label in the custom FormPanel, I have found that this might help solve a subset of the truncation issues (not 100% sure).
As for my images, again, I am not doing anything to amazing:
<mx:Image id="vehicle_image"
source="#Embed(source='../../../../../images/icons/basic/vehicles.swf')"
height="45" width="45" toolTip="Vehicles"
toolTipShow="handleToolTipShow(event)"
click="showBar(event, vehicle_bar)" enabled="true" x="47" y="0"/>
The image is contained in a canvas and I will have about 10 of these images all sized 45x45. On certain machines I will see 3 of the 10 images rendered smaller what would appear about 30x30 relative to the other 45x45 sized images.
The problem I am having is that I can not reproduce these issues on my development machine, and do not have any clue on how to fix these issues. I would expect that the things I am seeing are bugs in the FlexSDK, but even if they are bugs I do need a temporary work around.
Any ideas?
For some reason it won't let me add a comment, but..
This sounds a lot like some of the changes (CSS fixes) put in from Flex 2 to 3 (maybe 3 to 4 as well?) (Button components can do this too if the width is a fixed size.)
Are you absolutely sure that your development machine is running the same version of the app as the others? If you're using Flex/Flash Builder's "run" functionality to run on the dev machine, but building and deploying with Flex Ant tasks or some kind of separate build for the others, it's possible to have this happen by using different SDKs even though the code hasn't been changed at all.

How to bind Flex Effects to the effects target properties?

I'm trying to reuse effects. To achieve this, i was hoping that i could bind some of the effect's properties to the effect's target. Here's what i wanted to do:
<mx:transitions>
<mx:Transition toState="Ready">
<mx:Parallel targets="{[b1, b2, b3]}" perElementOffset="200" duration="500">
<mx:Move xFrom="{target.x-100}" xBy="100">
<!-- possibly a fade effect too -->
</mx:Parellel>
</mx:Transition>
</mx:transitions>
<mx:VBox>
<mx:Button id="b1"/>
<mx:Button id="b2"/>
<mx:Button id="b3"/>
</mx:VBox>
The above code assumes, a state change on application createComplete to Ready state.
In my futile attempt with the above code, i tried to create 1 effect that would animate the entrance of 3 buttons all laid out using VBox. I'm (trying to) avoiding 2 things:
Absolute layout hence hand coded coordinates. I want to exploit the containers.
Effect code duplication
Results:
- Compiler complains target is not defined. I've tried to put whole list of ideas into that field but to no avail. I've tried:
{this.target.x}
{effectId.target.x}
{propertyThatReturnsTheObject.x}
Can this be done? Thanks in advance.
if you give the Move Effect an id, can you bind to {moveId.target}. Its not clear that your second case is it...
I suspect the compiler is looking for target in a different scope to the one you think it is...
Certainly, target isn't a bindable attribute, so this may be academic anyway.

Resources