Q:

How to get "PDF" file from the binary data of SoftLayer's quote?

I got the binary data by "getPdf" method of SoftLayer's API.
Ref.
BillingSoftLayer_Billing_Order_Quote::getPdf | SoftLayer Development Network - http://sldn.softlayer.com/reference/services/SoftLayer_Billing_Order_Quote/getPdf
Then I wanna create the PDF file from the binary data.
Do you know how to proceed it?

A:

the method return a binary data encoded in base 64, what you need to do is decode the binary data.
see this article about enconde and decode binary data.
https://code.tutsplus.com/tutorials/base64-encoding-and-decoding-using-python--cms-25588
the Python client returns a xmlrpc.client.Binary object so you need to work with that object here an example using the Python client and Python 3
#!/usr/bin/env python

import SoftLayer
import xmlrpc.client
import base64
import os

USERNAME = 'set me'
API_KEY = 'set me'

quoteId = 1560845

client = SoftLayer.Client(username=USERNAME, api_key=API_KEY)

accountClient = client['SoftLayer_Billing_Order_Quote']
binaryData = accountClient.getPdf(id=quoteId)
decodeBinary = binaryData.data
file = open('test.pdf','wb')
file.write(decodeBinary)

Regards

