Java Code Sample to Create PDF from HTML Using REST API

//build uri to create empty pdf
    String strURI = "http://api.aspose.com/v1.1/pdf/outPdfFile.pdf?templateFile=input.html&templateType=html";
    String signedURI = Sign(strURI);
InputStreamresponseStream = ProcessCommand(signedURI, "PUT");
    String strJSON = StreamToString(responseStream);
Gsongson = new Gson();
    //Parse the json string to JObject and Deserializes the JSON to a object.
BaseResponsebaseResponse = gson.fromJson(strJSON,BaseResponse.class);
if (baseResponse.getCode().equals("200") &&baseResponse.getStatus().equals("OK"))
System.out.println("Empty PDF file has been created successfully");

//Here is the BaseResponse class
public class BaseResponse {
publicBaseResponse() { }
private String Code;
private String Status;
public String getCode(){return Code;}
public String getStatus(){return Status;}
public void  setCode(String temCode){ Code=temCode;}
public void setStatus(String temStatus){ Status=temStatus;}
}


Learn More :