Home Page Creating PDF files with XSL-FO and Visual Basic 6
XSL-FO Server
Getting started
How to
XSL-FO Editor
XSL-FO resources
XSL-FO in REALbasic
XSL-FO in Php
XSL-FO in VB 6
XSL-FO in Ruby
XSL-FO in Delphi
Usage with APEX
XSL-FO in VB 6

The following script shows how you can call the FOP server from a Visual Basic 6 program:

Dim inet
Dim xml As String
Dim Chunk() As Byte
Dim Size As Long
Dim Remaining As Long

'Create instance of object
Set inet = CreateObject("InetCtls.Inet")
'Set timeout to say 20 secs
inet.RequestTimeout = 20

'input XML data
xml = "<?xml version=""1.0"" encoding=""iso-8859-1""?> <departments><department><departmentName>R&amp;D</departmentName> <person> <name>John Schmidt</name> "
xml = xml & "<address>Red street 3</address> <status>A</status> </person> <person> <name>Paul Bones</name> <address>White street 5</address> <status>A</status> "
xml = xml & "</person> <person> <name>Mark Mayer</name> <address>Blue street 5</address> <status>A</status> </person> <person> <name>Janet Black</name> "
xml = xml & "<address>Black street 8</address> <status>I</status> </person></department><department> <departmentName>Sales</departmentName> <person> "
xml = xml & "<name>Juan Gomez</name> <address>Green street 3</address> <status>A</status> </person> <person> <name>Juliet Bones</name> <address>White street 5</address> "
xml = xml & " <status>A</status> </person></department></departments>"

'Call the FOP Server, passing the name of the template in the URL
inet.Execute "http://localhost:8087/J4LFOPServer/servlet?TEMPLATE=departmentEmployees.fo", "post", xml, "Content-Type: text/xml"

Do While inet.StillExecuting 

' read output size
Size = CLng(inet.GetHeader("Content-Length"))
Remaining = Size

Dim filename As String
Dim fnum As Long

filename = "output.pdf"
fnum = FreeFile
Open filename For Binary Access Write As #fnum
' read all bytes of the http response and save them to a file
Do Until Remaining = 0
    If Remaining > 1024 Then
        Chunk = inet.GetChunk(1024, icByteArray)
        Remaining = Remaining - 1024
        Chunk = inet.GetChunk(Remaining, icByteArray)
        Remaining = 0
    End If

    Put #fnum, , Chunk

Close #fnum