Skip to Content
0

Why pdf opens in browser but not in pdf reader ?

Feb 13 at 03:20 PM

73

avatar image

After having an attachment in my order(VA03) , i use FM 'BDS_DOCUMENT_GET_TABLE' to get the binary table of this pdf then i send it by email/

When i open it using the browser, it opens correctly, but when i save it in my documents then trying to open it , i get this message

'There was an error opening this document. The file is damaged and could not be repaired'

what could have happened to the pdf after converting it into binary table ?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Sandra Rossi Feb 13 at 09:40 PM
6

Each software has its own implementation to display the PDF, so maybe your PDF is corrupted (the classic issue is extra zero bits at the end of the file) but the browser is able to display it. So, pay attention to the length of the file when you get it, or when you attach it to the email.

Show 16 Share
10 |10000 characters needed characters left characters exceeded

This is what I like in SCN :-)

We will get an answer for every issue we face.If not an answer, atleast a lead which can lead us to the right solution.

Kudos to experts like you.

K.Kiran.

2

If you like it, put an up-vote on it! ;-)

0

If you like it, put an up-vote on it! ;-)

0

Sandra, thank you. that's explains why some pdf documents works fine. As you said, i have many zeros at the end of this corrupted pdf binary table, but how to get rid of them ?!? :\

0

Is it BDS_DOCUMENT_GET_TABLE that's adding the extra x00 or is when you send the email? How are you creating the email? How are you attaching the pdf?

0
Matthew Billingham

yes, the BDS_DOCUMENT_GET_TABLE FM returns a content table with line x1022 with zeros at the last line of this table, then i convert this table into an xstring in a loop at this table

LOOP AT lt_content INTO DATA(ls_content).
CONCATENATE xdata ls_content-line INTO xdata IN BYTE MODE.

ENDLOOP.

and i send this xstring file (in this case with zeros at the end) to the server and it deals with it by it's own

0

You get the actual size from the parameter COMPONENTS (COMP_SIZE) (EDIT: of function module BDS_DOCUMENT_GET_TABLE, sorry it's COMP_SIZE not DOCUMENT_SIZE)

0

In which FM is this parameter ?

0
Wael Alnashash

Wael,

If you have CL_BCS then you can find it in.....

CL_DOCUMENT_BCS>>ADD_ATTACHMENT>> Importing parameter I_ATTACHMENT_SIZE.

K.Kiran.

0

BDS_DOCUMENT_GET_TABLE

0

Do you use method add_attachment of class cl_document_bcs? If so, you need to have the parameter i_attachment_size = size got from components(document_size).

0
Matthew Billingham

Thank you for the answer.

No, i'm just sending the xstring file to the server.

i just need to know the size of my output xstring file from the binary table

let's say i have a binary table and it has next lines:

0123456789

0123456789

0123000000

the size of the xstring file should be 24 not 30

how can i get that ?

0

There is size of binary content in components-comp_size (BDS_DOCUMENT_GET_TABLE).

xdata = xdata(components-comp_size). "clip xstring size
1

What do you mean by "Send it to the server"? What server? Originally you wrote "i use FM 'BDS_DOCUMENT_GET_TABLE' to get the binary table of this pdf then i send it by email". Is this not true? It would be enormously helpful if when people asked questions they'd be precise and accurate with the information they give!

Anyway. Since you know the size of the file from Tomas Buryanek's answer, your problem is solved. One line of basic ABAP.

0
Matthew Billingham

My RFC FM is called from internet store on hybris platform and it returns an xstring file (which is the pdf).

there is no such BIG need in explaining what i do in the pdf file i get, Mr. Billingham.

0
Show more comments
Further commenting has been locked.