Hello I am working with Twilio Studio and I am using an HTTP Request, which brings me the following information.
[
{
"id": 131316,
"name": "User 1",
"location_id": 38716,
"times": [
{
"day": 1,
"day_name": "Monday",
"open": "08:30",
"close": "13:00"
},
{
"day": 1,
"day_name": " Monday",
"open": "14:00",
"close": "18:00"
},
{
"day": 2,
"day_name": "Tuesday",
"open": "08:30",
"close": "13:00"
},
{
"day": 2,
"day_name": "Tuesday",
"open": "14:00",
"close": "18:00"
},
{
"day": 3,
"day_name": "Wednesday",
"open": "08:30",
"close": "13:00"
},
{
"day": 3,
"day_name": "Wednesday",
"open": "14:00",
"close": "18:00"
},
{
"day": 4,
"day_name": "Thursday",
"open": "08:30",
"close": "13:00"
},
{
"day": 4,
"day_name": "Thursday",
"open": "14:00",
"close": "18:00"
},
{
"day": 5,
"day_name": "Friday",
"open": "08:30",
"close": "13:00"
},
{
"day": 5,
"day_name": "Friday",
"open": "14:00",
"close": "17:00"
}
]
},
{
"id": 131313,
"name": "User 2",
"location_id": 38716,
"times": [
{
"day": 1,
"day_name": " Monday",
"open": "08:30",
"close": "14:00"
},
{
"day": 1,
"day_name": " Monday",
"open": "15:00",
"close": "18:00"
},
{
"day": 2,
"day_name": "Tuesday",
"open": "08:30",
"close": "14:00"
},
{
"day": 2,
"day_name": "Tuesday",
"open": "15:00",
"close": "18:00"
},
{
"day": 3,
"day_name": "Wednesday",
"open": "08:30",
"close": "14:00"
},
{
"day": 3,
"day_name": "Wednesday",
"open": "15:00",
"close": "18:00"
},
{
"day": 4,
"day_name": "Thursday",
"open": "08:30",
"close": "14:00"
},
{
"day": 4,
"day_name": "Thursday",
"open": "15:00",
"close": "18:00"
},
{
"day": 5,
"day_name": "Friday",
"open": "08:30",
"close": "14:00"
},
{
"day": 5,
"day_name": "Friday",
"open": "15:00",
"close": "17:00"
}
]
},
{
"id": 130975,
"name": "User 3",
"location_id": 38716,
"times": [
{
"day": 1,
"day_name": " Monday",
"open": "08:30",
"close": "13:00"
},
{
"day": 1,
"day_name": " Monday",
"open": "14:00",
"close": "18:00"
},
{
"day": 2,
"day_name": "Tuesday",
"open": "08:30",
"close": "13:00"
},
{
"day": 2,
"day_name": "Tuesday",
"open": "14:00",
"close": "18:00"
},
{
"day": 3,
"day_name": "Wednesday",
"open": "08:30",
"close": "13:00"
},
{
"day": 3,
"day_name": "Wednesday",
"open": "14:00",
"close": "18:00"
},
{
"day": 4,
"day_name": "Thursday",
"open": "08:30",
"close": "13:00"
},
{
"day": 4,
"day_name": "Thursday",
"open": "14:00",
"close": "18:00"
},
{
"day": 5,
"day_name": "Friday",
"open": "08:30",
"close": "13:00"
},
{
"day": 5,
"day_name": "Friday",
"open": "14:00",
"close": "17:00"
}
]
}
]
I want to capture the "name" information that comes from the HTTP response but I have not been able to do it. I have used the following options without it working for me.
{{widgets.ListaPrestadores.response.parsed.name}}
{{widgets.ListaPrestadores.response.parsed.name[0]}}
{{widgets.ListaPrestadores.response.body.parsed.name}}
{{widgets.ListaPrestadores.response.body.parsed.name[0]}}
Does anyone have an idea how I could do this? Thank you.
Try wrapping the array in an object like below, then access first element in the array with the syntax.
Note that, although an array is valid JSON, if your request returns an array of objects, it will not be parsed by your Studio Flow
{{widgets.http_1.parsed.data[0].name}}
{"data":
[
{
"id": 131316,
"name": "User 1",
"location_id": 38716,
"times": [
{
"day": 1,
"day_name": "Monday",
"open": "08:30",
"close": "13:00"
},
{
"day": 1,
"day_name": " Monday",
"open": "14:00",
"close": "18:00"
},
{
"day": 2,
"day_name": "Tuesday",
"open": "08:30",
"close": "13:00"
},
{
"day": 2,
"day_name": "Tuesday",
"open": "14:00",
"close": "18:00"
},
{
"day": 3,
"day_name": "Wednesday",
"open": "08:30",
"close": "13:00"
},
{
"day": 3,
"day_name": "Wednesday",
"open": "14:00",
"close": "18:00"
},
{
"day": 4,
"day_name": "Thursday",
"open": "08:30",
"close": "13:00"
},
{
"day": 4,
"day_name": "Thursday",
"open": "14:00",
"close": "18:00"
},
{
"day": 5,
"day_name": "Friday",
"open": "08:30",
"close": "13:00"
},
{
"day": 5,
"day_name": "Friday",
"open": "14:00",
"close": "17:00"
}
]
},
{
"id": 131313,
"name": "User 2",
"location_id": 38716,
"times": [
{
"day": 1,
"day_name": " Monday",
"open": "08:30",
"close": "14:00"
},
{
"day": 1,
"day_name": " Monday",
"open": "15:00",
"close": "18:00"
},
{
"day": 2,
"day_name": "Tuesday",
"open": "08:30",
"close": "14:00"
},
{
"day": 2,
"day_name": "Tuesday",
"open": "15:00",
"close": "18:00"
},
{
"day": 3,
"day_name": "Wednesday",
"open": "08:30",
"close": "14:00"
},
{
"day": 3,
"day_name": "Wednesday",
"open": "15:00",
"close": "18:00"
},
{
"day": 4,
"day_name": "Thursday",
"open": "08:30",
"close": "14:00"
},
{
"day": 4,
"day_name": "Thursday",
"open": "15:00",
"close": "18:00"
},
{
"day": 5,
"day_name": "Friday",
"open": "08:30",
"close": "14:00"
},
{
"day": 5,
"day_name": "Friday",
"open": "15:00",
"close": "17:00"
}
]
},
{
"id": 130975,
"name": "User 3",
"location_id": 38716,
"times": [
{
"day": 1,
"day_name": " Monday",
"open": "08:30",
"close": "13:00"
},
{
"day": 1,
"day_name": " Monday",
"open": "14:00",
"close": "18:00"
},
{
"day": 2,
"day_name": "Tuesday",
"open": "08:30",
"close": "13:00"
},
{
"day": 2,
"day_name": "Tuesday",
"open": "14:00",
"close": "18:00"
},
{
"day": 3,
"day_name": "Wednesday",
"open": "08:30",
"close": "13:00"
},
{
"day": 3,
"day_name": "Wednesday",
"open": "14:00",
"close": "18:00"
},
{
"day": 4,
"day_name": "Thursday",
"open": "08:30",
"close": "13:00"
},
{
"day": 4,
"day_name": "Thursday",
"open": "14:00",
"close": "18:00"
},
{
"day": 5,
"day_name": "Friday",
"open": "08:30",
"close": "13:00"
},
{
"day": 5,
"day_name": "Friday",
"open": "14:00",
"close": "17:00"
}
]
}
]
}
Related
{
"status": true,
"error": false,
"data": [
{
"type": 0,
"title": "",
"description": "",
"data": [
{
"images": "/media/banner/Glocart%20Shop/Glocart-Shop_moVB3tP.jpg",
"is_external": true,
"link": "https://www.wikipedia.org/",
"product_id": null,
"offer_list_id": null,
"product_list_id": null
},
{
"images": "/media/banner/Grocery/Grocery_m341Az6.jpg",
"is_external": false,
"link": null,
"product_id": null,
"offer_list_id": 1,
"product_list_id": null
}
]
},
{
"type": 1,
"title": "Categories",
"description": "",
"data": [
{
"category_name": "Beverages",
"category_id": 5,
"category_icon": "/media/category_icon_upload_location/61ho157I07L._SX522__WpWCZ7h.jpg"
},
{
"category_name": "Tea & Coffee",
"category_id": 6,
"category_icon": "/media/category_icon_upload_location/Lipton-Green-Tea-Bags-250-SDL859816919-1-31762.jpg"
},
{
"category_name": "Body Care",
"category_id": 3,
"category_icon": "/media/category_icon_upload_location/nourishing-body-lotion-100ml_1024x1024.png"
},
{
"category_name": "Personal Hygiene",
"category_id": 7,
"category_icon": "/media/category_icon_upload_location/lif0259_2_1.jpg"
},
{
"category_name": "Jams & Preserves",
"category_id": 32,
"category_icon": "/media/category_icon_upload_location/kissan-mixed-fruit-jam-500-gm-164390973-ymzpr.jpg"
},
{
"category_name": "Air Fresheners",
"category_id": 28,
"category_icon": "/media/category_icon_upload_location/Godrej_Aer_Home_Air_Freshener_Spray_Morning_Misty_Meadows__fkCoOzL.jpg"
},
{
"category_name": "Chocolate",
"category_id": 35,
"category_icon": "/media/category_icon_upload_location/71p5hUVC0eL._SX569_.jpg"
},
{
"category_name": "Cosmetics & Makeup",
"category_id": 27,
"category_icon": "/media/category_icon_upload_location/81oA3GcTyRL._SL1500_.jpg"
},
{
"category_name": "Personal care",
"category_id": 26,
"category_icon": "/media/category_icon_upload_location/gillette-guard-3-card-blade-pack_rixer.png"
}
]
},
{
"type": 2,
"title": "Fresh Deals",
"description": "Today's Arrival",
"data": [
{
"product_id": 193,
"image_url": "/media/product_images/61XJQZV8YxL._SX425_.jpg",
"product_name": "UNILEVER KSN PINEAPPLE SQH 750ML-RS.15 PRICE OFF",
"offer_price": 14500,
"normal_price": 15500,
"is_in_cart": false,
"cart_qty": 0
},
{
"product_id": 193,
"image_url": "/media/product_images/61XJQZV8YxL._SX425_.jpg",
"product_name": "UNILEVER KSN PINEAPPLE SQH 750ML-RS.15 PRICE OFF",
"offer_price": 14500,
"normal_price": 15500,
"is_in_cart": false,
"cart_qty": 0
},
{
"product_id": 193,
"image_url": "/media/product_images/61XJQZV8YxL._SX425_.jpg",
"product_name": "UNILEVER KSN PINEAPPLE SQH 750ML-RS.15 PRICE OFF",
"offer_price": 14500,
"normal_price": 15500,
"is_in_cart": false,
"cart_qty": 0
}
]
},
{
"type": 3,
"title": "",
"description": "",
"data": [
{
"images": "/media/banner/Glocart%20Shop/Glocart-Shop_moVB3tP.jpg",
"is_external": true,
"link": "https://www.wikipedia.org/",
"product_id": null,
"offer_list_id": null,
"product_list_id": null
},
{
"images": "/media/banner/Glocart%20Shop/Glocart-Shop_moVB3tP.jpg",
"is_external": true,
"link": "https://www.wikipedia.org/",
"product_id": null,
"offer_list_id": null,
"product_list_id": null
}
]
},
{
"type": 4,
"title": "",
"description": "",
"data": [
{
"images": "/media/banner/Glocart%20Shop/Glocart-Shop_moVB3tP.jpg",
"is_external": true,
"link": null,
"product_id": null,
"offer_list_id": null,
"product_list_id": null
}
]
},
{
"type": 5,
"title": "Discount Range",
"description": "",
"data": [
{
"banner": "/media/product_images/61XJQZV8YxL._SX425_.jpg",
"discount_from": 50,
"discount_to": 60
},
{
"banner": "/media/product_images/61XJQZV8YxL._SX425_.jpg",
"discount_from": 40,
"discount_to": 100
}
]
},
{
"type": 2,
"title": "Top Deals",
"description": "Upto 45% discount",
"data": [
{
"product_id": 193,
"image_url": "/media/product_images/61XJQZV8YxL._SX425_.jpg",
"product_name": "UNILEVER KSN PINEAPPLE SQH 750ML-RS.15 PRICE OFF",
"offer_price": 14500,
"normal_price": 15500,
"is_in_cart": false,
"cart_qty": 0
},
{
"product_id": 193,
"image_url": "/media/product_images/61XJQZV8YxL._SX425_.jpg",
"product_name": "UNILEVER KSN PINEAPPLE SQH 750ML-RS.15 PRICE OFF",
"offer_price": 14500,
"normal_price": 15500,
"is_in_cart": false,
"cart_qty": 0
},
{
"product_id": 193,
"image_url": "/media/product_images/61XJQZV8YxL._SX425_.jpg",
"product_name": "UNILEVER KSN PINEAPPLE SQH 750ML-RS.15 PRICE OFF",
"offer_price": 14500,
"normal_price": 15500,
"is_in_cart": false,
"cart_qty": 0
}
]
},
{
"type": 0,
"title": "",
"description": "",
"data": {
"images": "/media/banner/Glocart%20Shop/Glocart-Shop_moVB3tP.jpg",
"is_external": true,
"link": "https://www.wikipedia.org/",
"product_id": null,
"offer_list_id": null,
"product_list_id": null
}
},
{
"type": 6,
"title": "Suggested for you",
"description": "",
"data": [
{
"product_id": 193,
"image_url": "/media/product_images/61XJQZV8YxL._SX425_.jpg",
"product_name": "UNILEVER KSN PINEAPPLE SQH 750ML-RS.15 PRICE OFF",
"offer_price": 14500,
"normal_price": 15500,
"is_in_cart": false,
"cart_qty": 0
},
{
"product_id": 193,
"image_url": "/media/product_images/61XJQZV8YxL._SX425_.jpg",
"product_name": "UNILEVER KSN PINEAPPLE SQH 750ML-RS.15 PRICE OFF",
"offer_price": 14500,
"normal_price": 15500,
"is_in_cart": false,
"cart_qty": 0
},
{
"product_id": 193,
"image_url": "/media/product_images/61XJQZV8YxL._SX425_.jpg",
"product_name": "UNILEVER KSN PINEAPPLE SQH 750ML-RS.15 PRICE OFF",
"offer_price": 14500,
"normal_price": 15500,
"is_in_cart": false,
"cart_qty": 0
}
]
},
{
"type": 0,
"title": "",
"description": "",
"data": {
"images": "/media/banner/Grocery/Grocery_m341Az6.jpg",
"is_external": false,
"link": null,
"product_id": null,
"offer_list_id": 1,
"product_list_id": null
}
},
{
"type": 7,
"title": "",
"description": "",
"data": [
{
"banner": "/media/product_images/61XJQZV8YxL._SX425_.jpg",
"category_name": "Personal Care",
"category_id": 1,
"have_sub_category": true,
"sub_categories": [
{
"category_name": "Chocolate",
"category_id": 35,
"category_icon": "/media/category_icon_upload_location/71p5hUVC0eL._SX569_.jpg"
},
{
"category_name": "Chocolate",
"category_id": 35,
"category_icon": "/media/category_icon_upload_location/71p5hUVC0eL._SX569_.jpg"
}
]
}
]
},
{
"type": 7,
"title": "",
"description": "",
"data": [
{
"banner": "/media/product_images/61XJQZV8YxL._SX425_.jpg",
"category_name": "Beauty Care",
"category_id": 2,
"have_sub_category": false,
"sub_categories": []
}
]
},
{
"type": 7,
"title": "",
"description": "",
"data": [
{
"banner": "/media/product_images/61XJQZV8YxL._SX425_.jpg",
"category_name": "Home Care",
"category_id": 3,
"have_sub_category": false,
"sub_categories": []
}
]
}
],
"cart_items_count": 5,
"total_cart_price": 30000,
"is_authenticated": true,
"new_notification_count": 1,
"cash_back_msg": "Dummy Cash Back message"
}
I have created one..but shows error
struct Home2Response: Codable {
var status, error: Bool?
var data: [Home2ResponseDatum]?
var cartItemsCount, totalCartPrice: Int?
var isAuthenticated: Bool?
var newNotificationCount: Int?
var cashBackMsg: String?
enum CodingKeys: String, CodingKey {
case status, error, data
case cartItemsCount = "cart_items_count"
case totalCartPrice = "total_cart_price"
case isAuthenticated = "is_authenticated"
case newNotificationCount = "new_notification_count"
case cashBackMsg = "cash_back_msg"
}
}
// MARK: - Home2ResponseDatum
struct Home2ResponseDatum: Codable {
var type: Int?
var title: String?
var datumDescription: String?
var data: [Any]?
enum CodingKeys: String, CodingKey {
case type, title
case datumDescription = "description"
case data
}
}
The name in JSON should match the one in your struct.
Change datumDescription into description.
struct Data : Codable {
let type : Int?
let title : String?
let description : String?
let data : [Data]?
i would like to know how to access multiple json dates in swiftui.
my problem was that you should connect json data with each other
here is the first jason file:
{
"place": "Mecca",
"type": "Makkiyah",
"count": 7,
"title": "Al-Fatiha",
"titleAr":"الفاتحة",
"index": "001",
"pages": "1",
"juz": [
{
"index": "01",
"verse": {
"start": "verse_1",
"end": "verse_7"
}
}
]
},
{
"place": "Medina",
"type": "Madaniyah",
"count": 286,
"title": "Al-Baqara",
"titleAr":"البقرة",
"index": "002",
"pages": "2",
"juz": [
{
"index": "01",
"verse": {
"start": "verse_1",
"end": "verse_141"
}
},
{
"index": "02",
"verse": {
"start": "verse_142",
"end": "verse_252"
}
},
{
"index": "03",
"verse": {
"start": "verse_253",
"end": "verse_286"
}
}
]
}
here is the second
{`{
"index": "001",
"name": "al-Fatihah",
"verse": {
"verse_1": "بِسْمِ ٱللَّهِ ٱلرَّحْمَٰنِ ٱلرَّحِيمِ",
"verse_2": "ٱلْحَمْدُ لِلَّهِ رَبِّ ٱلْعَٰلَمِينَ",
"verse_3": "ٱلرَّحْمَٰنِ ٱلرَّحِيمِ",
"verse_4": "مَٰلِكِ يَوْمِ ٱلدِّينِ",
"verse_5": "إِيَّاكَ نَعْبُدُ وَإِيَّاكَ نَسْتَعِينُ",
"verse_6": "ٱهْدِنَا ٱلصِّرَٰطَ ٱلْمُسْتَقِيمَ",
"verse_7": "صِرَٰطَ ٱلَّذِينَ أَنْعَمْتَ عَلَيْهِمْ غَيْرِ ٱلْمَغْضُوبِ عَلَيْهِمْ وَلَا ٱلضَّآلِّينَ"
},
"count": 7,
"juz": [
{
"index": "01",
"verse": {
"start": "verse_1",
"end": "verse_7"
}
}
]
The third
{
"index": "01",
"start": {
"index": "001",
"verse": "verse_1",
"name": "Al-Fatiha"
},
"end": {
"index": "002",
"verse": "verse_141",
"name": "Al-Baqara"
}
},
The Last one with Audio
{
"index": "001",
"verse": {
"verse_1": {
"file": "001.mp3",
"size": 27426,
"unit": "26,78 KB"
},
"verse_2": {
"file": "002.mp3",
"size": 26773,
"unit": "26,15 KB"
},
"verse_3": {
"file": "003.mp3",
"size": 21809,
"unit": "21,3 KB"
},
"verse_4": {
"file": "004.mp3",
"size": 17761,
"unit": "17,34 KB"
},
"verse_5": {
"file": "005.mp3",
"size": 25075,
"unit": "24,49 KB"
},
"verse_6": {
"file": "006.mp3",
"size": 23377,
"unit": "22,83 KB"
},
"verse_7": {
"file": "007.mp3",
"size": 63736,
"unit": "62,24 KB"
}
},
"count": 7
}
I hope you can help me.
the whole thing should end up like a book and audio player.
I tried it alone and only called the first json in foreach, how does the rest of the json file go?
the whole thing should end up like a book and audio player.
I hope for your help.
I Love SwiftUI
thank you in advance
Here is the source code:
https://jsfiddle.net/24zrbqpL/
Highcharts.chart('container', {
"chart": {
"type": "line",
"polar": true
},
"xAxis": {
"min": 0.5,
"max": 6.5,
"categories": ['Clarify Objectives', 'Propose Initiates', 'Prioritise & Select', 'Track Performance', 'Review Portfolio', 'Adjust Course', ''],
"labels": {
"distance": 25
},
"tickmarkPlacement": "on",
"lineWidth": 0,
"gridLineColor": "#575756",
"title": {
"style": {
"fontFamily": "\"Lucida Grande\", \"Lucida Sans Unicode\", Verdana, Arial, Helvetica, sans-serif",
"color": "#666666",
"fontSize": "30px",
"fontWeight": "normal",
"fontStyle": "normal"
}
}
},
"yAxis": {
"plotBands": [{
"from": 1,
"to": 2,
"color": "#f8c4c0",
"outerRadius": "105%",
"thickness": "50%"
}, {
"from": 2,
"to": 3,
"color": "#f39d96",
"outerRadius": "105%",
"thickness": "50%"
}, {
"from": 3,
"to": 4,
"color": "#ee766d",
"outerRadius": "105%",
"thickness": "50%"
}, {
"from": 4,
"to": 5,
"color": "#eb584d",
"outerRadius": "105%",
"thickness": "50%"
}],
"reversed": true,
"min": 1,
"max": 5,
"allowDecimals": false,
"tickInterval": 1,
"tickAmount": 6,
"tickLength": 10,
"gridLineInterpolation": "polygon",
"gridLineColor": "",
"lineWidth": 0,
"tickmarkPlacement": "between",
"tickPixelInterval": 100,
"tickPosition": "outside",
"labels": {
"enabled": true,
"style": {
"fontWeight": "bold"
},
//"y": 25
}
},
"title": {
"text": "APM Spiderweb"
},
"series": [{
data: [1, 2, 3, 4, 5, 6]
}, {
}],
"plotOptions": {
"series": {
"animation": true,
"lineWidth": 4,
"marker": {
"radius": 8,
"symbol": "circle"
},
"_colorIndex": 0,
"_symbolIndex": 0
}
},
"credits": {
"enabled": false
},
"colors": [
"#7cb5ec",
"#90ed7d",
"#f7a35c",
"#8085e9",
"#f15c80",
"#e4d354",
"#2b908f",
"#f45b5b",
"#91e8e1"
]
});
Setting a whiteSpace to 'nowrap' in the labels.style object is a solution which you are looking for.
"labels": {
"distance": 25,
"style": {
"whiteSpace": 'nowrap'
}
},
Demo: https://jsfiddle.net/BlackLabel/edpcjL3k/
API: https://api.highcharts.com/highcharts/xAxis.labels.style
Is it possible to use jsPDF to grab text from a HTML page and jsPDF-autotable to grab the table and to get that all inside one PDF? I have a document which has some content, and tables in the middle of the content. However, I was not able to print that document.
Sample code:
Sample code:enter code here
In the below code I am looping my Content array. Content can be of different types. For the table content am trying to use pdf.autoTable and for the text content am using pdf.text
var pdf = new jspdf('p', 'pt', 'a4');
pdf.setFontSize(18);
pdf.line(20, 25, 25, 25);
for (let i = 0; i < this.dalSectionsArray.length; i++) {
dynamicHtmlSource = dynamicHtmlSource + '<p style="text-align:left;">
<b>' + this.dalSectionsArray[i].title + '</b></p><b/>';
pdf.text(dynamicHtmlSource, 10+i, 10+i);
for (let j = 0; j < this.dalContentsArray.length; j++) {
if (this.dalSectionsArray[i].id ===
this.dalContentsArray[j].sectionView.id) {
if (this.dalContentsArray[j].subType === 'Clause') {
dynamicHtmlSource = this.getClauseData(this.dalContentsArray[j]);
pdf.text(dynamicHtmlSource,20+j,20+j);
} else if (this.dalContentsArray[j].subType === 'Block') {
dynamicHtmlSource = this.getBlockData(this.dalContentsArray[j]);
pdf.text(dynamicHtmlSource,30+j,30+j);
} else if (this.dalContentsArray[j].subType === 'Restriction') {
dynamicHtmlSource =
this.getRestrictionData(this.dalContentsArray[j]);
pdf.text(dynamicHtmlSource, 40+j, 40+j);
} else if (this.dalContentsArray[j].subType === 'Table') {
pdf.autoTable({
startY:50+j,
columnStyles: { europe: { halign: 'center' } }, // European
countries centered
body: this.dalContentsArray[j].tableValues,
columns: this.dalContentsArray[j].displayColumns
})
}
}
pdf.fromHTML('',
this.margins.left, // x coord
this.margins.top,
{
// y coord
width: this.margins.width// max width of content on PDF
}, (dispose) => {
this.headerFooterFormatting(pdf, pdf.internal.getNumberOfPages());
},
this.margins);
var iframe = document.createElement('iframe');
iframe.setAttribute('style', 'position:absolute;right:0; top:0;
bottom:0; height:100%; width:650px; padding:20px;');
document.body.appendChild(iframe);
pdf.setProperties({
title: 'jspdf-iframe',
subject: 'DAL Content',
author: 'PDFAuthor',
keywords: 'generated, javascript, web 2.0, ajax',
creator: 'ABC'
});
iframe.src = pdf.output('datauristring');
Issue is the pdf is completely messed and not printed properly. Can any
one help me in this regard.
Sample JSON:
{
"dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
"sections": [
{
"title": "ABC",
"description": "",
"order": "1",
"status": "Active",
"startDate": "2018-12-12T00:00:00",
"endDate": null,
"id": "{b3cdda34-1fd2-4463-9aa0-24beff4b83fe}-{1}",
"_etag": "\"0d0006a2-0000-0c00-0000-5c94e5760000\"",
"partitionKey": "GGG-Section-{b3cdda34-1fd2-4463-9aa0-24beff4b83fe}-{1}",
"type": "Section",
"clientId": "GGG",
"createdBy": "FFFFF",
"createdDate": "2018-11-12T00:00:00",
"modifiedBy": "FFFFF",
"modifiedDate": "2018-11-12T00:00:00",
"isactive": false
},
{
"title": "DEF",
"description": "",
"order": "2",
"status": "Active",
"startDate": "2018-12-12T00:00:00",
"endDate": null,
"id": "{fca09906-dff9-40b2-a971-28fef7f37dbf}-{1}",
"_etag": "\"0d0004a2-0000-0c00-0000-5c94e5760000\"",
"partitionKey": "GGG-Section-{fca09906-dff9-40b2-a971-28fef7f37dbf}-{1}",
"type": "Section",
"clientId": "GGG",
"createdBy": "FFFFF",
"createdDate": "2018-11-12T00:00:00",
"modifiedBy": "FFFFF",
"modifiedDate": "2018-11-12T00:00:00",
"isactive": false
},
{
"title": "GHI",
"description": "",
"order": "3",
"status": "Active",
"startDate": "2018-12-12T00:00:00",
"endDate": null,
"id": "{9cfb60cf-354c-4194-9e2e-6bab41c6b280}-{1}",
"_etag": "\"0d00faa1-0000-0c00-0000-5c94e5750000\"",
"partitionKey": "GGG-Section-{9cfb60cf-354c-4194-9e2e-6bab41c6b280}-{1}",
"type": "Section",
"clientId": "GGG",
"createdBy": "FFFFF",
"createdDate": "2018-11-12T00:00:00",
"modifiedBy": "FFFFF",
"modifiedDate": "2018-11-12T00:00:00",
"isactive": false
}
],
"contents": [
{
"dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
"baseDataid": "{a351366f-bf4b-44e0-94ff-a81be899ec3a}-{1}",
"subType": "Table",
"sectionView": {
"id": "{9cfb60cf-354c-4194-9e2e-6bab41c6b280}-{1}",
"title": "AAA",
"description": "",
"order": "4"
},
"title": "PL",
"description": "",
"order": "3",
"status": "Active",
"startDate": "2018-12-12T00:00:00",
"endDate": null,
"displayColumns": [ "N", "M", "O", "P" ],
"tableValues": [
{
"N": "Level 21",
"M": "22",
"O": "",
"P": "",
"isRowEditable": false
},
{
"id": "6cb79b9f-2ef2-4d3a-b6c4-7d84dd61aaf7",
"isDeleted": true,
"N": "KKKKKKK",
"M": "GBP 20M",
"O": "",
"isRowEditable": false
},
{
"id": "c83caf0b-8f00-4dc8-bf35-473bda398937",
"isDeleted": true,
"N": "EP",
"M": "GBP 15M",
"O": "",
"isRowEditable": false
}
],
"placeHolderValues": "",
"organizationDataView": [
{
"id": "{8b958d63-d605-4b9a-a3c4-a3c1c052316e}-{1}",
"orgGroupName": "QQ",
"orgGroupType": "DD",
"orgLevel": 1,
"orgParentGroupId": ""
}
],
"id": "{16a3fb1e-f7fa-4dfe-a4d3-c51b56c8dbee-uw}-{1}",
"_etag": "\"0d00a0ca-0000-0c00-0000-5c94ef3f0000\"",
"partitionKey": "GGG-CCCCOOOOO-{16a3fb1e-f7fa-4dfe-a4d3-c51b56c8dbee-uw}-{1}",
"type": "CCCCOOOOO",
"clientId": "GGG",
"createdBy": "MM",
"createdDate": "2018-12-12T00:00:00",
"modifiedBy": "PPP",
"modifiedDate": null,
"isactive": false
},
{
"dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
"baseDataid": "{2b498850-8f11-475d-b170-5705d05c4bf1}-{1}",
"subType": "Clause",
"sectionView": {
"id": "{b3cdda34-1fd2-4463-9aa0-24beff4b83fe}-{1}",
"title": "LLL",
"description": "",
"order": "3"
},
"title": "kkkkk",
"Description": [
{
"type": "label",
"value": "<br/>Some sample text here"
}
],
"order": "6",
"status": "Active",
"startDate": "2018-12-12T00:00:00",
"endDate": null,
"displayColumns": [],
"tableValues": null,
"placeHolderValues": "",
"organizationDataView": [
{
"id": "{8b958d63-d605-4b9a-a3c4-a3c1c052316e}-{1}",
"orgGroupName": "QQ",
"orgGroupType": "DD",
"orgLevel": 1,
"orgParentGroupId": ""
}
],
"id": "{6193cef1-2fe5-47c2-8367-0650ab66caf3-uw}-{1}",
"_etag": "\"0d00a5ca-0000-0c00-0000-5c94ef400000\"",
"partitionKey": "GGG-CCCCOOOOO-{6193cef1-2fe5-47c2-8367-0650ab66caf3-uw}-{1}",
"type": "CCCCOOOOO",
"clientId": "GGG",
"createdBy": "MM",
"createdDate": "2018-12-12T00:00:00",
"modifiedBy": "PPP",
"modifiedDate": null,
"isactive": false
},
{
"dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
"baseDataid": "{d6793120-5e5b-40ec-a1ea-e82e7bdc9d1a}-{1}",
"subType": "Clause",
"sectionView": {
"id": "{9cfb60cf-354c-4194-9e2e-6bab41c6b280}-{1}",
"title": "UT",
"description": "Sample Text",
"order": "4"
},
"title": "PR",
"Description": [
{
"type": "label",
"value": "Sample"
},
{
"type": "dropDown",
"value": "USD",
"options": [ "USD", "INR", "Dollar" ]
},
{
"type": "text",
"value": "50"
},
{
"type": "label",
"value": "Sample "
},
{
"type": "dropDown",
"value": "USD",
"options": [ "USD", "INR", "Dollar" ]
},
{
"type": "text",
"value": "50"
},
{
"type": "label",
"value": "Sample"
},
{
"type": "dropDown",
"value": "USD",
"options": [ "USD", "INR", "Dollar" ]
},
{
"type": "text",
"value": "50"
},
{
"type": "label",
"value": "Sample "
},
{
"type": "dropDown",
"value": "USD",
"options": [ "USD", "INR", "Dollar" ]
},
{
"type": "text",
"value": "50"
},
{
"type": "label",
"value": "Sample"
},
{
"type": "dropDown",
"value": "USD",
"options": [ "USD", "INR", "Dollar" ]
},
{
"type": "text",
"value": "50"
},
{
"type": "label",
"value": "any one programme/risk</li><li>a maximum premium of "
},
{
"type": "dropDown",
"value": "USD",
"options": [ "USD", "INR", "Dollar" ]
},
{
"type": "text",
"value": "50"
},
{
"type": "label",
"value": "Sample"
},
{
"type": "dropDown",
"value": "USD",
"options": [ "USD", "INR", "Dollar" ]
},
{
"type": "text",
"value": "50"
},
{
"type": "label",
"value": "<br/>SSample"
},
{
"type": "dropDown",
"value": "USD",
"options": [ "USD", "INR", "Dollar" ]
},
{
"type": "text",
"value": "50"
},
{
"type": "label",
"value": "Sample"
},
{
"type": "dropDown",
"value": "USD",
"options": [ "USD", "INR", "Dollar" ]
},
{
"type": "text",
"value": "50"
},
{
"type": "label",
"value": ".Sample"
},
{
"type": "dropDown",
"value": "USD",
"options": [ "USD", "INR", "Dollar" ]
},
{
"type": "text",
"value": "50"
},
{
"type": "label",
"value": ", on Lloyd's paper, in respect of Canadian domiciled Property risks<br/>Your authority for Health extends to unlimited Healthcare where required by statute<br/>You may accept up to "
},
{
"type": "dropDown",
"value": "USD",
"options": [ "USD", "INR", "Dollar" ]
},
{
"type": "text",
"value": "50"
},
{
"type": "label",
"value": ", on Lloyd's paper, in respect of declarations under the Coast P&I Facility<br/>You may accept up to "
},
{
"type": "dropDown",
"value": "USD",
"options": [ "USD", "INR", "Dollar" ]
},
{
"type": "text",
"value": "50"
},
{
"type": "label",
"value": ", on Lloyd's paper, in respect of combined primary and excess grounding liability<br/>"
}
],
"order": "6",
"status": "Active",
"startDate": "2018-12-12T00:00:00",
"endDate": null,
"displayColumns": [],
"tableValues": null,
"placeHolderValues": "",
"organizationDataView": [
{
"id": "{8b958d63-d605-4b9a-a3c4-a3c1c052316e}-{1}",
"orgGroupName": "QQ",
"orgGroupType": "DD",
"orgLevel": 1,
"orgParentGroupId": ""
}
],
"id": "{22505164-4d56-493e-8df2-b1bb53ab419a-uw}-{1}",
"_etag": "\"0d00acca-0000-0c00-0000-5c94ef400000\"",
"partitionKey": "GGG-CCCCOOOOO-{22505164-4d56-493e-8df2-b1bb53ab419a-uw}-{1}",
"type": "CCCCOOOOO",
"clientId": "GGG",
"createdBy": "MM",
"createdDate": "2018-12-12T00:00:00",
"modifiedBy": "PPP",
"modifiedDate": null,
"isactive": false
},
{
"dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
"baseDataid": "{ac949799-60c7-4f85-840f-f30203c5ee43}-{1}",
"subType": "Block",
"sectionView": {
"id": "{fca09906-dff9-40b2-a971-28fef7f37dbf}-{1}",
"title": "GR",
"description": "",
"order": "2"
},
"title": "",
"description": "Sample",
"order": "1",
"status": "Active",
"startDate": "2018-12-12T00:00:00",
"endDate": null,
"displayColumns": [],
"tableValues": null,
"placeHolderValues": "",
"organizationDataView": [
{
"id": "{8b958d63-d605-4b9a-a3c4-a3c1c052316e}-{1}",
"orgGroupName": "QQ",
"orgGroupType": "DD",
"orgLevel": 1,
"orgParentGroupId": ""
}
],
"id": "{8652fedc-0d7c-48d8-bc3f-577294551671-uw}-{1}",
"_etag": "\"0d00baca-0000-0c00-0000-5c94ef400000\"",
"partitionKey": "GGG-CCCCOOOOO-{8652fedc-0d7c-48d8-bc3f-577294551671-uw}-{1}",
"type": "CCCCOOOOO",
"clientId": "GGG",
"createdBy": "MM",
"createdDate": "2018-12-12T00:00:00",
"modifiedBy": "PPP",
"modifiedDate": null,
"isactive": false
},
{
"dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
"baseDataid": "{522f1248-0882-4348-9bba-59c056c816c8}-{1}",
"subType": "Clause",
"sectionView": {
"id": "{b3cdda34-1fd2-4463-9aa0-24beff4b83fe}-{1}",
"title": "LLL",
"description": "",
"order": "3"
},
"title": "UP",
"Description": [
{
"type": "label",
"value": "Sample"
}
],
"order": "1",
"status": "Active",
"startDate": "2018-12-12T00:00:00",
"endDate": null,
"displayColumns": [],
"tableValues": null,
"placeHolderValues": "",
"organizationDataView": [
{
"id": "{8b958d63-d605-4b9a-a3c4-a3c1c052316e}-{1}",
"orgGroupName": "QQ",
"orgGroupType": "DD",
"orgLevel": 1,
"orgParentGroupId": ""
}
],
"id": "{944eae3d-fa0f-4b0e-9c66-3499a16fc2fd-uw}-{1}",
"_etag": "\"0d00bfca-0000-0c00-0000-5c94ef400000\"",
"partitionKey": "GGG-CCCCOOOOO-{944eae3d-fa0f-4b0e-9c66-3499a16fc2fd-uw}-{1}",
"type": "CCCCOOOOO",
"clientId": "GGG",
"createdBy": "MM",
"createdDate": "2018-12-12T00:00:00",
"modifiedBy": "PPP",
"modifiedDate": null,
"isactive": false
},
{
"dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
"baseDataid": "{6c6a3c80-3536-4c51-8ccf-fcdc16d94090}-{1}",
"subType": "Table",
"sectionView": {
"id": "{9cfb60cf-354c-4194-9e2e-6bab41c6b280}-{1}",
"title": "KKPKPKPK",
"description": "",
"order": "4"
},
"title": "PT",
"description": "",
"order": "4",
"status": "Active",
"startDate": "2018-12-12T00:00:00",
"endDate": null,
"displayColumns": [ ".", "KKKKKKK", "EP", "P" ],
"tableValues": [
{
".": "Level 11",
"KKKKKKK": "",
"EP": "Level 21",
"P": "",
"isRowEditable": false
},
{
".": "Asbestos - other than licensed removers",
"KKKKKKK": "GBP 5M",
"EP": ".",
"isRowEditable": false
},
{
".": "Auto manufacturing - safety critical components",
"KKKKKKK": "GBP 10M",
"EP": ".",
"isRowEditable": false
},
{
".": "Rail - contracting companies",
"KKKKKKK": "GBP 5M",
"EP": ".",
"isRowEditable": false
},
{
".": "Asbestos - other than licensed removers",
"KKKKKKK": ".",
"EP": "GBP 10M",
"isRowEditable": false
},
{
".": "Rail - contracting companies",
"KKKKKKK": ".",
"EP": "GBP 10M",
"isRowEditable": false
}
],
"placeHolderValues": "",
"organizationDataView": [
{
"id": "{8b958d63-d605-4b9a-a3c4-a3c1c052316e}-{1}",
"orgGroupName": "QQ",
"orgGroupType": "DD",
"orgLevel": 1,
"orgParentGroupId": "."
}
],
"id": "{91de8a0b-4156-4121-be05-844b03928c29-uw}-{1}",
"_etag": "\"0d00c5ca-0000-0c00-0000-5c94ef410000\"",
"partitionKey": "GGG-CCCCOOOOO-{91de8a0b-4156-4121-be05-844b03928c29-uw}-{1}",
"type": "CCCCOOOOO",
"clientId": "GGG",
"createdBy": "MM",
"createdDate": "2018-12-12T00:00:00",
"modifiedBy": "PPP",
"modifiedDate": null,
"isactive": false
},
{
"dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
"baseDataid": "{92860693-e038-4a58-814c-6a74d59e7cce}-{1}",
"subType": "Clause",
"sectionView": {
"id": "{9cfb60cf-354c-4194-9e2e-6bab41c6b280}-{1}",
"title": "KKPKPKPK",
"description": "",
"order": "4"
},
"title": "",
"Description": [
{
"type": "label",
"value": "Sample"
}
],
"order": "9",
"status": "Active",
"startDate": "2018-12-12T00:00:00",
"endDate": null,
"displayColumns": [],
"tableValues": null,
"placeHolderValues": "",
"organizationDataView": [
{
"id": "{8b958d63-d605-4b9a-a3c4-a3c1c052316e}-{1}",
"orgGroupName": "QQ",
"orgGroupType": "DD",
"orgLevel": 1,
"orgParentGroupId": ""
}
],
"id": "{af17341e-a88c-4564-8296-c513e3708af2-uw-per}-{1}",
"_etag": "\"0d00e3ca-0000-0c00-0000-5c94ef420000\"",
"partitionKey": "GGG-CCCCOOOOO-{af17341e-a88c-4564-8296-c513e3708af2-uw-per}-{1}",
"type": "CCCCOOOOO",
"clientId": "GGG",
"createdBy": "MM",
"createdDate": "2018-12-12T00:00:00",
"modifiedBy": "PPP",
"modifiedDate": null,
"isactive": false
},
{
"dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
"baseDataid": "{92860693-e038-4a58-814c-6a74d59e7cce}-{1}",
"subType": "Clause",
"sectionView": {
"id": "{9cfb60cf-354c-4194-9e2e-6bab41c6b280}-{1}",
"title": "KKPKPKPK",
"description": "",
"order": "4"
},
"title": "PL",
"Description": [
{
"type": "label",
"value": "Sample"
}
],
"order": "7",
"status": "Active",
"startDate": "2018-12-12T00:00:00",
"endDate": null,
"displayColumns": [],
"tableValues": null,
"placeHolderValues": "",
"organizationDataView": [
{
"id": "{8b958d63-d605-4b9a-a3c4-a3c1c052316e}-{1}",
"orgGroupName": "QQ",
"orgGroupType": "DD",
"orgLevel": 1,
"orgParentGroupId": ""
}
],
"id": "{af17341e-a88c-4564-8296-c513e3708af2-uw}-{1}",
"_etag": "\"0d00e8ca-0000-0c00-0000-5c94ef420000\"",
"partitionKey": "GGG-CCCCOOOOO-{af17341e-a88c-4564-8296-c513e3708af2-uw}-{1}",
"type": "CCCCOOOOO",
"clientId": "GGG",
"createdBy": "MM",
"createdDate": "2018-12-12T00:00:00",
"modifiedBy": "PPP",
"modifiedDate": null,
"isactive": false
},
{
"dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
"baseDataid": "{92c5bd05-c8a2-45c1-a1e9-fd3f78c705ab}-{1}",
"subType": "Table",
"sectionView": {
"id": "{9cfb60cf-354c-4194-9e2e-6bab41c6b280}-{1}",
"title": "KKPKPKPK",
"description": "",
"order": "4"
},
"title": "KKPKPKPK PP",
"description": "",
"order": "1",
"status": "Active",
"startDate": "2018-12-12T00:00:00",
"endDate": null,
"displayColumns": [ "N", "kkk", "LPLPLPL", "Ccy", "M", "LTLT", "P" ],
"tableValues": [
{
"N": "Level 11",
"kkk": "",
"LPLPLPL": "",
"Ccy": "",
"M": "",
"LTLT": "",
"P": "",
"isRowEditable": false
},
{
"N": "Level 11",
"kkk": "",
"LPLPLPL": "",
"Ccy": "",
"M": "11",
"LTLT": "",
"P": "",
"isRowEditable": false
},
{
"N": "QQQl",
"kkk": "QQQQ",
"LPLPLPL": "DDDD",
"Ccy": "GBP",
"M": "10M",
"LTLT": "Any one vessel",
"isRowEditable": false
},
{
"N": "Marine Cargo",
"kkk": "QIEL",
"LPLPLPL": "Lineslip and other non-coverholder facilities",
"Ccy": "GBP",
"M": "5M",
"LTLT": "Any one event",
"isRowEditable": false
},
{
"N": "KKKK",
"kkk": "PPPP",
"LPLPLPL": "DDDD",
"Ccy": "GBP",
"M": "20M",
"LTLT": "Any one vessel",
"isRowEditable": false
}
],
"placeHolderValues": "",
"organizationDataView": [
{
"id": "{8b958d63-d605-4b9a-a3c4-a3c1c052316e}-{1}",
"orgGroupName": "QQ",
"orgGroupType": "DD",
"orgLevel": 1,
"orgParentGroupId": ""
}
],
"id": "{d036bc60-db2d-4c93-86ff-981a62e207ca-uw}-{1}",
"_etag": "\"0d00eacb-0000-0c00-0000-5c94ef530000\"",
"partitionKey": "GGG-CCCCOOOOO-{d036bc60-db2d-4c93-86ff-981a62e207ca-uw}-{1}",
"type": "CCCCOOOOO",
"clientId": "GGG",
"createdBy": "MM",
"createdDate": "2018-12-12T00:00:00",
"modifiedBy": "PPP",
"modifiedDate": null,
"isactive": false
},
{
"dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
"baseDataid": "{bf1f6e82-6afd-4837-81ab-acabc665da14}-{1}",
"subType": "Clause",
"sectionView": {
"id": "{b3cdda34-1fd2-4463-9aa0-24beff4b83fe}-{1}",
"title": "LLL",
"description": "",
"order": "3"
},
"title": "klklkl",
"Description": [
{
"type": "label",
"value": "sAMPLE tEXT"
}
],
"order": "4",
"status": "Active",
"startDate": "2018-12-12T00:00:00",
"endDate": null,
"displayColumns": [],
"tableValues": null,
"placeHolderValues": "",
"organizationDataView": [
{
"id": "{8b958d63-d605-4b9a-a3c4-a3c1c052316e}-{1}",
"orgGroupName": "QQ",
"orgGroupType": "DD",
"orgLevel": 1,
"orgParentGroupId": ""
}
],
"id": "{QQ-851f96e7-542f-4a57-a0b1-35feb4698f5e-uw}-{1}",
"_etag": "\"0d0062cc-0000-0c00-0000-5c94ef5a0000\"",
"partitionKey": "GGG-CCCCOOOOO-{QQ-851f96e7-542f-4a57-a0b1-35feb4698f5e-uw}-{1}",
"type": "CCCCOOOOO",
"clientId": "GGG",
"createdBy": "MM",
"createdDate": "2018-12-12T00:00:00",
"modifiedBy": "PPP",
"modifiedDate": null,
"isactive": false
}
]
}
getClauseData(dalContentdata) {
let dynamicClauseHtmlSource = '<h4>' + dalContentdata.title + '</h4>';
dynamicClauseHtmlSource = dynamicClauseHtmlSource + '<p></p>';
dynamicClauseHtmlSource = dynamicClauseHtmlSource + + '<p style="text-align:justify;line-height:0.3em">' + dalContentdata.description + '</p>';
dynamicClauseHtmlSource = this.brToNewLine(dynamicClauseHtmlSource);
return dynamicClauseHtmlSource;
}
getBlockData(dalContentdata) {
let dynamicBlockHtmlSource = '<h4>' + dalContentdata.title + '</h4>';
dynamicBlockHtmlSource = dynamicBlockHtmlSource + '<p></p>';
dynamicBlockHtmlSource = dynamicBlockHtmlSource + dalContentdata.description;
dynamicBlockHtmlSource = this.brToNewLine(dynamicBlockHtmlSource);
return dynamicBlockHtmlSource;
}
getTableData(dalContentdata) {
let tableSource = "<table>";
tableSource = tableSource + "<tr>";
for (var k = 0; k < dalContentdata.displayColumns.length; k++) {
tableSource = tableSource + "<th style='word-wrap: break-word'>" + dalContentdata.displayColumns[k] + "</th>";
}
tableSource = tableSource + "</tr>";
for (var j = 0; j < dalContentdata.tableValues.length; j++) {
tableSource = tableSource + "<tr>";
for (var k = 0; k < dalContentdata.displayColumns.length; k++) {
tableSource = tableSource + "<td style='word-wrap: break-word'>" + dalContentdata.tableValues[0][dalContentdata.displayColumns[k]] + "</td>";
}
tableSource = tableSource + "</tr>";
}
tableSource = tableSource + "</table>";
return tableSource;
}
brToNewLine(str) {
return str.replace(/<br ?\/?>/g, "\n");
}
Previously we are using https://finance.yahoo.com/webservice/v1/symbols/allcurrencies/quote?format=json to get all the currencies exchange rate for our application. However, realized that currently this link doesn't work anymore. What should we use now?
You can use YahooFinancials (Python Module) to get currency data from YahooFinanace:
$ pip install yahoofinancials
https://github.com/JECSand/yahoofinancials
from yahoofinancials import YahooFinancials
currencies = ['EURUSD=X', 'JPY=X', 'GBPUSD=X']
yahoo_financials_currencies = YahooFinancials(currencies)
print(yahoo_financials_currencies.get_historical_price_data("2018-08-01", "2018-08-10", "daily"))
Which returns:
{
"JPY=X": {
"eventsData": {},
"firstTradeDate": {
"date": 846633600,
"formatted_date": "1996-10-30"
},
"currency": "JPY",
"prices": [
{
"high": 112.13700103759766,
"volume": 0,
"formatted_date": "2018-07-31",
"low": 111.69999694824219,
"adjclose": 111.80799865722656,
"date": 1533078000,
"close": 111.80799865722656,
"open": 111.79499816894531
},
{
"high": 111.7239990234375,
"volume": 0,
"formatted_date": "2018-08-01",
"low": 111.33000183105469,
"adjclose": 111.62000274658203,
"date": 1533164400,
"close": 111.62000274658203,
"open": 111.63700103759766
},
{
"high": 111.78299713134766,
"volume": 0,
"formatted_date": "2018-08-02",
"low": 111.0999984741211,
"adjclose": 111.69000244140625,
"date": 1533250800,
"close": 111.69000244140625,
"open": 111.6989974975586
},
{
"high": 111.52200317382812,
"volume": 0,
"formatted_date": "2018-08-05",
"low": 111.16699981689453,
"adjclose": 111.23400115966797,
"date": 1533510000,
"close": 111.23400115966797,
"open": 111.21700286865234
},
{
"high": 111.36399841308594,
"volume": 0,
"formatted_date": "2018-08-06",
"low": 110.9990005493164,
"adjclose": 111.33999633789062,
"date": 1533596400,
"close": 111.33999633789062,
"open": 111.3280029296875
},
{
"high": 111.41999816894531,
"volume": 0,
"formatted_date": "2018-08-07",
"low": 110.83999633789062,
"adjclose": 111.34500122070312,
"date": 1533682800,
"close": 111.34500122070312,
"open": 111.34700012207031
},
{
"high": 111.1780014038086,
"volume": 0,
"formatted_date": "2018-08-08",
"low": 110.70999908447266,
"adjclose": 110.89199829101562,
"date": 1533769200,
"close": 110.89199829101562,
"open": 110.90299987792969
},
{
"high": 111.12799835205078,
"volume": 0,
"formatted_date": "2018-08-09",
"low": 110.51799774169922,
"adjclose": 111.09100341796875,
"date": 1533855600,
"close": 111.09100341796875,
"open": 111.06400299072266
}
],
"timeZone": {
"gmtOffset": 3600
},
"instrumentType": "CURRENCY"
},
"EURUSD=X": {
"eventsData": {},
"firstTradeDate": {
"date": 1070236800,
"formatted_date": "2003-12-01"
},
"currency": "USD",
"prices": [
{
"high": 1.169864296913147,
"volume": 0,
"formatted_date": "2018-07-31",
"low": 1.166534423828125,
"adjclose": 1.168961763381958,
"date": 1533078000,
"close": 1.168961763381958,
"open": 1.168961763381958
},
{
"high": 1.1669973134994507,
"volume": 0,
"formatted_date": "2018-08-01",
"low": 1.1604158878326416,
"adjclose": 1.1665889024734497,
"date": 1533164400,
"close": 1.1665889024734497,
"open": 1.1663848161697388
},
{
"high": 1.1612001657485962,
"volume": 0,
"formatted_date": "2018-08-02",
"low": 1.1562163829803467,
"adjclose": 1.1586008071899414,
"date": 1533250800,
"close": 1.1586008071899414,
"open": 1.1585606336593628
},
{
"high": 1.1570056676864624,
"volume": 0,
"formatted_date": "2018-08-05",
"low": 1.1530966758728027,
"adjclose": 1.1562297344207764,
"date": 1533510000,
"close": 1.1562297344207764,
"open": 1.156136155128479
},
{
"high": 1.1609008312225342,
"volume": 0,
"formatted_date": "2018-08-06",
"low": 1.1552013158798218,
"adjclose": 1.1558021306991577,
"date": 1533596400,
"close": 1.1558021306991577,
"open": 1.155748724937439
},
{
"high": 1.1629259586334229,
"volume": 0,
"formatted_date": "2018-08-07",
"low": 1.1574609279632568,
"adjclose": 1.1602946519851685,
"date": 1533682800,
"close": 1.1602946519851685,
"open": 1.1603351831436157
},
{
"high": 1.1621150970458984,
"volume": 0,
"formatted_date": "2018-08-08",
"low": 1.156176209449768,
"adjclose": 1.1610760688781738,
"date": 1533769200,
"close": 1.1610760688781738,
"open": 1.1610087156295776
},
{
"high": 1.1539349555969238,
"volume": 0,
"formatted_date": "2018-08-09",
"low": 1.1396141052246094,
"adjclose": 1.1523923873901367,
"date": 1533855600,
"close": 1.1523923873901367,
"open": 1.1528706550598145
}
],
"timeZone": {
"gmtOffset": 3600
},
"instrumentType": "CURRENCY"
},
"GBPUSD=X": {
"eventsData": {},
"firstTradeDate": {
"date": 1070236800,
"formatted_date": "2003-12-01"
},
"currency": "USD",
"prices": [
{
"high": 1.314578652381897,
"volume": 0,
"formatted_date": "2018-07-31",
"low": 1.3097577095031738,
"adjclose": 1.3121638298034668,
"date": 1533078000,
"close": 1.3121638298034668,
"open": 1.3118367195129395
},
{
"high": 1.3128528594970703,
"volume": 0,
"formatted_date": "2018-08-01",
"low": 1.3018969297409058,
"adjclose": 1.3126115798950195,
"date": 1533164400,
"close": 1.3126115798950195,
"open": 1.3125253915786743
},
{
"high": 1.3043080568313599,
"volume": 0,
"formatted_date": "2018-08-02",
"low": 1.2976226806640625,
"adjclose": 1.3018121719360352,
"date": 1533250800,
"close": 1.3018121719360352,
"open": 1.301574945449829
},
{
"high": 1.3007283210754395,
"volume": 0,
"formatted_date": "2018-08-05",
"low": 1.292073130607605,
"adjclose": 1.3003562688827515,
"date": 1533510000,
"close": 1.3003562688827515,
"open": 1.300153374671936
},
{
"high": 1.2973533868789673,
"volume": 0,
"formatted_date": "2018-08-06",
"low": 1.2938284873962402,
"adjclose": 1.2944984436035156,
"date": 1533596400,
"close": 1.2944984436035156,
"open": 1.294247031211853
},
{
"high": 1.2961763143539429,
"volume": 0,
"formatted_date": "2018-08-07",
"low": 1.2855453491210938,
"adjclose": 1.2946659326553345,
"date": 1533682800,
"close": 1.2946659326553345,
"open": 1.2946659326553345
},
{
"high": 1.2911388874053955,
"volume": 0,
"formatted_date": "2018-08-08",
"low": 1.2843565940856934,
"adjclose": 1.2881617546081543,
"date": 1533769200,
"close": 1.2881617546081543,
"open": 1.2879958152770996
},
{
"high": 1.283861756324768,
"volume": 0,
"formatted_date": "2018-08-09",
"low": 1.2726045846939087,
"adjclose": 1.2828407287597656,
"date": 1533855600,
"close": 1.2828407287597656,
"open": 1.2830052375793457
}
],
"timeZone": {
"gmtOffset": 3600
},
"instrumentType": "CURRENCY"
}
}
From here you can easily save this JSON data to a file if needed.