[Send Mail with Binary Attachments] unabe to load PDF Document(Need help urgent)

Forge Component
(2)
Published on 2018-12-12 by Leandro Correa
2 votes
Published on 2018-12-12 by Leandro Correa

Hi team

i have one mobile application.from that application i have to send one email with PDF Attachment.for that mobile application i am calling one another web application url with one input parameter,and i am getting binary data and that binary data i am passing to the Forge componentsend email.but it is not working.i am getting below error



web helper file to generate PDF screen


Mobile Screen

Details of GetBinary Action

Hey Arkyadeep,

Try opening the PDF in notepad for instance, try to see if it makes any sense.

This error can occur when the PDF binary is invalid.

Joey Moree wrote:

Hey Arkyadeep,

Try opening the PDF in notepad for instance, try to see if it makes any sense.

This error can occur when the PDF binary is invalid.

if i open pdf in notepad then i am getting html file.


A html file? 

This probably means there has been an error somewhere.
Perhaps something is going on with the GetRequest_Submit action....

What's the content of this html file? Are you able to post it?

Joey Moree wrote:

A html file? 

This probably means there has been an error somewhere.
Perhaps something is going on with the GetRequest_Submit action....

What's the content of this html file? Are you able to post it?

if u open the pdf file in notepad then u can see the html file


Ah I see, so the binary you are getting from GetRequest_Submit, is the current page!

A page, is built using html, thus when getting the binary you are getting a .html file and not a .pdf file.

I was expecting you to get some PDF from a certain request or something :) 

You should instead send it as a .html, but that would break the usuability of this page, since the javascript is not accessible on the client (since the javascript is only on the outsystems server). 

If you wish to convert the current page into a PDF you should use something like html2pdf.

Joey Moree wrote:in this component they want binary content.we dont want to implement HTML2PDF.is there any other way

Ah I see, so the binary you are getting from GetRequest_Submit, is the current page!

A page, is built using html, thus when getting the binary you are getting a .html file and not a .pdf file.

I was expecting you to get some PDF from a certain request or something :) 

You should instead send it as a .html, but that would break the usuability of this page, since the javascript is not accessible on the client (since the javascript is only on the outsystems server). 

If you wish to convert the current page into a PDF you should use something like html2pdf.



Binary content is the binary representation of a file, just because an action returns binary doesn't mean that it's a pdf file.

Most file types have some header information which indicates that they are a certain type of file.

Here's an example of a PDF binary:

%PDF-1.7
1 0 obj
  << /Type /Catalog
     /Pages 2 0 R
  >>
endobj

2 0 obj
  << /Type /Pages
     /Kids [3 0 R]
     /Count 1
  >>
endobj

3 0 obj
  << /Type /Page
     /Parent 2 0 R
     /MediaBox [0 0 600 400]
     /Resources << >>
  >>
endobj

xref
0 4
00000000000 65535 f
00000000010 00000 n
00000000069 00000 n
00000000141 00000 n
trailer
  << /Root 1 0 R
     /Size 4
  >>
startxref
249
%%EOF


The binary you are using right now, is a binary, even though it is html.

If you wish to upload a PDF you can ask a few questions.

- Is the PDF always the same?
- Should I generate the PDF on the fly?
- Should the user upload a PDF?

If the PDF is always the same, you can use the Resources folder to include a PDF of your own.
Then you can directly call the binary for this resource instead of using the GetRequest_Submit binary.

Currently, you are trying to attach a html file as a pdf, ofcourse this doesn't work. If you wish to show the current page, but not use html2pdf, just change the extension to .html instead.

Hi Arkyadeep Bharadwaj,

Well there are alternatives, but they are all softwares available through the internet that could do the trick. 

here you can see some of them: 

https://nugetmusthaves.com/Tag/html-to-pdf 

But all this work can just be avoid by using the html2pdf converter just like Joey suggested

Best Regards,

Hi Arkyadeep Bharadwaj,

You can get the PDF file on an URL or on a WebService using the File Plugin and then use the binary data to send the e-mail.

If you want to preview the PDF file you can so use the File Viewer Plugin

I hope this help you.


Best Regards,

Leandro.