ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » IIB 10 - Issue generating pdf files from Email Output node

Post new topic  Reply to topic
 IIB 10 - Issue generating pdf files from Email Output node « View previous topic :: View next topic » 
Author Message
Cody18
PostPosted: Tue Sep 08, 2015 3:50 pm    Post subject: IIB 10 - Issue generating pdf files from Email Output node Reply with quote

Newbie

Joined: 08 Sep 2015
Posts: 9

Hello,

I am trying to send out a pdf attachement using the Email Output node in IIB 10. And the pdf does generate, but fail to open. It throws an error, 'Adobe Reader could not open attachement because it is either not a supported file type or the file has been damaged.....'

After going through previous posts, I do realize that the issue is somewhere with the encoding/decoding of the pdf file, since my input is a base64 encoded data. I have tried all options of setting content-encoding-type to base 64, but it still generates a damaged file. The Attachement tab in the Email Output node seems to be disabled too and i can not set the attachement encoding there as well.

My code

Code:
DECLARE partData BLOB BASE64DECODE('SWYgaSBjYW4gc2VlIHRoaXMuIEkgaGF2ZSBkb25lIGl0IQ==');
SET OutputLocalEnvironment.Destination.Email.Attachment.ContentEncoding = 'base64';
SET OutputRoot.Properties.ContentType = 'multipart/related;boundary=myBoundary';

--top Level structure
CREATE LASTCHILD OF OutputRoot DOMAIN('MIME') Name 'MIME';
--CREATE FIELD OutputRoot.MIME TYPE Name;
DECLARE M REFERENCE TO OutputRoot.MIME;
   
--Building a tree for multipart MIME document      
CREATE LASTCHILD OF M TYPE Name NAME 'Parts';
CREATE LASTCHILD OF M.Parts TYPE Name NAME 'Part';
DECLARE P1 REFERENCE TO M.Parts.Part[1];

--   Create the body of the email.
CREATE FIELD P1."Content-Type" TYPE NameValue VALUE 'application/pdf; name="attachment.pdf"';
CREATE FIELD P1."Content-Id"   TYPE NameValue VALUE 'part one';
CREATE FIELD P1."Content-Transfer-Encoding" TYPE NameValue VALUE 'binary';
CREATE LASTCHILD OF P1 TYPE Name NAME 'Data';
CREATE LASTCHILD OF P1.Data DOMAIN('BLOB') parse(partData);
--CREATE LASTCHILD OF P1.Data.BLOB NAME 'BLOLB' VALUE partData;




I understand there are previous posts on this issue, and i have tried them out too. Somehow doesnt help.

Please do let me know your suggestions.

Many Thanks
Back to top
View user's profile Send private message
Cody18
PostPosted: Tue Sep 08, 2015 10:47 pm    Post subject: Reply with quote

Newbie

Joined: 08 Sep 2015
Posts: 9

Just an update, the earlier base64encoded data was not of pdf format, Hence the error.

I picked up a valid pdf format data now, yet I see errors like, Out of memory or Cannot extract the embedded font error(for a PDF with image).

Could this by any chance be Adobe version issue? Or still problem with my coding.
Back to top
View user's profile Send private message
nelson
PostPosted: Wed Sep 09, 2015 4:30 am    Post subject: Reply with quote

Partisan

Joined: 02 Oct 2012
Posts: 313

Please take a look at my comments at:

http://www.mqseries.net/phpBB/viewtopic.php?p=386643&highlight=#386643

I've successfully attached a PDF document this way...
Back to top
View user's profile Send private message
nelson
PostPosted: Wed Sep 09, 2015 4:38 am    Post subject: Reply with quote

Partisan

Joined: 02 Oct 2012
Posts: 313

Cody18 wrote:
Just an update, the earlier base64encoded data was not of pdf format, Hence the error.

I picked up a valid pdf format data now, yet I see errors like, Out of memory or Cannot extract the embedded font error(for a PDF with image).

Could this by any chance be Adobe version issue? Or still problem with my coding.


How are you generating the pdf (within IIB?)? if not, can you compare the source pdf and the iib attached pdf and check if there are any differences?
Back to top
View user's profile Send private message
Cody18
PostPosted: Wed Sep 09, 2015 3:54 pm    Post subject: Reply with quote

Newbie

Joined: 08 Sep 2015
Posts: 9

Thank you so much for your reply

However, I have tried decoding my data using the java BASE64DECODE function. All that is in place. Also tried setting the content-encoding to base 64 and have tried options application/pdf and application/octet-stream too. But it still is not able to generate an exact replica of the source PDF. It either throws an Out of Memory error or Cannot extract embedded font error.

The service logic is something like, it calls a third party for a particular pdf file and this third party sends out a base 64 encoded data for that pdf file. This data i pull out and decode it and pass it as BLOB.

I tried comparing the two pdf files - source and IIB generated one with DiffPDF(Got the source pdf file from the third party in proper PDF format-Not encoded). The difference, is IIB generated PDF is empty .. Thats all i could see. Is there any other way i should compare them?
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Sep 09, 2015 8:25 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20698
Location: LI,NY

All base64decode / encode functions may not be equal.
Have you tried encoding the original pdf as supplied by the 3rd party by the broker's bas64 functions and compared the result to what you get from the 3rd party? Do the encoded byte streams show any difference at all?
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Cody18
PostPosted: Thu Sep 10, 2015 3:37 pm    Post subject: Reply with quote

Newbie

Joined: 08 Sep 2015
Posts: 9

The encoded data from the third party and broker encoded data seem to differ. Have asked the third party to look into it.

But however, if i try to input the broker encoded data to my ESQL, it still does not generate a proper pdf. Somewhere, the decoding or some part of my code is messing up the final pdf. Not sure what.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Sep 10, 2015 7:05 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20698
Location: LI,NY

Are you using the broker built-in functionality to Encode and Decode? (and only the broker built-in functionality)

_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
nelson
PostPosted: Fri Sep 11, 2015 6:31 am    Post subject: Reply with quote

Partisan

Joined: 02 Oct 2012
Posts: 313

I'm going to explain you my flow (that it's working):

1. Receive the data. In this case a I call a web service and receive the PDF data as a string type.

2. Use a mapping node to transform the data into another XML structure that calls the "Send email service". Within the mapping I take the PDF data field (string type) and maps it to a base64binary type field using the Transform - base64binary option, when wiring the source with the destination.

3. Within the "Send email service":

Code:
SET OutputRoot.XMLNSC.MySendEmailMessagetoJavaComputeNode.Attachment.PDFContent = CAST InputRoot.XMLNSC.SendEmailServiceMessage.PDFData AS BLOB CCSID ....


4. In a Java Compute Node (I do some other stuff within the JCN, so you could do the same in ESQL... if you decide to do it with JCN, use the Integration Toolkit sample to guide you):

Code:

...
MbElement destination = newEnv.getRootElement().createElementAsLastChild(MbElement.TYPE_NAME, "Destination", null);
MbElement email = destination.createElementAsLastChild(MbElement.TYPE_NAME, "Email", null);
MbElement attachment = email.createElementAsLastChild(MbElement.TYPE_NAME, "Attachment", null);   
...
byte[] Content = (byte[])Adjunto.getFirstElementByPath("PDFContent").getValue();
...
attachment.createElementAsLastChild(MbElement.TYPE_NAME_VALUE, "Content", Content);
...


Hope that helps.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri Sep 11, 2015 7:07 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20698
Location: LI,NY

Are you sure that the pdf data "string type" is not already Base64 encoded?
AFAIK there is no such thing as a string type for a pdf file...

Define PDF Data "string type"... this is absolutely not clear to me. It could mean pdf content stripped of pdf header / footer / images / etc... So to me a pdf is essentially a BLOB and not a String...., it could mean a hex representation of the file, it could mean a base64 encoding of the file...???
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
nelson
PostPosted: Fri Sep 11, 2015 7:27 am    Post subject: Reply with quote

Partisan

Joined: 02 Oct 2012
Posts: 313

fjb_saper wrote:
Are you sure that the pdf data "string type" is not already Base64 encoded?
AFAIK there is no such thing as a string type for a pdf file...

Define PDF Data "string type"... this is absolutely not clear to me. It could mean pdf content stripped of pdf header / footer / images / etc... So to me a pdf is essentially a BLOB and not a String...., it could mean a hex representation of the file, it could mean a base64 encoding of the file...???


It is already Base64 encoded, but for a reason I don't know the WS sends the data in a string type field, if I don´t "cast" explicitly to a base64binary, when you try to cast to BLOB it fails..
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri Sep 11, 2015 7:41 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20698
Location: LI,NY

nelson wrote:
fjb_saper wrote:
Are you sure that the pdf data "string type" is not already Base64 encoded?
AFAIK there is no such thing as a string type for a pdf file...

Define PDF Data "string type"... this is absolutely not clear to me. It could mean pdf content stripped of pdf header / footer / images / etc... So to me a pdf is essentially a BLOB and not a String...., it could mean a hex representation of the file, it could mean a base64 encoding of the file...???


It is already Base64 encoded, but for a reason I don't know the WS sends the data in a string type field, if I don´t "cast" explicitly to a base64binary, when you try to cast to BLOB it fails..


So you receive this as a CHARACTER type. Try and CAST To BLOB with the corresponding CCSID. I would imagine that it would fail if you omit the CCSID as the content is not a hex representation of the bytes.

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Cody18
PostPosted: Mon Sep 14, 2015 4:13 pm    Post subject: Reply with quote

Newbie

Joined: 08 Sep 2015
Posts: 9

Many thanks to all of you for your suggestions. I had to drop of f the MIME structure to make the attachement work. Moreover, the 3rd party was sending a corrupted encoded file, which would fail always. So got a working PDF to make the flow work.

So now my code works with the following



Code:
DECLARE partData BLOB BASE64DECODE(Environment.Variable.TotalChunk);
        
      
      SET OutputRoot.BLOB.BLOB =  CAST('This is the main body of the email.' AS BLOB CCSID 1208);
       SET OutputLocalEnvironment.Destination.Email.Attachment.ContentType = 'application/pdf';
      SET OutputLocalEnvironment.Destination.Email.Attachment.Content = partData;
      SET OutputLocalEnvironment.Destination.Email.Attachment.ContentName = 'attachment.pdf';
      SET OutputLocalEnvironment.Destination.Email.Attachment.ContentEncoding = 'base64';

      RETURN TRUE;




I am still curious as to why the MIME structure would not generate a proper PDF attachement. Will look into that in a while.

Thanks all [/code]
Back to top
View user's profile Send private message
mqjeff
PostPosted: Tue Sep 15, 2015 5:12 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Cody18 wrote:
I am still curious as to why the MIME structure would not generate a proper PDF attachement. Will look into that in a while.

Glad you got things working!

The only thing that looks suspicious to me in your MIME code is the parse when you create the data part. Granted, using the BLOB parser shouldn't actually parse data... but it's possible it's doing some kind of CCSID convert.

Was that taken from the samples?
_________________
chmod -R ugo-wx /
Back to top
View user's profile Send private message
Cody18
PostPosted: Tue Sep 15, 2015 5:34 pm    Post subject: Reply with quote

Newbie

Joined: 08 Sep 2015
Posts: 9

I did try the other way round too. By not parsing the data. It still was the same.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » IIB 10 - Issue generating pdf files from Email Output node
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.