У меня есть API, который возвращает массив блюд с изображениями и описанием, что я делаю, перебираю все это и добавляю изображение в PDF.Но после 44 итераций я получаю ошибку unsupported image type: text/html; charset=utf-8
.Но когда я добавляю изображения, которые выдают мне ошибки один за другим, все работает нормально.
for i, dish := range items {
var imgURL string
if dish.Image != "" {
if pdf.Error() != nil {
uadmin.Trail(uadmin.DEBUG, pdf.Error())
}
imgURL = "http://192.168.149.101:5557" + dish.Image
fmt.Println(fmt.Sprintf("%v %v", i, imgURL))
httpimg.Register(pdf, imgURL, "")
pdf.Image(imgURL, 20, 10, 60, 0, true, "", 0, "")
imgURL = ""
}
pdf.SetFont("Arial", "B", 16)
pdf.SetLeftMargin(90)
pdf.SetY(nameY)
pdf.Write(7, dish.Name)
pdf.SetFont("Arial", "", 12)
nameY += 10
pdf.SetY(nameY)
pdf.SetLeftMargin(90)
pdf.Write(6, dish.Desc)
pdf.SetFont("Arial", "B", 14)
nameY += 30
pdf.Text(90, nameY, fmt.Sprint(dish.Price)+".00php")
pdf.SetTopMargin(65)
}
pdf.OutputFileAndClose("menu.pdf")
ЛОГИ сервера:
API CALL: getCategoryItems
[ DEBUG ] select a.id,a.hide_on_take_out, a.deleted_at, a.kitchen_location_id, a.name, a.code, a.description, a.suggested_item_id, a.image, a.spicy_level, a.is_spicy_level_changable, a.is_vegetarian, a.best_seller, a.is_displayed, a.serving_time, a.reference_id, a.location_id, a.abbreviation, a.item_color, a.visibility, a.available_online, a.available_for_pickup, a.available_electronically,case when b.id > 0 then b.item_category_id else a.item_category_id end as item_category_id, a.type, a.skip_modifier_screen, a.available, a.sub_kitchen_location_id, a.take_out_charge_id, a.position, a.kitchen_code,a.special_request_message, a.pax from items as a left join item_locations as b on b.item_id = a.id where (a.deleted_at is null and a.is_displayed = 1) group by a.id order by a.item_category_id,case when b.id > 0 then b.display_order else a.position end
[ DEBUG ] select a.id,a.hide_on_take_out, a.deleted_at, a.kitchen_location_id, a.name, a.code, a.description, a.suggested_item_id, a.image, a.spicy_level, a.is_spicy_level_changable, a.is_vegetarian, a.best_seller, a.is_displayed, a.serving_time, a.reference_id, a.location_id, a.abbreviation, a.item_color, a.visibility, a.available_online, a.available_for_pickup, a.available_electronically,case when b.id > 0 then b.item_category_id else a.item_category_id end as item_category_id, a.type, a.skip_modifier_screen, a.available, a.sub_kitchen_location_id, a.take_out_charge_id, a.position, a.kitchen_code,a.special_request_message, a.pax from items as a left join item_locations as b on b.item_id = a.id where (a.deleted_at is null and a.is_displayed = 1) group by a.id order by a.item_category_id,case when b.id > 0 then b.display_order else a.position end
[ INFO ] Api call time : 2.525186934s
[ INFO ] &{GET /api/?method=getCategoryItems&lang=eng&categoryID= HTTP/1.1 1 1 map[X-Custom-Header:[myvalue] User-Agent:[Go-http-client/1.1] Accept-Encoding:[gzip] Content-Type:[application/json]] {} <nil> 0 [] false 192.168.149.101:5557 map[categoryID:[] method:[getCategoryItems] lang:[eng]] map[] <nil> map[] 192.168.149.37:33042 /api/?method=getCategoryItems&lang=eng&categoryID= <nil> <nil> <nil> 0xc000238510}