@@ -169,7 +169,7 @@ public Uri WebApiBaseUrl
169169 // - ReturnFormat ReturnFormat (default = PDF)
170170 // - bool Append (default = true)
171171 //
172- // Return value: A List of strings (the documents as Base64 encoded strings)
172+ // Return value: A List of byte[]
173173 *-----------------------------------------------------------------------------------------------------*/
174174 /// <summary>
175175 /// This method merges a template with data.
@@ -178,7 +178,7 @@ public Uri WebApiBaseUrl
178178 /// <param name="templateName">The name of the template in the template storage.</param>
179179 /// <param name="returnFormat">The document format of the resulting document.</param>
180180 /// <param name="append">Specifies whether the resulting documents should be appended or not.</param>
181- public List < string > MergeDocument ( MergeBody mergeBody ,
181+ public List < byte [ ] > MergeDocument ( MergeBody mergeBody ,
182182 string templateName = null ,
183183 ReturnFormat returnFormat = ReturnFormat . PDF ,
184184 bool append = true )
@@ -195,7 +195,15 @@ public List<string> MergeDocument(MergeBody mergeBody,
195195 // if sucessful, return the image list
196196 if ( response . IsSuccessStatusCode )
197197 {
198- return response . Content . ReadAsAsync < List < string > > ( ) . Result ;
198+ List < byte [ ] > bResults = new List < byte [ ] > ( ) ;
199+
200+ foreach ( string sResult in response . Content . ReadAsAsync < List < string > > ( ) . Result )
201+ {
202+ bResults . Add ( Convert . FromBase64String ( sResult ) ) ;
203+ }
204+
205+ return bResults ;
206+ //return response.Content.ReadAsAsync<List<string>>().Result;
199207 }
200208 else
201209 {
@@ -251,9 +259,9 @@ public void UploadTemplate(string templateName, byte[] template)
251259 /// <summary>
252260 /// This method converts a document to another format.
253261 /// </summary>
254- /// <param name="document">The source document data encoded as a Base64 string .</param>
262+ /// <param name="document">The source document data as a byte array .</param>
255263 /// <param name="returnFormat">The document format of the resulting document.</param>
256- public string ConvertDocument ( byte [ ] document , ReturnFormat returnFormat )
264+ public byte [ ] ConvertDocument ( byte [ ] document , ReturnFormat returnFormat )
257265 {
258266 // create a new HttpClient using the Factory method CreateHttpClient
259267 using ( HttpClient client = CreateHttpClient ( ) )
@@ -263,10 +271,10 @@ public string ConvertDocument(byte[] document, ReturnFormat returnFormat)
263271 HttpResponseMessage response = client . PostAsync ( "v1/document/convert?returnFormat=" + returnFormat ,
264272 Convert . ToBase64String ( document ) , formatter ) . Result ;
265273
266- // if sucessful, return the image list
274+ // if sucessful, return the document list
267275 if ( response . IsSuccessStatusCode )
268276 {
269- return response . Content . ReadAsAsync < string > ( ) . Result ;
277+ return Convert . FromBase64String ( response . Content . ReadAsAsync < string > ( ) . Result ) ;
270278 }
271279 else
272280 {
@@ -404,13 +412,13 @@ public void DeleteTemplate(string templateName)
404412 //
405413 // Parameters:
406414 // - string TemplateName
407- // Return value: string (the document as a Base64 string)
415+ // Return value: byte[]
408416 *-----------------------------------------------------------------------------------------------------*/
409417 /// <summary>
410- /// This method returns a template from the template storage as a Base64 encoded string .
418+ /// This method returns a template from the template storage as a byte array .
411419 /// </summary>
412420 /// <param name="templateName">The name of the template in the template storage.</param>
413- public string DownloadTemplate ( string templateName )
421+ public byte [ ] DownloadTemplate ( string templateName )
414422 {
415423 // create a new HttpClient using the Factory method CreateHttpClient
416424 using ( HttpClient client = CreateHttpClient ( ) )
@@ -421,7 +429,7 @@ public string DownloadTemplate(string templateName)
421429 // return an the document, if successful
422430 if ( response . IsSuccessStatusCode )
423431 {
424- return response . Content . ReadAsAsync < string > ( ) . Result ;
432+ return Convert . FromBase64String ( response . Content . ReadAsAsync < string > ( ) . Result ) ;
425433 }
426434 else
427435 {
0 commit comments