Skip to content

Instantly share code, notes, and snippets.

@frabcus
Created March 8, 2016 15:20
Show Gist options
  • Save frabcus/1889bfe5e7bb7688f568 to your computer and use it in GitHub Desktop.
Save frabcus/1889bfe5e7bb7688f568 to your computer and use it in GitHub Desktop.
Imports System.Net
Imports System.Net.Http
Imports System.Threading.Tasks
Class Program
Shared uploadURL As String = "https://pdftables.com/api?key=&format=xml"
Private Shared Sub Main()
Dim task = PDFToTable("C:\temp\your_test_pdf.pdf")
task.Wait()
Console.Write(task.Result)
Console.WriteLine("Press enter to continue...")
Console.ReadLine()
End Sub
Private Shared Function PDFToTable(filename As String) As Task(Of String)
Using f = System.IO.File.OpenRead(filename)
Dim client = New HttpClient()
Dim upload = New StreamContent(f)
Dim mpcontent = New MultipartFormDataContent()
Console.WriteLine("Uploading content...")
mpcontent.Add(upload)
Using response = Await client.PostAsync(uploadURL, mpcontent)
Console.WriteLine("Response status {0} {1}", CInt(response.StatusCode), response.StatusCode)
Using content = response.Content
Return Await content.ReadAsStringAsync()
End Using
End Using
End Using
End Function
End Class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment