cancel
Showing results for 
Search instead for 
Did you mean: 

abap/odta xstream format to png format

Radhey
Explorer
0 Kudos

Hi Abapers/experts

Any anyone know how to convert xstream to PNG format?

In ABAP/odata , I have generated QR code, which is in xstream or base64 format in abap/odata. I want that QR code in PNG format.

Anyone any idea,

Also will work, on SAP UI5 side to convert base64 or xstream in PNG format.

Thanks

Radhesh

Radhey
Explorer
0 Kudos

i want to code for abap.

Jelena
Active Contributor
0 Kudos

C'mon now... What do you think xstream or base64 is? Just look at it. Does it look like some gibberish? Of course. Because it's binary data. This means it's not human-readable (unlike plain text format). But it would make total sense for a computer program that knows how to read it. Which computer program? Now we are getting closer.

Binary format is the way to exchange any data. ABAP or SAP doesn't care what data it is, as long as it makes sense for the receiving program. For example, there are functions to generate a PDF view of SAP output. You can actually see the data involved in debugger. And it will again look like gibberish. Because you need some form of PDF viewer application to make sense of it and show you something humans can understand.

Now where were we? So, when you're saying "in PNG format", what do you mean exactly? How do you envision this to work and how would you verify the result? If you read a PNG file in ABAP, you will see - you've guessed it - gibberish. But if you send this binary content somewhere where an application like MS Paint or a browser can understand it and use it to show a picture.

I hope by now you are beginning to understand that the original question doesn't really make sense. Binary format is like a bucket. What you put in it, it's up to you. Can be beer, can be water. But you still need a bucket to carry the liquid. With this example, your question sounds like "I got a bucket, how do I get beer?" Well, have you considered looking inside the bucket? Maybe beer is already there? And if not, then where did you get what's in the bucket? Maybe if you go to a bar you can get beer instead of water into your bucket? Just some ideas.

Jelena
Active Contributor
0 Kudos

Duplicate

Sandra_Rossi
Active Contributor
0 Kudos

You seem to be confused by two different notions:

  • xstream, base64, byte, xstring are format-independent. They can contain any format (PNG, PDF, JPEG, BMP, ZIP, etc.)
  • png is a format. It can be transported/packaged (or whatever verb you prefer to use) under xstream, base64, byte, xstring.

In the comments, you are now talking about "converting into PNG". Converting which format into PNG? JPEG, PDF, something else? Please don't answer format xstream, base64, byte, xstring, that would be meaningless.

Accepted Solutions (1)

Accepted Solutions (1)

IngoBraeuninger
Advisor
Advisor

Hi Radhesh,
when it's only all about a base64 encoding I can recommend the XCO library for this:

https://help.sap.com/docs/btp/sap-business-technology-platform/xstring

Maybe this code snippet might help how to do it:

DATA(base64) = xco_cp=>xstring( xstring
)->as_string( xco_cp_binary=>text_encoding->base64
)->value.

best regards, Ingo

Answers (4)

Answers (4)

Radhey
Explorer
0 Kudos

thanks all, I converted QR code from xtream format to pdf format and that is working for me.

But still, no answer for , i want function module for convert xtream to png format.

but closing thread.

Sandra_Rossi
Active Contributor
0 Kudos

It seems that you didn't understand what I explained about xstream. Concerning your sentences "convert from xstream to pdf" and "convert from xstream to png", the two are completely different conversions !

The good answer would be better not convert from PDF to PNG, but generate the QR code directly in PNG format.

Radhey
Explorer
0 Kudos

Thanks @Ingo.Braeuninger

For reply. I think this will not solve the problem. I want to get the output in PNG format and not sure if this piece of code will do that.

Thanks

Radhesh

Sandra_Rossi
Active Contributor
0 Kudos

Please use the COMMENT button for comments, asking for complements, adding details, replying to a comment or a proposed solution or to the OP question, etc., ANSWER is only to propose a solution, dixit SAP text at the right of the answer area.

Sandra_Rossi
Active Contributor
0 Kudos

radheyy

Ingo has given the right answer, but you don't understand it, because you think the PNG format is something special, which is completely wrong. The only problem you have is to decompress into bytes, whatever binary format it corresponds to, JPG, PDF, BMP, PNG, ZIP and so on.

I hope you understand and you will try the solution given by Ingo, provided that you have the sufficient ABAP version (I guess 7.56).

Radhey
Explorer
0 Kudos

thanks for your reply. what do you think? I didn't try to it convert into a different format in ABAP?

I tried all the ways. byte,base64,xtream,bmp etc

While attaching that into pdf hear is the error "The input is not a PNG file".

I think in abap, there's no method or FM or any method to convert files into PNG format. I tpng-prob.pngried min.js, js, etc in javascript, but no method found to convert it into a perfect PNG format.

Also check https://pdf-lib.js.org/, pdf-lib dot js dot org --> add image(PNG) in pdf(layer).

Sandra_Rossi
Active Contributor
0 Kudos

As I explained, this discussion should not be under a false answer, it should be under Ingo answer.

I continue the discussion in the comments directly under your question.

Radhey
Explorer
0 Kudos

I'm doing QR Imprint in pdf with the help of pdf-lib in sap ui5.

QR is a dynamic URL, generated in the backend ABAP.

For this, pdf(stream) format, is converted to base64 and then in an array buffer. both work base64/array buffer.

Now I have a pdf in non xtreme format and ready for edit . Now need the QR in PNG format so that I can attach QR in pdf.

So simple question, how to convert xtream/base64 to PNG format?

Sandra_Rossi
Active Contributor
0 Kudos

Please use the COMMENT button for comments, asking for complements, adding details, replying to a comment or a proposed solution or to the OP question, etc., ANSWER is only to propose a solution, dixit SAP text at the right of the answer area.

Radhey
Explorer
0 Kudos

my simple question is.

In abap how to convert xtream or base64 to PNG format? If you know the answer please right down hear.

I know about xtream/base64 binary. might be lots of users know.

simple question is there. In abap how to convert xtream or base64 to PNG format?

Sandra_Rossi
Active Contributor
0 Kudos

Please use the COMMENT button for comments, asking for complements, adding details, replying to a comment or a proposed solution or to the OP question, etc., ANSWER is only to propose a solution, dixit SAP text at the right of the answer area.