Problem when sending mail the generated pdf

26 views
Skip to first unread message

Fernando Reynolds

unread,
May 7, 2014, 1:29:09 PM5/7/14
to purepdf...@googlegroups.com
Good afternoon. 
Thank purePDF is genuinely spectacular. 

We have a problem. 
If we add a line to the pdf, where we will pass the contents to a text Input when generate the pdf, we can open it without problems . But if you send it as an email attachment, abode reader gives us an error: 

"Adobe Reader can not open pdfFile.pdf because it is not a supported type or damaged (eg sent as email attachment and was not correctly decoded) file"


I leave the code: 
(considerations) 

1 -. The part that sends the pdf as an attachment, we tested a pdf downloaded from the internet, any pdf not generated by us and works perfectly 

. 2 - If we remove the en 

document.add (new Paragraph (problematicLine)); 

everything works perfectly 


CODE:



private funcion generatePdf():void
{
import org.purepdf.elements.Paragraph;  
import org.purepdf.pdf.PageSize;  
import org.purepdf.pdf.PdfDocument;  
import org.purepdf.pdf.PdfWriter;  
import org.purepdf.pdf.fonts.BaseFont;  
import org.purepdf.pdf.fonts.FontsResourceFactory;  
import org.purepdf.resources.BuiltinFonts; 
FontsResourceFactory.getInstance().registerFont(BaseFont.HELVETICA, new BuiltinFonts.HELVETICA());  
var bytes:ByteArray = new ByteArray();  
var writer:PdfWriter = PdfWriter.create(bytes, PageSize.A4);  
var document:PdfDocument = writer.pdfDocument;  
document.open();

var problematicLine:String = "Hello this line, dont work " + nameIn.text;     /*  textInput  */

document.add(new Paragraph("HELLO THIS WORK OK")); 
document.add(new Paragraph(problematicLine));                  /* if quit this line, everything works fine  */

document.close();  
/* Save */

var fileStream:FileStream = new FileStream();
var file:File = File.createTempDirectory();
file = File.applicationStorageDirectory.resolvePath(namePdf.Pdf);
fileStream.open(file, FileMode.WRITE);
fileStream.writeBytes(bytes);
fileStream.close();
sendPdf();

}   /* end function generatePdf  */



                    private function sendPdf():void
{
var encoder:Base64Encoder;
var bytes:ByteArray = new ByteArray();    
var stream:FileStream = new FileStream();
file = File.applicationStorageDirectory.resolvePath(namePdf.Pdf);
stream.open(file, FileMode.READ);    
stream.readBytes(bytes,0,stream.bytesAvailable);    
stream.close();
encoder = new Base64Encoder();
encoder.encodeBytes(bytes, 0, bytes.length);
var myMailer:SMTPMailer = new SMTPMailer ("smtp.yoursmtp.com", 25);
myMailer.authenticate(userSmtp, passSmtp);
myMailer.sendAttachedMail("a...@aaa.es", "b...@bbb.es", "upssss", "<b>HELLO ATT pdf</b>", bytes, namePdf.Pdf);
}






thanks , really thanks  :)
Reply all
Reply to author
Forward
0 new messages