Free Support Forum -

Webservice pdf.kit binary

I have a question about using .KIT in a web service. Maybe you can point me to an example. Basically, I would like to return the file as binary file type.

The current example that I have seen from you returns the file as a Response.OutputStream. I will not be using the HTTP response on the web service since I will return the file to the client as a binary file.

This message was posted using Email2Forum by Merit.


Can you please elaborate your requirement a little more so that we can more accurately give you a suggestion.


To start, I would like to know the best method to create a binary file
Dim outputFilestream As Stream = New FileStream(templatePdf, FileMode.Open, FileAccess.ReadWrite)

Dim inputString As String = Server.MapPath(“folder\Name.pdf”)

form = New Form(inputString, outputFilestream)
I then fill the form fields
For i = 0 To 5
form.FillField(fieldNameArray(i), fieldValueArray(i))
Then I try to create a byte file from the stream
Dim len As Integer = CType(outputFilestream.Length, Integer)
mByteArray = New Byte(len - 1) {}
outputFilestream.Read(mByteArray, 0, len) ’ It fails here!!

It would be great if I could have a byte type file returned directly from one of your methods instead of a file stream.


You have to call the Save method of Form class after filling all the fields and reset the filestream pointer to 0 [Seek(0, SeekOrigin.Begin)] before reading it into an array.


Your previous help has gotten me past the errors, thanks.

I would like to create the output PDF in Memory, rather than a physical "OUT" file. Is there a code example for that?

In a competitor's component they expose a smart way to accomplish this. Does ASPOSE offer something similar?

'Open the save File. OR use MEMORY<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

intRet = PDF_ToolKit.OpenOutputFile("MEMORY")


In order to create the file in memory please use MemoryStream in place of FileStream.