Skip to content

Commit 0e66ed0

Browse files
authored
fix c# sample code
1 parent d92dde2 commit 0e66ed0

File tree

1 file changed

+26
-30
lines changed

1 file changed

+26
-30
lines changed

README.md

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -69,33 +69,31 @@ An `Api2PdfResponse` object is returned from every API call. If a call is unsucc
6969

7070
**Convert HTML to PDF (load PDF in browser window and specify a file name)**
7171

72-
var apiResponse = a2pClient.WkHtmlToPdf.FromHtml("<p>Hello, World</p>", inline=true, outputFileName="test.pdf");
72+
var apiResponse = a2pClient.WkHtmlToPdf.FromHtml("<p>Hello, World</p>", inline: true, outputFileName: "test.pdf");
7373

74-
**Convert HTML to PDF (use keyword arguments for advanced wkhtmltopdf settings)**
74+
**Convert HTML to PDF (use dictionary for advanced wkhtmltopdf settings)**
7575
[View full list of wkhtmltopdf options available.](https://www.api2pdf.com/documentation/advanced-options-wkhtmltopdf/)
7676

77-
options = {
78-
'orientation': 'landscape',
79-
'pageSize': 'A4'
80-
}
81-
var apiResponse = a2pClient.WkHtmlToPdf.FromHtml("<p>Hello, World</p>", **options);
77+
var options = new Dictionary<string, string>();
78+
options.Add("orientation", "landscape");
79+
options.Add("pageSize", "Letter");
80+
var apiResponse = a2pClient.WkHtmlToPdf.FromHtml("<p>Hello, World</p>", options: options);
8281

8382
**Convert URL to PDF**
8483

8584
var apiResponse = a2pClient.WkHtmlToPdf.FromUrl("http://www.api2pdf.com");
8685

8786
**Convert URL to PDF (load PDF in browser window and specify a file name)**
8887

89-
var apiResponse = a2pClient.WkHtmlToPdf.FromUrl("http://www.api2pdf.com", inline=true, outputFileName="test.pdf");
88+
var apiResponse = a2pClient.WkHtmlToPdf.FromUrl("http://www.api2pdf.com", inline: true, outputFileName: "test.pdf");
9089

9190
**Convert URL to PDF (use keyword arguments for advanced wkhtmltopdf settings)**
9291
[View full list of wkhtmltopdf options available.](https://www.api2pdf.com/documentation/advanced-options-wkhtmltopdf/)
9392

94-
options = {
95-
'orientation': 'landscape',
96-
'pageSize': 'A4'
97-
}
98-
var apiResponse = a2pClient.WkHtmlToPdf.FromUrl("http://www.api2pdf.com", **options);
93+
var options = new Dictionary<string, string>();
94+
options.Add("orientation", "landscape");
95+
options.Add("pageSize", "Letter");
96+
var apiResponse = a2pClient.WkHtmlToPdf.FromUrl("http://www.api2pdf.com", options: options);
9997

10098

10199
---
@@ -108,33 +106,31 @@ An `Api2PdfResponse` object is returned from every API call. If a call is unsucc
108106

109107
**Convert HTML to PDF (load PDF in browser window and specify a file name)**
110108

111-
var apiResponse = a2pClient.HeadlessChrome.FromHtml("<p>Hello, World</p>", inline=true, outputFileName="test.pdf");
109+
var apiResponse = a2pClient.HeadlessChrome.FromHtml("<p>Hello, World</p>", inline: true, outputFileName: "test.pdf");
112110

113111
**Convert HTML to PDF (use keyword arguments for advanced Headless Chrome settings)**
114112
[View full list of Headless Chrome options available.](https://www.api2pdf.com/documentation/advanced-options-headless-chrome/)
115113

116-
options = {
117-
'orientation': 'landscape',
118-
'pageSize': 'A4'
119-
}
120-
var apiResponse = a2pClient.HeadlessChrome.FromHtml("<p>Hello, World</p>", **options);
114+
var options = new Dictionary<string, string>();
115+
options.Add("orientation", "landscape");
116+
options.Add("pageSize", "Letter");
117+
var apiResponse = a2pClient.HeadlessChrome.FromHtml("<p>Hello, World</p>", options: options);
121118

122119
**Convert URL to PDF**
123120

124121
var apiResponse = a2pClient.HeadlessChrome.FromUrl("http://www.api2pdf.com");
125122

126123
**Convert URL to PDF (load PDF in browser window and specify a file name)**
127124

128-
var apiResponse = a2pClient.HeadlessChrome.FromUrl("http://www.api2pdf.com", inline=true, outputFileName="test.pdf");
125+
var apiResponse = a2pClient.HeadlessChrome.FromUrl("http://www.api2pdf.com", inline: true, outputFileName: "test.pdf");
129126

130-
**Convert URL to PDF (use keyword arguments for advanced Headless Chrome settings)**
127+
**Convert URL to PDF (use dictionary for advanced Headless Chrome settings)**
131128
[View full list of Headless Chrome options available.](https://www.api2pdf.com/documentation/advanced-options-headless-chrome/)
132129

133-
options = {
134-
'orientation': 'landscape',
135-
'pageSize': 'A4'
136-
}
137-
var apiResponse = a2pClient.HeadlessChrome.FromUrl("http://www.api2pdf.com", **options);
130+
var options = new Dictionary<string, string>();
131+
options.Add("orientation", "landscape");
132+
options.Add("pageSize", "Letter");
133+
var apiResponse = a2pClient.HeadlessChrome.FromUrl("http://www.api2pdf.com", options: options);
138134

139135
---
140136

@@ -152,7 +148,7 @@ You must provide a url to the file. Our engine will consume the file at that URL
152148

153149
**Convert Microsoft Office Document or Image to PDF (load PDF in browser window and specify a file name)**
154150

155-
var apiResponse = a2pClient.LibreOffice.Convert("https://www.api2pdf.com/wp-content/themes/api2pdf/assets/samples/sample-word-doc.docx", inline=true, outputFileName="test.pdf");
151+
var apiResponse = a2pClient.LibreOffice.Convert("https://www.api2pdf.com/wp-content/themes/api2pdf/assets/samples/sample-word-doc.docx", inline: true, outputFileName: "test.pdf");
156152

157153
---
158154

@@ -168,7 +164,7 @@ To use the merge endpoint, supply a list of urls to existing PDFs. The engine wi
168164
**Merge PDFs from list of URLs to existing PDFs (load PDF in browser window and specify a file name)**
169165

170166
var links_to_pdfs = new List<string>() {"https://LINK-TO-PDF", "https://LINK-TO-PDF"};
171-
var apiResponse = a2pClient.Merge(links_to_pdfs, inline=true, outputFileName="test.pdf");
167+
var apiResponse = a2pClient.Merge(links_to_pdfs, inline: true, outputFileName: "test.pdf");
172168

173169
---
174170

@@ -180,7 +176,7 @@ On any `Api2PdfResponse` that succesfully generated a pdf, you can use the handy
180176

181177
var a2pClient = Api2Pdf("YOUR-API-KEY");
182178
var links_to_pdfs = new List<string>() {"https://LINK-TO-PDF", "https://LINK-TO-PDF"};
183-
var apiResponse = a2pClient.Merge(links_to_pdfs, inline=true, outputFileName="test.pdf");
179+
var apiResponse = a2pClient.Merge(links_to_pdfs, inline: true, outputFileName: "test.pdf");
184180
apiResponse.SavePdf("path-to-local-folder");
185181

186182
**byte[] Api2PdfResponse.GetPdfBytes()**
@@ -189,7 +185,7 @@ You can use `GetPdfBytes()` method to download the pdf to a byte array.
189185

190186
var a2pClient = Api2Pdf("YOUR-API-KEY");
191187
var links_to_pdfs = new List<string>() {"https://LINK-TO-PDF", "https://LINK-TO-PDF"};
192-
var apiResponse = a2pClient.Merge(links_to_pdfs, inline=true, outputFileName="test.pdf");
188+
var apiResponse = a2pClient.Merge(links_to_pdfs, inline: true, outputFileName: "test.pdf");
193189
apiResponse.GetPdfBytes();
194190

195191
---

0 commit comments

Comments
 (0)