Document not being displayed correctly through webspeed

ankit_jkt

New Member
Hi All,
I am trying to view a document through WebSpeed. And I've managed to "open" the document but I get a lot of special character all over my document - looks as if the control characters are not being displayed correctly.

Please answer urgently.
 

Cringer

ProgressTalk.com Moderator
Staff member
What sort of document is it? How have you opened it? And the questions in my sig too please.
 

ankit_jkt

New Member
It is a word document and i am using progress 9.1E version and OS windows.

One more thing i am not recieving any error but document is not being displayed correctly.

I have the following code to open the document:-
<script language="speedscript">
DEFINE VARIABLE cFileName AS CHARACTER NO-UNDO.
DEFINE VARIABLE i_len AS INTEGER NO-UNDO.
DEFINE VARIABLE ra_rawdata AS RAW NO-UNDO.
DEFINE VARIABLE cTitle AS CHARACTER NO-UNDO.
IF request_method EQ "get" AND TRIM(get-value("document")) NE "":U THEN
DO:
ASSIGN cFileName = TRIM(get-value("document"))
cTitle = ENTRY(NUM-ENTRIES(cFileName, '/':U), cFileName, '/':U).
output-http-header("Pragma","No-Cache").
output-http-header("Cache-Control","No-Cache").
output-http-header("Expires","0").
output-http-header ("Content-disposition":U, "inline").
output-content-type ("application/msword":U).
END.
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>`cTitle`</title>
<meta http-equiv="content-type" content="application/msword; charset=iso-8859-1">
</head>
<body>

<script language = "speedscript">
IF SEARCH(cFileName) <> ? THEN
DO:
INPUT FROM VALUE(cFileName) BINARY NO-ECHO NO-MAP NO-CONVERT.
SEEK INPUT TO 0.
REPEAT:
ASSIGN LENGTH (ra_rawdata) = 1024.
IMPORT UNFORMATTED ra_rawdata.
PUT {&WEBSTREAM} CONTROL ra_rawdata.
END.
ASSIGN LENGTH (ra_rawdata) = 0. /* Deallocate memory */
INPUT CLOSE.
RETURN ''.
END.
</script>
</body>
</html>
</script>
 

ankit_jkt

New Member
No, I think it is not a character set issue.

Actually original document contents are displaying on web page but some others control chracters are also displaying with the document contents and the document is not in the correct format.
 

ankit_jkt

New Member
Hi Cringer,

Thanks for your reply.

I think you are right and it may be a charcter set issue i.e. displays control character on the web page with the original document contents.
Please tell me how I can resolve this problem ("character set problem") to display the document contents correctly without any control character.

Please answer urgently.
 

lee.bourne

Member
Have you tried adding the charset into the http headers?

output-content-type ("application/msword; charset=iso-8859-1":U).

However, I'd question why you have any html/xhtml in the body at all given that the content type is application/msword. Trying just outputting the http headers, i.e. up to and including output-content-type and then going straight into the streaming of the file.

Lee
 

ankit_jkt

New Member
I have tried this option already and put it before streaming the document contents into html. But i am not sure that this is the right place to use this. Please suggest where "output-content-type ("application/msword; charset=iso-8859-1":U)" should be placed.

I also want to know, Is there any role of output-http-header option. If yes, then which place it should be placed and with what values.

I have coded to output the document content in the body tag but i am not sure this is right place or not. Please suggest where this code be placed.

Thanks
 

lee.bourne

Member
I was thinking something like this:

Code:
[COLOR=#333333]<script language="speedscript">[/COLOR]
[COLOR=#333333]DEFINE VARIABLE cFileName AS CHARACTER NO-UNDO.[/COLOR]
[COLOR=#333333]DEFINE VARIABLE i_len AS INTEGER NO-UNDO.[/COLOR]
[COLOR=#333333]DEFINE VARIABLE ra_rawdata AS RAW NO-UNDO.[/COLOR]
[COLOR=#333333]DEFINE VARIABLE cTitle AS CHARACTER NO-UNDO.[/COLOR]
[COLOR=#333333]IF request_method EQ "get" AND TRIM(get-value("document")) NE "":U THEN[/COLOR]
[COLOR=#333333]DO:[/COLOR]
[COLOR=#333333]ASSIGN cFileName = TRIM(get-value("document"))[/COLOR]
[COLOR=#333333]cTitle = ENTRY(NUM-ENTRIES(cFileName, '/':U), cFileName, '/':U).[/COLOR]
[COLOR=#333333]output-http-header("Pragma","No-Cache").[/COLOR]
[COLOR=#333333]output-http-header("Cache-Control","No-Cache").[/COLOR]
[COLOR=#333333]output-http-header("Expires","0").[/COLOR]
[COLOR=#333333]output-http-header ("Content-disposition":U, "inline"). [/COLOR]
[COLOR=#333333]output-content-type ("application/msword[/COLOR][COLOR=#333333]; charset=iso-8859-1[/COLOR][COLOR=#333333]":U).[/COLOR]
[COLOR=#333333]END.[/COLOR]
[COLOR=#333333]
IF SEARCH(cFileName) <> ? THEN [/COLOR]
[COLOR=#333333]DO:[/COLOR]
[COLOR=#333333]INPUT FROM VALUE(cFileName) BINARY NO-ECHO NO-MAP NO-CONVERT. [/COLOR]
[COLOR=#333333]SEEK INPUT TO 0.[/COLOR]
[COLOR=#333333]REPEAT:[/COLOR]
[COLOR=#333333]ASSIGN LENGTH (ra_rawdata) = 1024.[/COLOR]
[COLOR=#333333]IMPORT UNFORMATTED ra_rawdata.[/COLOR]
[COLOR=#333333]PUT {&WEBSTREAM} CONTROL ra_rawdata.[/COLOR]
[COLOR=#333333]END.[/COLOR]
[COLOR=#333333]ASSIGN LENGTH (ra_rawdata) = 0. /* Deallocate memory */[/COLOR]
[COLOR=#333333]INPUT CLOSE.[/COLOR]
[COLOR=#333333]RETURN ''.[/COLOR]
[COLOR=#333333]END. 
[/COLOR][COLOR=#333333]</script>[/COLOR]

However, there is also a slight issue in terms of error handling. If the document doesn't exist, i.e. SEARCH(cFileName) = ?, then the user won't receive an error back. The code would need to be restructured so that if the file didn't exist you send the text/html content type back along with an appropriate error message inside html tags.

Lee
 

ankit_jkt

New Member
I have tried the code given in last reply i.e., reply no. 9, but the problem is still remains.

Please help.

Thanks
Ankit Kumar
 

ankit_jkt

New Member
Hi All,
Thanks for your great support..

I have resolve the problem.

The Problem was with these three statements.
OUTPUT-HTTP-HEADER("Expires","0"). OUTPUT-HTTP-HEADER("Content-disposition", "attachment; filename=" + cDisplayName).
OUTPUT-CONTENT-TYPE("application/msword").

These statements should be in an internal procedure( IP name must be "output-headers") of the file. There are no need to call this IP explicitly, this IP called automatically by the web-speed.


Regards
Ankit Kumar
 
Top