DisplayFromByteArray with javascript

Discussions about document viewing.
Post Reply
Tuco
Posts: 2
Joined: Tue Oct 14, 2008 12:00 pm

DisplayFromByteArray with javascript

Post by Tuco » Tue Oct 14, 2008 12:12 pm

Hello, i have a problem with DisplayFromByteArray function, and i'm going crazy...

I have this javascript that works fine:

<script type="text/javascript">
VisorPDF.DisplayFromURL("www.gdpicture.com", "/ressources/specifications/ActivexCOM.pdf");
</script>

but when i want to use DisplayFromByteArray function it doesn''t work... what kind of variable do i have to pass to this function?

This piece of javascript gives a type mismatch javascript error:

var vArray = [37,80,68,70,45,49,46,49,13,10,13,10,57,32,48,32,111,98,106,13,10,60,60,13,10];
VisorPDF.DisplayFromByteArray(vArray);


but this piece is ok:

var vArray = "edasdasd";
VisorPDF.DisplayFromByteArray(vArray);


both cases are just for test, when i know what kind of variable i need i will put the correct data inside.

So, do i have to pass a string to DisplayFromByteArray function?? why an array of bytes variable gives a type mistatch error? And, i have to pass a string... in wich format?

Thanks in advance,
Tuco

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: DisplayFromByteArray with javascript

Post by Loïc » Tue Oct 14, 2008 12:31 pm

Hi,

in JS:

Code: Select all

var vArray = [37,80,68,70,45,49,46,49,13,10,13,10,57,32,48,32,111,98,106,13,10,60,60,13,10];
is not an array of byte. I this each entry are encoded in 32-bit value (and not 8-bit). It is why you got the type mismatch error.

This:

Code: Select all

var vArray = "edasdasd";
Can be considered as an array of byte. This is an array of char and each char are encoded as a byte (8-bit).


Solution:

Catch your data as string value and use the DisplayFromString() method instead the DisplayFromByteArray().

Best regards,

Loïc

Tuco
Posts: 2
Joined: Tue Oct 14, 2008 12:00 pm

Re: DisplayFromByteArray with javascript

Post by Tuco » Wed Oct 15, 2008 12:14 pm

Thanks for your reply

I understand what you say... but i can't solve my problem.

I didn't give you all the information, so, now i'm going to explain my case:

I'm working with asp.net, c#. I have a byte[] variable at server side, with the data of the pdf document. On asp.net page load event, i write this byte[] variable data into value of an html textarea. Then, at the end of the aspx code there is a javascript script that calls the display method passing the value of this textarea to the activex object.

When i write the byte[] variable to the value of the input, i do a transformation byte[] --> string. But, wich codification do i have to do?

Both methods of the gridviewer activex, DisplayFromByteArray and DisplayFromString, expect a javascript string parameter... but with wich codification? I think i could use any of both methods... the problem is that i don't know how to pass them te information.

Maybe i'm not realizing something... maybe i'm doing too complicate... i just want to pass the information in a byte[] variable at server side to the activex gridviewer, but i can't see how. There must be a simple way, isn't?

Thanks,
Tuco

milegd
Posts: 1
Joined: Sun Feb 05, 2012 2:56 pm

Re: DisplayFromByteArray with javascript

Post by milegd » Sun Feb 05, 2012 3:06 pm

I have the same problem.DisplayFromByteArray(DisplayFromString) with javascript or vbscript. Is there any sample code now?This post is very old but there is no answer.

anujsahu
Posts: 1
Joined: Tue Jun 25, 2013 12:00 pm

Re: DisplayFromByteArray with javascript

Post by anujsahu » Mon Jul 01, 2013 1:53 pm

I am also facing the exact issue..any suggestions?

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests