@@ -17,8 +17,6 @@ To convert HTML to PDF, send a request to the /v1/conversion/html-to-pdf endpoin
1717
1818{% highlight c# tabtitle="Curl" %}
1919
20- For URL
21-
2220curl --location 'http://localhost:8003/v1/conversion/html-to-pdf ' \
2321 --form-string 'settings={
2422 "JobID": "job-123",
@@ -41,36 +39,10 @@ curl --location 'http://localhost:8003/v1/conversion/html-to-pdf' \
4139 }
4240 }'
4341
44- For File
45-
46- curl --location 'http://localhost:8003/v1/conversion/html-to-pdf ' \
47- --form-string 'settings={
48- "JobID": "job-123",
49- "IndexFile":"index.html",
50- "PaperSize": "A4",
51- "Settings": {
52- "Url": "",
53- "AdditionalDelay": 500,
54- "EnableScripts": true,
55- "EnableLinks": true,
56- "EnableBookmarks": true,
57- "EnableForms": false,
58- "EnableToc": false,
59- "Margins": 24,
60- "Rotation": 0,
61- "Orientation": "Portrait",
62- "SinglePagePdf": false,
63- "ShowHeader": true,
64- "ShowFooter": true
65- }
66- }'
67-
6842{% endhighlight %}
6943
7044{% highlight javaScript tabtitle="JavaScript" %}
7145
72- For Url
73-
7446const formdata = new FormData();
7547formdata.append(
7648 "settings",
@@ -96,7 +68,90 @@ formdata.append(
9668 })
9769 );
9870
99- For File
71+ const requestOptions = {
72+ method: "POST",
73+ body: formdata,
74+ redirect: "follow"
75+ };
76+
77+ fetch("http://localhost:8003/v1/conversion/html-to-pdf ", requestOptions)
78+ .then((response) => response.text())
79+ .then((result) => console.log(result))
80+ .catch((error) => console.error(error));
81+
82+ {% endhighlight %}
83+
84+ {% highlight c# tabtitle="C#" %}
85+
86+ var client = new HttpClient();
87+ var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost:8003/v1/conversion/html-to-pdf ");
88+ var content = new MultipartFormDataContent();
89+
90+ var settings = new
91+ {
92+ JobID = "job-300",
93+ "IndexFile":"",
94+ PaperSize = "A4",
95+ Settings = new
96+ {
97+ Url = "https://example.com/guide ",
98+ AdditionalDelay = 700,
99+ EnableScripts = true,
100+ Enablelinks = true,
101+ EnableBookmarks = true,
102+ EnableForms = false,
103+ EnableToc = false,
104+ Margins = 24,
105+ Rotation = 0,
106+ Orientation = "Portrait",
107+ SinglePagePdf = false,
108+ ShowHeader = true,
109+ ShowFooter = true
110+ }
111+ };
112+
113+ content.Add(new StringContent(JsonSerializer.Serialize(settings)), "settings");
114+ request.Content = content;
115+
116+ var response = await client.SendAsync(request);
117+ response.EnsureSuccessStatusCode();
118+ Console.WriteLine(await response.Content.ReadAsStringAsync());
119+
120+ {% endhighlight %}
121+
122+ {% endtabs %}
123+
124+ To convert HTML to PDF, send a request to the /v1/conversion/html-to-pdf endpoint, including the HTML file as input as follows:
125+
126+ {% tabs %}
127+
128+ {% highlight c# tabtitle="Curl" %}
129+
130+ curl --location 'http://localhost:8003/v1/conversion/html-to-pdf ' \
131+ --form-string 'settings={
132+ "JobID": "job-123",
133+ "IndexFile":"index.html",
134+ "PaperSize": "A4",
135+ "Settings": {
136+ "Url": "",
137+ "AdditionalDelay": 500,
138+ "EnableScripts": true,
139+ "EnableLinks": true,
140+ "EnableBookmarks": true,
141+ "EnableForms": false,
142+ "EnableToc": false,
143+ "Margins": 24,
144+ "Rotation": 0,
145+ "Orientation": "Portrait",
146+ "SinglePagePdf": false,
147+ "ShowHeader": true,
148+ "ShowFooter": true
149+ }
150+ }'
151+
152+ {% endhighlight %}
153+
154+ {% highlight javaScript tabtitle="JavaScript" %}
100155
101156const formdata = new FormData();
102157formdata.append(
@@ -142,33 +197,6 @@ var client = new HttpClient();
142197var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost:8003/v1/conversion/html-to-pdf ");
143198var content = new MultipartFormDataContent();
144199
145- For Url
146-
147- var settings = new
148- {
149- JobID = "job-300",
150- "IndexFile":"",
151- PaperSize = "A4",
152- Settings = new
153- {
154- Url = "https://example.com/guide ",
155- AdditionalDelay = 700,
156- EnableScripts = true,
157- Enablelinks = true,
158- EnableBookmarks = true,
159- EnableForms = false,
160- EnableToc = false,
161- Margins = 24,
162- Rotation = 0,
163- Orientation = "Portrait",
164- SinglePagePdf = false,
165- ShowHeader = true,
166- ShowFooter = true
167- }
168- };
169-
170- For File
171-
172200var settings = new
173201{
174202 JobID = "job-300",
@@ -192,7 +220,6 @@ var settings = new
192220 }
193221};
194222
195-
196223content.Add(new StringContent(JsonSerializer.Serialize(settings)), "settings");
197224request.Content = content;
198225
0 commit comments