• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 277
  • Last Modified:

How to get some binary data?

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?
1 Solution
- is ActivePDF Server class a COM class?
- can you show me its interface?

- 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. :)
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.


Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now