NishilSB / alivepdf

Automatically exported from code.google.com/p/alivepdf
0 stars 1 forks source link

addImageStream results in blank PDF with "out of memory" error in Adobe Reader. #346

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create an Adobe Air JS project.
2. Generate a PDF with a jpeg image using addImageStream.
3. A sample project has been attached.

What is the expected output? What do you see instead?
A PDF with an image. Instead a blank PDF is shown and Adobee Reader issues an 
Out of Memory error.

What version of the product are you using? On what operating system?
AlivePDF 1.5RC, Windows 7, Adobe Air 2 SDK, Aptana Studio

Please provide any additional information below.
// Generate PDF
var pdf = new alivePDF.PDF();
pdf.setTitle("Alive PDF Image");
pdf.addPage();

// Add Image
var file = 
air.File.applicationDirectory.resolvePath('app:/assets/chips-tips.jpg');

var bytes = new air.ByteArray();
var stream = new air.FileStream();
stream.open(file, air.FileMode.READ);
stream.readBytes(bytes);
stream.close();
pdf.addImageStream(bytes, alivePDF.ColorSpace.DEVICE_RGB);

// Save and open PDF
var pdfData = pdf.save(alivePDF.Method.LOCAL);
try 
{
    var pdfFile = air.File.desktopDirectory.resolvePath("Test.pdf");
    var fileStream = new air.FileStream();
    fileStream.open(pdfFile, air.FileMode.WRITE);
    fileStream.writeUTFBytes(pdfData);
    fileStream.close();
    pdfFile.openWithDefaultApplication();
} 
catch (error) 
{
    alert(error.message);
}

Original issue reported on code.google.com by dpwebe...@gmail.com on 30 Dec 2011 at 10:17

Attachments:

GoogleCodeExporter commented 8 years ago
Solved the issue, never use fileStream.writeUTFBytes(pdfData), use 
fileStream.writeBytes(pdfData);

MAJOR FACEPALM when I solved this. Thanks for a great library!!!!

Original comment by dpwebe...@gmail.com on 12 Jan 2012 at 8:15

GoogleCodeExporter commented 8 years ago
sir what is air here

Original comment by swe.1...@gmail.com on 4 Jan 2013 at 5:21

GoogleCodeExporter commented 8 years ago

Original comment by cgauth...@gmail.com on 28 Feb 2015 at 12:26