Converting Flex Graphs to PDF/JPEG

We'd love to use Flex in our application. However, we would
need a way to convert Flash components (or an entire SWF) to a
PDF/JPEG.
We've created a Flex application that allows users to create
their own charts and we will even have the ability to generate a
simple SWF file for each chart (using the command line compiler).
Is there a way (or any ideas about a possible way) to do
*any* of these things? --
- Convert a static SWF file to PDF
- Convert a static SWF file to JPEG/PNG/TIF/ETC
- Grab a 'screenshot' of a Flex Component
- Anything else that would do the job
I've looked around for a product that would do any of the
above, but I can't find anything that could be accessed
programmatically (i.e. called via a script).

The answer is yes. Here is a thread that should answer your
question. I
updated the PNGEncoder.as to compile with Beta3. However, I
have not tested
that it works in Beta3.
Original Question:
Specifically we need to export a bitmap (in any format,
preferably PNG, but
jpg or GIF will do) from the application. These bitmaps
should be pixel
perfect replicas of chart controls within the application. We
were
originally told that this was not possible in Flex 1.5. It
appears however
that in Flex 2.0, the BitmapData class of the Flash 8 player
is now exposed,
and with a little research it seems like we should be able to
use it to
access a Flex chart, pixel by pixel and send the data back to
the server for
rendering as an image file.
So I have a couple questions:
1.. Is the approach I have outlined above workable?
2.. Does this approach require Flex 2.0?
3.. Is there a better way of exporting a bitmap image of a
Flex control?
Response:
1) You don't need to pull the data pixel by pixel. You can
create a
BitmapData, draw() the chart into the bitmap, and ask for its
bits as a
bytearray.
2) Your best bet is to compress the bitmapData into a PNG and
send that to
the server. The server does nothing but turn around and send
it right back
in the response with the appropriate headers to trigger the
browser to pop
up a save dialog.
3) I've attached some prototype code I wrote a while back to
turn a Bitmap
into a PNG. It was written against a pre-alpha build, so it
will need some
work. It's also not fully functional I think. Specifically, I
know that when
the size of the image crosses a boundary you need to split it
up into chunks
as you write it out into the file, which this code isn't
doing. THere may be
other problems too.
4) Yes, this only works in Flex 2.
PNGEncoder.as:
package {
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
import flash.net.*;
public class PNGEncoder {
private var _png:ByteArray;
public function encode(img:BitmapData):ByteArray
var imgWidth:uint = img.width;
var imgHeight:uint = img.height;
var imgData:ByteArray = img.getPixels(new
Rectangle(0,0,imgWidth,imgHeight));
_png = new ByteArray();
_png.writeByte(137);
_png.writeByte(80);
_png.writeByte(78);
_png.writeByte(71);
_png.writeByte(13);
_png.writeByte(10);
_png.writeByte(26);
_png.writeByte(10);
var IHDR:ByteArray = new ByteArray();
IHDR.writeInt(imgWidth);
IHDR.writeInt(imgHeight);
IHDR.writeByte(8); // color depth: 8 bpp
IHDR.writeByte(6); // color type: RGBA
IHDR.writeByte(0); // compression: ZLIB
IHDR.writeByte(0); // filter method
IHDR.writeByte(0); // not interlaced;
writeChunk([0x49,0x48,0x44,0x52],IHDR);
var IDAT:ByteArray= new ByteArray();
for(var i:uint=0;i<imgHeight;i++) {
IDAT.writeByte(0);
for(var j:uint=0;j<imgWidth;j++) {
var p:uint = img.getPixel32(j,i);
IDAT.writeByte((p>>16)&0xFF);
IDAT.writeByte((p>> 8)&0xFF);
IDAT.writeByte((p )&0xFF);
IDAT.writeByte((p>>24)&0xFF);
IDAT.compress();
writeChunk([0x49,0x44,0x41,0x54],IDAT);
writeChunk([0x49,0x45,0x4E,0x44],null);
return _png;
public function dump():String
_png.position = 0;
var out:String ="";
for(var i:uint=0;i<_png.length;i++) {
var code:String = "0123456789abcdef";
var v:uint = _png.readUnsignedByte();
out += code.charAt((v & 0xF0) >> 4);
out += code.charAt(v & 0xF);
out += " ";
return out;
private function writeChunk(type:Array,data:ByteArray):void
var len:uint = 0;
if(data != null)
len = data.length; // data length
_png.writeUnsignedInt(len);
var p:uint = _png.position;
_png.writeByte(type[0]);
_png.writeByte(type[1]);
_png.writeByte(type[2]);
_png.writeByte(type[3]);
if(data != null)
_png.writeBytes(data);
var endP:uint = _png.position;
_png.position = p;
var c:uint = crc(_png,endP-p);
_png.position = endP;
_png.writeUnsignedInt(c);
/* Table of CRCs of all 8-bit messages. */
private static var crc_table:Array;
/* Flag: has the table been computed? Initially false. */
private static var crc_table_computed:Boolean = false;
/* Make the table for a fast CRC. */
private function make_crc_table():void
var c:uint;
var n:int;
var k:int;
crc_table = [];
for (n = 0; n < 256; n++) {
c = n;
for (k = 0; k < 8; k++) {
if (c & 1)
c = uint(uint(0xedb88320) ^ uint(c >>> 1));
else
c = uint(c >>> 1);
crc_table[n] = c;
crc_table_computed = true;
/* Update a running CRC with the bytes buf[0..len-1]--the
CRC
should be initialized to all 1's, and the transmitted value
is the 1's complement of the final running CRC (see the
crc() routine below)). */
private function update_crc(crc:uint, buf:ByteArray,
len:uint):uint
var c:uint = crc;
var n:int;
var v:uint;
if (!crc_table_computed)
make_crc_table();
for (n = 0; n < len; n++) {
v = buf.readUnsignedByte();
c = uint(crc_table[(c ^ v) & uint(0xff)] ^ uint(c
>>> 8));
return c;
/* Return the CRC of the bytes buf[0..len-1]. */
private function crc(buf:ByteArray, len:uint):uint
var cc:uint = update_crc(uint(0xffffffff), buf, len);
return uint(cc ^ uint(0xffffffff));
Jason Szeto
Adobe Flex SDK Developer
"jeb1138" <[email protected]> wrote in
message
news:[email protected]...
> We'd love to use Flex in our application. However, we
would need a way to
> convert some resulting Flash components (or an entire
SWF) to a PDF/JPEG.
>
> We've created a Flex application that allows users to
create their own
> charts
> and we will even have the ability to generate a simple
SWF file for each
> chart
> (using the command line compiler).
>
> Is there a way (or any ideas about a possible way) to do
*any* of these
> things? --
> - Convert a static SWF file to PDF
> - Convert a static SWF file to JPEG/PNG/TIF/ETC
> - Grab a 'screenshot' of a Flex Component
> - Anything else that would do the job
>
> I've looked around for a product that would do any of
the above, but I
> can't
> find anything that could be accessed programmatically
(i.e. called via a
> script).
>

Similar Messages

  • Convert Flex Page To PDF

    Hai, i need to convert my flex page to PDF by on click of a
    button. No idea about this, can any one help me , with clear
    details.
    Thanks in Advance.....

    Bill,
    Thanks again for the reply.  I am using the Convert Web Page to PDF selection on the Adobe toolbar which is available in IE.  I printed the page from File >> Print and it looks good except no links.  It is also printed in a Portrait style page layout.
    Sample:
    When I used the Convert Web Page to PDF from the Adobe toolbar, it looks like it is attempting to 'print' it in a landscape mode and that may be where the problem is.
    Sample:
    These are the same report.  However, I can't find a preference to tell it to convert in a Portrait mode instead of landscape.  Any clues on how to force it to always convert Portrait?
    Thanks again,
    Gilley

  • Script for scanning  and converting  cover page of PDF to JPEG

    Hi we are building an application that would allow the upload of PDFs. We want to be able to scan and convert the cover page to jpeg for display purposes.
    Does anyone know whether there is a ready made script to do this?

    This would require a plug-in so that you could access the AVConversion methods. Unfortunately since Acrobat is not licensed for server use you would not be allowed to have this plug-in as part of an automated workflow on a server accepting uploads.

  • Border on JPEG when converted from doc to PDF

    When I convert a document to PDF some of the jpegs have a border on the left side and across the top. It has been happening for awhile, I have updated to the current reader 10.3, I am using Win 7 and Office 2007. I am able to create a pdf without the borders on another computer that is using XP and Office 2007.

    Looks like a issue of Office 2007.

  • When converting Word Doc to PDF Acrobat converts all words and tables but will not convert graphs

    When converting a word microsoft word document to PDF Acrobat converts words, tables, everything but the graphs in the document. It will not convert the graphs it leaves that area blank.

    Cvest group wrote:
    From Microsoft Office 2007 created word doc from word doc to Acrobat to Create PDF.
    This is very confusing; what actually coverted the document - Word, Acrobat, or CreatePDF (now renamed to "Adobe PDF Pack") ?
    Either way it's not an Adobe Reader problem;
    if Word: post in the Microsoft Word forum
    if Acrobat: post in the Adobe Acrobat forum
    if ExportPDF: post in the ExportPDF forum

  • How do I convert PDF/JPEG file in "Brush Script MT" font to Word Document

    How do I convert PDF/JPEG file in "Brush Script MT" font to Word Document? (I checked with Acrobat XI pro but no use

    You cannot in Adobe Reader. You can try in Acrobat, but first you must try to run OCR (Text Recognition). I have never tried OCR on a script font.

  • Multiple images are blocky when converting from powerpoint to PDF?

    Heres my problem:
    If I have a powerpoint with ONE image (be it jpeg, gif, png, etc) they apper fine when you convert the document to PDF (via print>Print to PDF or by using the Acorbat plug in in Powerpoint).
    BUT
    If I have 2 or more images in a powerpoint slide, the images appear blocky and sections of the images are missing. I tried to ungroup the photos and group the photos yet I get the same result. Anyone know how to correct this??
    The images were originally created in Adobe Illustrator. There must be a setting in Illustrator or Powerpoint that is causing this problem but I cant figure it out.
    Thanks

    Correction, it appears to be a problem with the CROP button in Powerpoint. I have a PNG file and it has two images (a map and a legend) on one png. When I crop it to only show ONE image (either the map or the legend) it makes it become blocky. So weird.

  • Legend text turns black when converting a .ppt to .pdf

    I have a picture of an Excel graph pasted into Powerpoint as an Enhance Metafile.  When I convert the .ppt to .pdf, the legend text in the graph turns into a black filled box. Can you tell me how to avoid this? Thanks!

    This isn't the proper forum for that. This is for the free Reader application which does not convert files to PDF.
    Depending on what you actually use to convert to PDF, you may need a Microsoft forum or the Adobe Acrobat forum.

  • Error from reports from ZAM(Graph or PDF) - File does not begin with '%PDF-'.

    I just noticed today that any Graph or PDF report I try to view I get the
    following error - Error from reports from ZAM - File does not begin with
    '%PDF-'. I tried to just save the file and then open it, but get the same
    error. I can open other pdf files I have downloaded from other sites ok.
    Anyone have any idea? I haven't done anything to that server that I am
    aware of in quite a while.
    Thanks
    Bill

    I took a closer look at the files it downloaded, opened them with notepad,
    haer is what it says:
    XSL Transform or subsequent processing failedThe document has no pages.
    "Bill" <[email protected]> wrote in message
    news:2bBtk.2164$[email protected]..
    >I just noticed today that any Graph or PDF report I try to view I get the
    >following error - Error from reports from ZAM - File does not begin with
    >'%PDF-'. I tried to just save the file and then open it, but get the same
    >error. I can open other pdf files I have downloaded from other sites ok.
    >Anyone have any idea? I haven't done anything to that server that I am
    >aware of in quite a while.
    >
    > Thanks
    >
    > Bill
    >

  • How to make Adobe acrobat feature to convert SAP  Pages to PDF available for multiple users connected to the same server

    We have installed Adobe Acrobat X Pro- English,Francais,Deutsch version 10.1.9 in our test environment and tried  testing it for converting SAP pages into PDF with a few pilot users. In doing so we faced a challenge, where only one user at a time can use Adobe Acrobat PRO to convert SAP pages in to PDF.As long as the first user who  is connected to Adobe Acrobat Pro via SAP isn’t logged off, other users connected to the same  server  are not being able to get the “Save As” dialog box to save the PDF in their preferred location.
    This is a business requirement and we need an urgent solution for the same. Can anyone help us in telling us if this is possible and if yes the how to go about?

    It's not something we deal with here, the LiveCycle products are a different world. Key points: Adobe LiveCycle is a range of products, some desktop, some server. LiveCycle PDF Generator is the one you should look at, it comes in 3 editions. License terms are by negotiation. Key management is via its Java API.

  • How to convert word doc into pdf - which product of adobe i need to use- what upgrades - am a newbie

    How to convert word doc into pdf - which product of adobe i need to use- what upgrades - am a newbie -  simple answers please - Thanks in advance.

    @Pipeline2007 - which version of Microsoft Office have you got? Older versions of Acrobat aren't compatible with the latest versions of Office, see this link for info:
    http://helpx.adobe.com/acrobat/kb/compatible-web-browsers-pdfmaker-applications.html

  • Is it possible to convert a DWF to PDF using a command line or batch  process. How can I see this in action?

    I need to convert DWF files to PDF. Is this possible?  Adobe able to batch them and can they be converted via a batch or scheduled process. 
    We have a team placing DWF files on a network drive.  Then we need to scoop them up and convert them. Using SSIS or a C# program we can move the converted files to an archive folder.  Is this possible to do using Adobe?

    Hi pnorm,
    Please check the 'Convert AutoCAD files in batches' section in the Doc : http://help.adobe.com/en_US/acrobat/X/pro/using/WS58a04a822e3e50102bd615109794195ff-7f35.w .html
    Regards,
    Rave

  • Why is it taking so long to convert my docx to PDF?

    It is taking a long time to convert my docx to PDF.  My docx is 74KB and contains a picture

    Hi danielc77590163,
    Did your file finish converting? If it did, you may have just run into an issue with your Internet connection/upload speed.
    If it stalled, or you received an error message, please clear the browser cache and then try again. If that fails, then we'd want to take a closer look at what's going on. Do other files convert for you? Are you converting via Adobe Reader or via the ExportPDF web interface? How was this particular PDF file created?
    Best,
    Sara

  • Error: EXOpenExport() while converting xlsb file to PDF

    I am getting this error while converting .XLSB file to PDF using IBR :Step PDFExport forced conversion failure by conversion engine because of error: EXOpenExport() failed: no filter available for this file type (0x0004). Can anyone tell me how to resolve this issue.
    Thanks in advance.

    Thank you for all your intrest.
    The error message I get is... "an unexpected error occured. PDFMaker was unable to process the request".
    When I then try to convert again, the system opens the ppt, but then does not do anything, and the error message does not show, for all presentations I try to convert.
    I have also tried using the ribbon, but the button does not do anything once I have clicked.
    I can print to PDF, but this provides an output which is not suitable, because it shows as if it each slide was printed on to paper and then put in PDF.
    I have also uninstalled and reinstalled Acrobat to make sure nothing was corrupt.

  • I know that how to convert any documents to pdf file, but don't know how to get barcode on it. I am using windows 8.1. and want to see barcode on my documents before the print. Please help.

    I know that how to convert any documents to pdf file, but don't know how to get barcode on it. I am using windows 8.1. and want to see barcode on my documents before the print. Please help.

    Hi Frank ,
    Please refer to the following link and see if this helps.
    https://helpx.adobe.com/acrobat/kb/error-organizer-database-damaged-reset-1.html
    Regards
    Sukrit Dhingra

Maybe you are looking for

  • Using Clob with TopLink 9.0.4.5 and Oracle 10g RAC

    I am trying to store an XML file in a Clob type field of a DB table using TopLink 9.0.4.5 and Oracle 10g RAC and need some guidance about how to do it. I got some directions to start it with the Tip "How-To: Map Large Objects (LOBs) to Oracle Databas

  • ITunes requires QuickTime 7.5.5 or later...

    I just udated a 10.4.11 install to 10.5.8 now when I attempt to open iTunes 10.6.1, I get this error: "itunes iTunes requires QuickTime 7.5.5 or later" Software update says everything is up to date I ran Cocktail, Repair Permissions, Repair Disk, reb

  • Call_and_receive fires 2 times?? why ??

    Hello, i have little problem with saprfc_call_and_receive(). In Firefox (2+) everything is ok. call_and_receive() fires only 1 time. BUUUUUUT with IE (6+) the same call_and_receive() fire 2 times. 1. Firing => RCODE = 0 (OK) 2. Firing => RCODE = 4 (B

  • How to block my iphone5?

    how to block my iphone5?

  • Bill during suspending

    I am an international college student in NY. I've got a mobile phone with 2 years contract last year. I paid $400 for deposit because I don't have social security number. I went back to my country for summer holiday from the end of May until August.