Charith
unread,Jan 3, 2011, 4:05:48 AM1/3/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to purepdf-discuss
Hi
I have some issue transferring PDF with a image to the sever. When the
image is not attached, it transfer correctly and PDF can be opened and
viewed with other information. Please let me know if you aware of any
clue for this issue. It just say "PDF is damage and can not be open"
when the transfer is done.
Following code I use in the client side.
// Building PDF doc
-----------------------------------------------------------------------------------------
createDocument("Testing ...");
document.open();
// code goes here
// Attaching image
-----------------------------------------------------------------------------------------
var bmp: BitmapData = ( new cls1() as Bitmap ).bitmapData;
// ---------------
// JPEG image
// ---------------
var baSource: ByteArray = bmp.getPixels( bmp.rect );
var bytes: ByteArray = jpegLib.write_jpeg_file( baSource,
bmp.width, bmp.height, 3, 2, 90 );
var image1: ImageElement = ImageElement.getInstance( bytes );
image1.alignment = ImageElement.RIGHT; // set the image alignment
image1.borderWidth = 5;
image1.borderSides = RectangleElement.LEFT | RectangleElement.TOP |
RectangleElement.RIGHT | RectangleElement.BOTTOM;
image1.borderColor = new RGBColor( 255, 255, 255 );
document.add( image1 );
// close and save the document
document.close();
// posting server
-----------------------------------------------------------------------------------------
private function doPost():void
{
buffer.position = 0;
var req:URLRequest = new URLRequest(serverURL
+"/"+uploadServletName);
req.method = URLRequestMethod.POST;
var postData:URLVariables = new URLVariables();
req.data = buffer;
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.BINARY;
// loader.addEventListener( ProgressEvent.PROGRESS, progress);
loader.addEventListener( IOErrorEvent.IO_ERROR, error_complete );
loader.addEventListener( SecurityErrorEvent.SECURITY_ERROR,
error_complete );
loader.addEventListener( Event.COMPLETE, loader_complete );
loader.load( req );
Alert.show("Your file is being created. It will open as soon as its
done ...");
}
Thanks in Advance.
Charith