You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@flex.apache.org by FreddyKrueger <co...@freynolds.es> on 2014/05/06 17:24:21 UTC

Flex movile save pdf and send by mail, Android, IOS.. alivePdf + SMTPMailer

Good afternoon. 
I have to save a PDF and send from your mobile device. 

I saved and costs. 
Arrives mail without problems. 
But when I try to open the pdf gives me error. 
Reader, tells me that the file is not what was expected and could be
unencrypted. 

I hit you the code. thank infinitely help 
Freddy



var pdf:PDF = new PDF;
pdf = new PDF(Orientation.LANDSCAPE, Unit.MM, Size.A4 );
pdf.setDisplayMode (Display.REAL);  
pdf.addPage(); 
pdf.addText('hello nice', 10, 10);

var fs:FileStream = new FileStream();
var file: File = File.applicationStorageDirectory.resolvePath("a.pdf");
                                                           fs.open(file,
FileMode.WRITE);
                                                           var
pdfBytes:ByteArray = pdf.save(Method.LOCAL);
                                                          
fs.writeBytes(pdfBytes);
                                                           fs.close();

myMailer.sendAttachedMail("jaja@jaja.jaja", " jaja@jaja.jaja ", "test smtp",
"<br>*Picture from HTML :)*", pdfBytes, "a.pdf");




--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/Flex-movile-save-pdf-and-send-by-mail-Android-IOS-alivePdf-SMTPMailer-tp6391.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

Re: Flex movile save pdf and send by mail, Android, IOS.. alivePdf + SMTPMailer

Posted by FreddyKrueger <co...@freynolds.es>.
Good afternoon everyone, I have managed to make some progress. 

The problem seems to be in the generation of pdf. 

Because when you take any pdf downloaded from the internet, and you send it
by mail, all goes well. 


I made a test using purePDF. 
When you generate the pdf, shown more stable than alivePDF. 
I make sending and pdf opens correctly. 

Only when within the lines of the pdf add a variable, the pdf opens, but the
pdf mailed, not open. Returning to the issue where adobe reader tells me
that the file is encoded wrong. 

I leave the 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;
document.add(new Paragraph("HELLO THIS WORK OK")); 
document.add(new Paragraph(textoAsistencia)); 
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("aaa@aaa.es", "bbb@bbb.es", "upssss", "*HELLO
ATT pdf*", bytes, namePdf.Pdf);
				
				
			}


Any ideas? with purePDF I managed to open the pdf mailed. 
But if I put some variable text (nameIn.text) does not work. The pdf opens
in the tablet, but being mailed, adobe reader does not open




--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/Flex-mobile-save-pdf-and-send-by-mail-Android-IOS-alivePdf-SMTPMailer-tp6391p6396.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

Re: Flex movile save pdf and send by mail, Android, IOS.. alivePdf + SMTPMailer

Posted by Angelo Lazzari <an...@redtulp.com>.
Hi, here is the ANE we use when we need to send a message by mail:
http://distriqt.com/product/air-native-extensions/message
and if you want you can take a look here to see how many ANE they made
http://distriqt.com/native-extensions.

We use AlivePDF to create the document and the Message ANE to send it by
mail, the ane works in all the platform IOS & Android, windows & mac.

The DISTRIQT company has support service and they answer rapidly.

Have Fun,
Angelo



2014-05-07 14:10 GMT+02:00 FreddyKrueger <co...@freynolds.es>:

> Angelo, thank you very much for answering.
>
> I have continued to work with the code and it's crazy.
>
> The pdf can be generated always open.
> But the sending, not always open.
>
> It is random.
>
> When I add a page at the end of the pdf, is often open.
>
> When attaching here a PDF I have not generated, another thing, downloaded
> from internet ... always open.
>
>
> You saying, they found a Native Extension for sending email with
> attachments.
>
> I have not been able to find anything.
>
> Could you give me some link?
>
> Thank you
> attentively
> Freddy Kruger
>
>
>
> --
> View this message in context:
> http://apache-flex-users.2333346.n4.nabble.com/Flex-mobile-save-pdf-and-send-by-mail-Android-IOS-alivePdf-SMTPMailer-tp6391p6395.html
> Sent from the Apache Flex Users mailing list archive at Nabble.com.
>

Re: Flex movile save pdf and send by mail, Android, IOS.. alivePdf + SMTPMailer

Posted by FreddyKrueger <co...@freynolds.es>.
Angelo, thank you very much for answering. 

I have continued to work with the code and it's crazy. 

The pdf can be generated always open. 
But the sending, not always open. 

It is random. 

When I add a page at the end of the pdf, is often open. 

When attaching here a PDF I have not generated, another thing, downloaded
from internet ... always open. 


You saying, they found a Native Extension for sending email with
attachments. 

I have not been able to find anything. 

Could you give me some link? 

Thank you 
attentively 
Freddy Kruger



--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/Flex-mobile-save-pdf-and-send-by-mail-Android-IOS-alivePdf-SMTPMailer-tp6391p6395.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

Re: Flex movile save pdf and send by mail, Android, IOS.. alivePdf + SMTPMailer

Posted by Angelo Lazzari <an...@redtulp.com>.
I had a problem like your but using an ANE to send the pdf...and the
solution was correct the mime type of the mail attachment... i put
"application/pdf"...
don't know if it could be the same problem.

Angelo




2014-05-06 17:24 GMT+02:00 FreddyKrueger <co...@freynolds.es>:

> Good afternoon.
> I have to save a PDF and send from your mobile device.
>
> I saved and costs.
> Arrives mail without problems.
> But when I try to open the pdf gives me error.
> Reader, tells me that the file is not what was expected and could be
> unencrypted.
>
> I hit you the code. thank infinitely help
> Freddy
>
>
>
> var pdf:PDF = new PDF;
> pdf = new PDF(Orientation.LANDSCAPE, Unit.MM, Size.A4 );
> pdf.setDisplayMode (Display.REAL);
> pdf.addPage();
> pdf.addText('hello nice', 10, 10);
>
> var fs:FileStream = new FileStream();
> var file: File = File.applicationStorageDirectory.resolvePath("a.pdf");
>                                                            fs.open(file,
> FileMode.WRITE);
>                                                            var
> pdfBytes:ByteArray = pdf.save(Method.LOCAL);
>
> fs.writeBytes(pdfBytes);
>                                                            fs.close();
>
> myMailer.sendAttachedMail("jaja@jaja.jaja", " jaja@jaja.jaja ", "test
> smtp",
> "<br>*Picture from HTML :)*", pdfBytes, "a.pdf");
>
>
>
>
> --
> View this message in context:
> http://apache-flex-users.2333346.n4.nabble.com/Flex-movile-save-pdf-and-send-by-mail-Android-IOS-alivePdf-SMTPMailer-tp6391.html
> Sent from the Apache Flex Users mailing list archive at Nabble.com.
>