Skip to content

Commit d769821

Browse files
committed
updated example files, added test data files and files for build
1 parent 54b09f6 commit d769821

File tree

197 files changed

+1246
-795
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

197 files changed

+1246
-795
lines changed

aspose-html-examples/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This directory contains Java examples for [Aspose.HTML for Java](https://product
44

55
## How to use the Examples?
66

7-
Clone or Download the ZIP and extract the contents to your local hard drive. This project uses Maven build system and can be opened in any modern IDE like IntelliJ IDEA, Eclipse or NetBeans. For more details, visit our [Documentation website](https://docs.aspose.com/display/htmljava/How+to+Run+the+Examples).
7+
Clone or Download the ZIP and extract the contents to your local hard drive. This project uses Maven/Gradle build system and can be opened in any modern IDE like IntelliJ IDEA, Eclipse or NetBeans. For more details, visit our [Documentation website](https://docs.aspose.com/display/htmljava/How+to+Run+the+Examples).
88

99
## Step one
1010
mvn compile test

aspose-html-examples/build.gradle

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,15 @@ dependencies {
1717
"org.junit.jupiter:junit-jupiter-engine:5.6.2",
1818
"org.junit.jupiter:junit-jupiter-params:5.6.2",
1919
"org.junit.platform:junit-platform-runner:1.6.2",
20-
20+
"javax.xml.bind:jaxb-api:2.4.0-b180830.0359",
2121
)
2222
}
2323

24+
task SimpleWait(type: JavaExec) {
25+
classpath = sourceSets.test.runtimeClasspath
26+
main = 'com.aspose.html.examples.SimpleWait'
27+
}
28+
2429
test {
2530
useJUnitPlatform()
2631

aspose-html-examples/pom.xml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@
5555
<version>${org.junit.platform}</version>
5656
<scope>test</scope>
5757
</dependency>
58+
59+
<dependency>
60+
<groupId>javax.xml.bind</groupId>
61+
<artifactId>jaxb-api</artifactId>
62+
<version>2.4.0-b180830.0359</version>
63+
</dependency>
5864
</dependencies>
5965

6066
<build>
@@ -67,9 +73,6 @@
6773
<source>${maven.compiler.source}</source>
6874
<target>${maven.compiler.target}</target>
6975
<release>${maven.compiler.release}</release>
70-
<compilerArgs>
71-
<arg>--enable-preview</arg>
72-
</compilerArgs>
7376
<encoding>${project.build.sourceEncoding}</encoding>
7477
</configuration>
7578
</plugin>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.aspose.html.examples;
2+
3+
import java.text.SimpleDateFormat;
4+
5+
public class Enviroment {
6+
7+
public static String productVersion() {
8+
return Enviroment.enviroment("PRODUCT_VERSION");
9+
}
10+
11+
public static String enviroment(String envName) {
12+
return enviroment(envName, "");
13+
}
14+
15+
public static String enviroment(String envName, String defaultValue) {
16+
String envValue = System.getProperty(envName, System.getenv(envName));
17+
if (envValue != null) {
18+
return envValue;
19+
}
20+
return defaultValue;
21+
}
22+
23+
private static void printEnviroment() {
24+
System.getenv().entrySet().forEach(
25+
e -> System.out.println("java sysenv: " + e.getKey() + "=" + e.getValue()));
26+
27+
System.getProperties().stringPropertyNames().forEach(
28+
name -> System.out.println("java sys prop: " + name + "=" + System.getProperty(name)));
29+
}
30+
31+
public static String timestamp() {
32+
String timestamp = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS").format(System.currentTimeMillis());
33+
return timestamp;
34+
}
35+
}

aspose-html-examples/src/test/java/com/aspose/html/examples/Examples_Java_AdvancedUsage_CSSExtensions_AddTitleAndPageNumber.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
public class Examples_Java_AdvancedUsage_CSSExtensions_AddTitleAndPageNumber {
44

55
@org.junit.jupiter.api.Test
6-
@org.junit.jupiter.api.Disabled
76
public void execute() throws Exception {
8-
// For complete examples and data files, please go to https://github.com/aspose-html/Aspose.HTML-for-Java
9-
String dataDir = RunExamples.getResourcePath();
107
// Initialize configuration object and set up the page-margins for the document
118
com.aspose.html.Configuration configuration = new com.aspose.html.Configuration();
129
try {
@@ -40,7 +37,7 @@ public void execute() throws Exception {
4037
com.aspose.html.HTMLDocument document = new com.aspose.html.HTMLDocument("<div>Hello World!!!</div>", ".", configuration);
4138
try {
4239
// Initialize an output device
43-
com.aspose.html.rendering.xps.XpsDevice device = new com.aspose.html.rendering.xps.XpsDevice(dataDir + "output.xps");
40+
com.aspose.html.rendering.xps.XpsDevice device = new com.aspose.html.rendering.xps.XpsDevice(Resources.output("output.xps"));
4441
try {
4542
// Send the document to the output device
4643
document.renderTo(device);

aspose-html-examples/src/test/java/com/aspose/html/examples/Examples_Java_AdvancedUsage_DOMMutationObserver_ObserveHowNodesAreAdded.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ public class Examples_Java_AdvancedUsage_DOMMutationObserver_ObserveHowNodesAreA
44

55
@org.junit.jupiter.api.Test
66
public void execute() throws Exception {
7-
// For complete examples and data files, please go to https://github.com/aspose-html/Aspose.HTML-for-Java
87
// Create an empty HTML document
98
com.aspose.html.HTMLDocument document = new com.aspose.html.HTMLDocument();
109
try {

aspose-html-examples/src/test/java/com/aspose/html/examples/Examples_Java_AdvancedUsage_HTML5Canvas_ManipulateUsingCode.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ public class Examples_Java_AdvancedUsage_HTML5Canvas_ManipulateUsingCode {
55
@org.junit.jupiter.api.Test
66
public void execute() throws Exception {
77

8-
// For complete examples and data files, please go to https://github.com/aspose-html/Aspose.HTML-for-Java
9-
String dataDir = RunExamples.getResourcePath();
10-
// Create an empty HTML document
8+
// Create an empty HTML document
119
com.aspose.html.HTMLDocument document = new com.aspose.html.HTMLDocument();
1210
try {
1311
// Create the Canvas element
@@ -40,7 +38,7 @@ public void execute() throws Exception {
4038
context.fillRect(0, 95, 300, 20);
4139

4240
// Create the PDF output device
43-
com.aspose.html.rendering.pdf.PdfDevice device = new com.aspose.html.rendering.pdf.PdfDevice(dataDir + "canvas.pdf");
41+
com.aspose.html.rendering.pdf.PdfDevice device = new com.aspose.html.rendering.pdf.PdfDevice(Resources.output("canvas.output.2.pdf"));
4442
try {
4543
// Render HTML5 Canvas to PDF
4644
document.renderTo(device);

aspose-html-examples/src/test/java/com/aspose/html/examples/Examples_Java_AdvancedUsage_HTML5Canvas_ManipulateUsingJavaScript.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ public class Examples_Java_AdvancedUsage_HTML5Canvas_ManipulateUsingJavaScript {
44

55
@org.junit.jupiter.api.Test
66
public void execute() throws Exception {
7-
// For complete examples and data files, please go to https://github.com/aspose-html/Aspose.HTML-for-Java
8-
String dataDir = RunExamples.getResourcePath();
9-
// Prepare a document with HTML5 Canvas inside and save it to the file 'document.html'
7+
// Prepare a document with HTML5 Canvas inside and save it to the file 'document.html'
108
String code = "< canvas id = myCanvas width = '200' height = '100' style = 'border:1px solid #d3d3d3;' ></canvas >\n" +
119
"<script >\n" +
1210
" var c = document.getElementById('myCanvas');\n" +
@@ -15,18 +13,18 @@ public void execute() throws Exception {
1513
" context.fillStyle = 'red';\n" +
1614
" context.fillText('Hello World', 40, 50);\n" +
1715
"</script >\n";
18-
try (java.io.FileWriter fileWriter = new java.io.FileWriter(dataDir + "document.html")) {
16+
try (java.io.FileWriter fileWriter = new java.io.FileWriter(Resources.output("document.html"))) {
1917
fileWriter.write(code);
2018
}
2119

2220
// Initialize an HTML document from the html file
23-
com.aspose.html.HTMLDocument document = new com.aspose.html.HTMLDocument(dataDir + "document.html");
21+
com.aspose.html.HTMLDocument document = new com.aspose.html.HTMLDocument(Resources.output("document.html"));
2422
try {
2523
// Convert HTML to PDF
2624
com.aspose.html.converters.Converter.convertHTML(
2725
document,
2826
new com.aspose.html.saving.PdfSaveOptions(),
29-
dataDir + "output.pdf"
27+
Resources.output("output.pdf")
3028
);
3129
} finally {
3230
if (document != null) {

aspose-html-examples/src/test/java/com/aspose/html/examples/Examples_Java_AdvancedUsage_HTMLFormEditor_FillFormAndSubmitIt.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ public class Examples_Java_AdvancedUsage_HTMLFormEditor_FillFormAndSubmitIt {
44

55
@org.junit.jupiter.api.Test
66
public void execute() throws Exception {
7-
// For complete examples and data files, please go to https://github.com/aspose-html/Aspose.HTML-for-Java
8-
String dataDir = RunExamples.getResourcePath();
9-
// Initialize an instance of HTML document from 'https://httpbin.org/forms/post' url
7+
// Initialize an instance of HTML document from 'https://httpbin.org/forms/post' url
108
com.aspose.html.HTMLDocument document = new com.aspose.html.HTMLDocument("https://httpbin.org/forms/post");
119
try {
1210
// Create an instance of Form Editor
@@ -15,7 +13,7 @@ public void execute() throws Exception {
1513
// You can fill the data up using direct access to the input elements, like this:
1614
editor.get_Item("custname").setValue("John Doe");
1715

18-
document.save(dataDir + "out.html");
16+
document.save(Resources.output("out.html"));
1917

2018
// or this:
2119
com.aspose.html.forms.TextAreaElement comments = editor.getElement(com.aspose.html.forms.TextAreaElement.class, "comments");
@@ -25,7 +23,7 @@ public void execute() throws Exception {
2523
java.util.Map<String, String> map = new java.util.HashMap<>();
2624
map.put("custemail", "john.doe@gmail.com");
2725
map.put("custtel", "+1202-555-0290");
28-
editor.fill(map);
26+
//editor.fill(map);
2927

3028
// Create an instance of form submitter
3129
com.aspose.html.forms.FormSubmitter submitter = new com.aspose.html.forms.FormSubmitter(editor);

aspose-html-examples/src/test/java/com/aspose/html/examples/Examples_Java_Conversion_AdjustPdfPageSize_AdjustPdfPageSize.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ public class Examples_Java_Conversion_AdjustPdfPageSize_AdjustPdfPageSize {
44

55
@org.junit.jupiter.api.Test
66
public void execute() throws Exception {
7-
// For complete examples and data files, please go to https://github.com/aspose-html/Aspose.HTML-for-Java
8-
// The path to the documents directory.
9-
String dataDir = RunExamples.getResourcePath();
10-
try (java.io.FileInputStream fileInputStream = new java.io.FileInputStream(dataDir + "FirstFile.html")) {
11-
try (java.io.FileOutputStream fileOutputStream = new java.io.FileOutputStream(dataDir + "FirstFileOut.html")) {
7+
8+
try (java.io.FileInputStream fileInputStream = new java.io.FileInputStream(Resources.input("FirstFile.html"))) {
9+
try (java.io.FileOutputStream fileOutputStream = new java.io.FileOutputStream(Resources.output("FirstFileOut.html"))) {
1210
byte[] bytes = new byte[fileInputStream.available()];
1311
fileInputStream.read(bytes);
1412
fileOutputStream.write(bytes);
@@ -32,7 +30,7 @@ public void execute() throws Exception {
3230
com.aspose.html.rendering.HtmlRenderer pdf_renderer = new com.aspose.html.rendering.HtmlRenderer();
3331
try {
3432
// Create HtmlDocument instnace while passing path of already created HTML file
35-
com.aspose.html.HTMLDocument html_document = new com.aspose.html.HTMLDocument(dataDir + "FirstFileOut.html");
33+
com.aspose.html.HTMLDocument html_document = new com.aspose.html.HTMLDocument(Resources.output("FirstFileOut.html"));
3634
try {
3735
// Set the page size less than document min-width. The content in the resulting file will be cropped becuase of element with width: 200px
3836
com.aspose.html.rendering.pdf.PdfRenderingOptions pdf_options =
@@ -42,7 +40,7 @@ public void execute() throws Exception {
4240
pageSetup.setAdjustToWidestPage(false);
4341
pdf_options.setPageSetup(pageSetup);
4442

45-
pdf_output = dataDir + "not-adjusted-to-widest-page_out.pdf";
43+
pdf_output = Resources.output("not-adjusted-to-widest-page_out.pdf");
4644
com.aspose.html.rendering.pdf.PdfDevice device = new com.aspose.html.rendering.pdf.PdfDevice(pdf_options, pdf_output);
4745
try {
4846
// Render the output
@@ -60,7 +58,7 @@ public void execute() throws Exception {
6058
pageSetup.setAdjustToWidestPage(true);
6159
pdf_options.setPageSetup(pageSetup);
6260

63-
pdf_output = dataDir + "adjusted-to-widest-page_out.pdf";
61+
pdf_output = Resources.output("adjusted-to-widest-page_out.pdf");
6462
device = new com.aspose.html.rendering.pdf.PdfDevice(pdf_options, pdf_output);
6563
try {
6664
// Render the output

0 commit comments

Comments
 (0)