Posted By

johansonkatherine on 04/10/14


file java html ruby api c#

Versions (?)

Last Edited at 04/10/14 05:13pm

Viewed 3 times

Java Code Sample to Create PDF from HTML Using REST API

/ Published in: Java


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

  1. //build uri to create empty pdf
  2. String strURI = "";
  3. String signedURI = Sign(strURI);
  4. InputStreamresponseStream = ProcessCommand(signedURI, "PUT");
  5. String strJSON = StreamToString(responseStream);
  6. Gsongson = new Gson();
  7. //Parse the json string to JObject and Deserializes the JSON to a object.
  8. BaseResponsebaseResponse = gson.fromJson(strJSON,BaseResponse.class);
  9. if (baseResponse.getCode().equals("200") &&baseResponse.getStatus().equals("OK"))
  10. System.out.println("Empty PDF file has been created successfully");
  12. //Here is the BaseResponse class
  13. public class BaseResponse {
  14. publicBaseResponse() { }
  15. private String Code;
  16. private String Status;
  17. public String getCode(){return Code;}
  18. public String getStatus(){return Status;}
  19. public void setCode(String temCode){ Code=temCode;}
  20. public void setStatus(String temStatus){ Status=temStatus;}
  21. }

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.