Java Code Sample to Create PDF from HTML in REST





1
Date Submitted Thu. Apr. 10th, 2014 7:22 AM
Revision 1 of 1
Helper johansonkatherine
Tags cloud | create | File | from | HTML | in | Java | pdf | Using
Comments 0 comments
This code sample shows how Java developers can create PDF file from HTML using Aspose.Pdf for Cloud API in their REST applications.


//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;}
}


 

Katherine Johanson

Comments

There are currently no comments for this snippet.

Voting

Votes Down