Beispiel #1
0
func main() {
	// Initialize API client
	c, err := handwritingio.NewClient(key, secret)
	if err != nil {
		fmt.Println(err)
		return
	}

	// Prepare params for rendering
	var params = handwritingio.DefaultRenderParamsPDF
	params.HandwritingID = "31SAZEF000DX" // found in our catalog or by listing handwritings
	params.HandwritingSize = "15pt"
	params.Text = message
	params.Height = "2in"
	params.Width = "4in"

	// Call API to render PDF
	r, err := c.RenderPDF(params)
	if err != nil {
		fmt.Println(err)
		return
	}
	defer r.Close()

	// Create file
	f, err := os.Create(filename)
	if err != nil {
		fmt.Println(err)
		return
	}
	defer f.Close()

	// Write PDF to file
	_, err = io.Copy(f, r)
	if err != nil {
		fmt.Println(err)
	}

	return
}
Beispiel #2
0
func main() {
	// Initialize API client
	client, err := handwritingio.NewClient(key, secret)
	if err != nil {
		fmt.Println(err)
		return
	}

	// Set up list params
	var params = handwritingio.DefaultHandwritingListParams
	params.OrderBy = "title"
	params.Limit = 50
	params.Offset = 0

	// Fetch first page
	handwritings, err := client.ListHandwritings(params)
	if err != nil {
		fmt.Println(err)
		return
	}

	for len(handwritings) > 0 {
		for _, handwriting := range handwritings {
			fmt.Printf("%s: %s\n", handwriting.ID, handwriting.Title)
		}

		// Fetch next page
		params.Offset += params.Limit
		handwritings, err = client.ListHandwritings(params)
		if err != nil {
			fmt.Println(err)
			return
		}

		fmt.Println("== Page ==")

	}

	return
}