|
// for more examples, please visit https://github.com/aspose-pdf-cloud/aspose-pdf-cloud-java/tree/master/Examples/src/main/java/com/aspose/asposecloudpdf/examples |
|
|
|
try |
|
{ |
|
// Get ClientID and ClientSecret from https://dashboard.aspose.cloud/ |
|
String clientId = "bbf94a2c-6d7e-4020-b4d2-b9809741374e"; |
|
String clientSecret = "1c9379bb7d701c26cc87e741a29987bb"; |
|
|
|
// create an instance of PdfApi |
|
PdfApi pdfApi = new PdfApi(clientSecret,clientId); |
|
|
|
// name of input JPG image |
|
String imageFile = "Compare-Word-Document-preview.jpg"; |
|
|
|
String resultantPDF = "Resultant.pdf"; |
|
// create a blank PDF document in cloud storage |
|
DocumentResponse document = pdfApi.putCreateDocument(resultantPDF, "Internal",null); |
|
|
|
// load JPG image from local drive |
|
File file = new File("c://Downloads/"+imageFile); |
|
|
|
// page number of PDF file |
|
int pageNumber = 1; |
|
|
|
// coordinates for image in PDF document |
|
// The coordinates are in Point starting from Bottom-Left to Top-Right |
|
double llx = 10.0; |
|
double lly = 850; |
|
double urx = 580.0; |
|
double ury = 650.0; |
|
|
|
|
|
// name The document name. (required) |
|
// pageNumber The page number. (required) |
|
// llx Coordinate lower left X. (required) |
|
// lly Coordinate lower left Y. (required) |
|
// urx Coordinate upper right X. (required) |
|
// ury Coordinate upper right Y. (required) |
|
// imageFilePath Path to image file if specified. Request content is used otherwise. (optional) |
|
// storage The document storage. (optional) |
|
// folder The document folder. (optional) |
|
// image Image file. (optional) |
|
pdfApi.postInsertImage(resultantPDF, pageNumber, llx, lly, urx, ury, null,"Internal",null,file); |
|
|
|
System.out.println("JPG to PDF Conversion sucessfull !"); |
|
}catch(Exception ex) |
|
{ |
|
System.out.println(ex); |
|
} |