Skip to content

Commit 97e1641

Browse files
Examples for Aspose.PDF Cloud for Android SDK
1 parent 5266b4f commit 97e1641

File tree

13 files changed

+5406
-11
lines changed

13 files changed

+5406
-11
lines changed

Exampls/jar/classes.jar

1.66 MB
Binary file not shown.

Exampls/pom.xml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
<project xmlns="http://maven.apache.org/POM/4.0.0"
2-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4-
<modelVersion>4.0.0</modelVersion>
5-
<groupId>com.aspose.pdf.android</groupId>
6-
<artifactId>examples</artifactId>
7-
<version>0.0.1-SNAPSHOT</version>
8-
9-
10-
11-
</project>
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>com.aspose.pdf.android</groupId>
6+
<artifactId>examples</artifactId>
7+
<version>0.0.1-SNAPSHOT</version>
8+
9+
10+
11+
</project>
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
package com.aspose.examples.pdf.examples.fields;
2+
3+
import java.io.File;
4+
import java.util.ArrayList;
5+
6+
import com.aspose.asposecloudpdfandroid.ApiException;
7+
import com.aspose.asposecloudpdfandroid.api.PdfApi;
8+
import com.aspose.asposecloudpdfandroid.model.AsposeResponse;
9+
import com.aspose.asposecloudpdfandroid.model.Field;
10+
import com.aspose.asposecloudpdfandroid.model.FieldResponse;
11+
import com.aspose.asposecloudpdfandroid.model.FieldType;
12+
import com.aspose.asposecloudpdfandroid.model.Fields;
13+
import com.aspose.asposecloudpdfandroid.model.FieldsResponse;
14+
import com.aspose.asposecloudpdfandroid.model.Rectangle;
15+
16+
public class FieldExamples {
17+
private final PdfApi pdfApi;
18+
private String tempFolder = "TempPdfCloud";
19+
private String ExampleDataFolder = "ExampleData";
20+
private String setupFile = "setup.json";
21+
22+
class ApiCreds {
23+
public String app_key;
24+
public String app_sid;
25+
public String product_uri;
26+
}
27+
28+
public FieldExamples()
29+
{
30+
31+
pdfApi = new PdfApi("app_key", "app_sid");
32+
pdfApi.getApiClient().setBasePath("product_uri");
33+
}
34+
35+
private void uploadFile(String name) throws ApiException {
36+
File file = new File(ExampleDataFolder + "/" + name);
37+
AsposeResponse response = pdfApi.putCreate(tempFolder + '/' + name, file, null, null);
38+
}
39+
40+
public void getFieldExample() throws ApiException {
41+
String name = "PdfWithAcroForm.pdf";
42+
this.uploadFile(name);
43+
44+
String folder = this.tempFolder;
45+
String fieldName = "textField";
46+
47+
FieldResponse response = this.pdfApi.getField(name, fieldName, null, folder);
48+
}
49+
50+
public void getFieldsExample() throws ApiException {
51+
String name = "PdfWithAcroForm.pdf";
52+
this.uploadFile(name);
53+
54+
String folder = this.tempFolder;
55+
56+
FieldsResponse response = this.pdfApi.getFields(name, null, folder);
57+
}
58+
59+
public void postCreateFieldExample() throws ApiException {
60+
String name = "Hello world.pdf";
61+
this.uploadFile(name);
62+
63+
Rectangle rect = new Rectangle().LLX(50.).LLY(200.).URX(200.).URY(400.);
64+
65+
Field field = new Field();
66+
field.setName("checkboxfield");
67+
field.setValues(new ArrayList<String>() {
68+
{
69+
add("1");
70+
}
71+
});
72+
field.setType(FieldType.BOOLEAN);
73+
field.setRect(rect);
74+
75+
int pageNumber = 1;
76+
String folder = this.tempFolder;
77+
78+
AsposeResponse response = this.pdfApi.postCreateField(name, pageNumber, field, null, folder);
79+
}
80+
81+
public void putUpdateFieldExample() throws ApiException {
82+
String name = "PdfWithAcroForm.pdf";
83+
this.uploadFile(name);
84+
85+
String fieldName = "textField";
86+
87+
Field field = new Field();
88+
field.setName(fieldName);
89+
field.setValues(new ArrayList<String>() {
90+
{
91+
add("Text field updated value.");
92+
}
93+
});
94+
field.setType(FieldType.TEXT);
95+
96+
String folder = this.tempFolder;
97+
98+
FieldResponse response = this.pdfApi.putUpdateField(name, fieldName, field, null, folder);
99+
}
100+
101+
public void putUpdateFieldsExample() throws ApiException {
102+
String name = "PdfWithAcroForm.pdf";
103+
this.uploadFile(name);
104+
105+
Field field = new Field();
106+
field.setName("textField");
107+
field.setValues(new ArrayList<String>() {
108+
{
109+
add("1");
110+
}
111+
});
112+
field.setType(FieldType.TEXT);
113+
114+
ArrayList<Field> fieldsList = new ArrayList<Field>();
115+
fieldsList.add(field);
116+
117+
Fields fields = new Fields().list(fieldsList);
118+
119+
String folder = this.tempFolder;
120+
121+
AsposeResponse response = this.pdfApi.putUpdateFields(name, fields, null, folder);
122+
}
123+
124+
public void deleteFieldExample() throws ApiException {
125+
String name = "PdfWithAcroForm.pdf";
126+
this.uploadFile(name);
127+
128+
String fieldName = "textField";
129+
130+
String folder = this.tempFolder;
131+
132+
AsposeResponse response = this.pdfApi.deleteField(name, fieldName, null, folder);
133+
}
134+
135+
public void putFieldsFlattenExample() throws ApiException {
136+
String name = "PdfWithAcroForm.pdf";
137+
this.uploadFile(name);
138+
139+
String folder = this.tempFolder;
140+
141+
AsposeResponse response = this.pdfApi.putFieldsFlatten(name, null, folder);
142+
143+
}
144+
145+
}

0 commit comments

Comments
 (0)