C# Code Sample to Create PDF from HTML Using REST API


/ Published in: C#
Save to your folder(s)

This code sample shows how C# developers can create PDF file from HTML using Aspose.Pdf for Cloud API in their REST applications.


Copy this code and paste it in your HTML
  1. stringstrURI = "http://api.aspose.com/v1.1/pdf/outPdfFile.pdf?templateFile=input.html&templateType=html";
  2. stringsignedURI = Sign(strURI);
  3. StreamReader reader = new StreamReader(ProcessCommand(signedURI, "PUT"));
  4. //further process JSON response
  5. stringstrJSON = reader.ReadToEnd();
  6. //Parse the json string to JObject
  7. JObjectparsedJSON = JObject.Parse(strJSON);
  8. BaseResponse stream = JsonConvert.DeserializeObject<BaseResponse>(parsedJSON.ToString());
  9. if (stream.Code == "200" &&stream.Status == "OK")
  10. Console.WriteLine("Empty PDF file has been created successfully");
  11.  
  12. //Here is the BaseResponse class
  13. public class BaseResponse
  14. {
  15. publicBaseResponse() { }
  16. public string Code { get; set; }
  17. public string Status { get; set; }
  18. }

URL: http://www.aspose.com/docs/display/pdfcloud/Create+PDF+from+HTML

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.