?
Solved

How to get some binary data?

Posted on 2003-03-20
2
Medium Priority
?
275 Views
Last Modified: 2008-02-01
Hi folks.

  i have some code that converts HTML into a PDF format (binary) using our ActivePDF Server + Webgrabber software, here at work.

Works perfectly, etc.

   Now that i'm converting my code from asp -> c#, i cannot do the following :-


   (ERRORS) strTextBinary = objAPServer.GetBinaryImage( strFileName );

objAPServer is an instance of the ActivePDF Server class :-

   eg. APServerNET.APServer objAPServer = null;


   The error is that the GetBinaryImage() function returns a type 'object'.


   So then i tried this ....

   object test = null;
   test = objAPServer.GetBinaryImage( strFileName );

   compiled.  but i still have NO IDEA how i can get the CONTENT of this object...


   Why am i using GetBinaryImage then???
   well, in my working (old/traditional) ASP code, this is what i did...

   Response.BinaryWrite(objAPServer.GetBinaryImage( strFileName )


   and becuase i'm now proigramming this in C#, i do not want to write anything to the screen/console, becuase this is all encapsualted in a class. i wish for the class to return a binary string instead - so the person who USES my class can have the raw binary data and do what they want with it -> ie. save to disk, display to page, etc.


    any suggestions folks?
0
Comment
Question by:pure032398
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 4

Expert Comment

by:Nebulus_
ID: 8179367
first:
- is ActivePDF Server class a COM class?
- can you show me its interface?

second:
- you can use your code:
object test = null;
test = objAPServer.GetBinaryImage( strFileName );
- get test object in debug mode and view Type instance
associated with test:
Type a = test.GetType();
- look at Is... properties now: (IsArray, IsByRef, IsClass, IsEnum, etc.)

maybe this can be a start. :)
0
 
LVL 2

Accepted Solution

by:
Buzzby earned 750 total points
ID: 8184266
Hopefully the above (or the Vstudio debugger) will show that the intrinsic type is an array of bytes? Then you should be able to cast it something like this:

byte[] data = (byte[]) test;

If you find that you have a System.Array type within the object use the CopyTo() method to move it to a more specific type.

Sincerely,
Buzzby
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question