Java izstrādātāji var viegli izveidot HTML, izmantojot tikai mūsu jaudīgo produktu API. Tas nozīmē, ka mūsu risinājums nodrošinās programmētājiem visu nepieciešamo, lai izveidotu HTML pakalpojumā Java.
Izmantojot mūsu Java bibliotēku, izstrādātāji var viegli izveidot HTML no nulles. Lai to izdarītu, Java izstrādātājiem ir jāveic tikai dažas darbības:
Ir vērts atzīmēt, ka tukšā dokumentā tehniski ir jāiekļauj viena rindkopa, tāpēc, programmatiski veidojot HTML dokumentu, jūs iegūsit tieši tādu dokumenta pamatstruktūru.
Ņemiet vērā, ka varat uzreiz pievienot saturu jaunizveidotajam HTML failam. Tādējādi jūs iegūsit ne tikai tukšu dokumentu, bet arī dokumentu ar nepieciešamo saturu. Papildinformāciju par dokumenta rediģēšanu skatiet rediģēšanas lapā.
Šī Java bibliotēka ļauj programmatiski izveidot HTML dokumentus. Izmēģiniet mūsu jaudīgo funkcionalitāti un uzziniet, kā dažos formātos izveidot HTML, izmantojot šo piemēru:
// Repository path: https://releases.aspose.com/java/repo/
// Maven, where 'ver' - Aspose.Words version number, for example, 24.4.
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-words</artifactId>
<version>ver</version>
<classifier>jdk17</classifier>
</dependency>
Kopēt
// Repository path: https://releases.aspose.com/java/repo/
// Gradle, where 'ver' - Aspose.Words version number, for example, 24.4.
compile(group: 'com.aspose', name: 'aspose-words', version: 'ver', classifier: 'jdk17')
Kopēt
// Repository path: https://releases.aspose.com/java/repo/
// Ivy, where 'ver' - Aspose.Words version number, for example, 24.4.
<dependency org="com.aspose" name="aspose-words" rev="ver">
<artifact name="aspose-words" m:classifier="jdk17" ext="jar"/>
</dependency>
Kopēt
// Repository path: https://releases.aspose.com/java/repo/
// Sbt, where 'ver' - Aspose.Words version number, for example, 24.4.
libraryDependencies += "com.aspose" % "aspose-words" % "ver"
Kopēt
import com.aspose.words.*;
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Font font = builder.getFont();
font.setName("Courier New");
font.setColor(Color.BLUE);
font.setSize(36);
font.setHighlightColor(Color.YELLOW);
builder.write("Morbi enim nunc faucibus a.");
doc.save("Output.html");
import com.aspose.words.*;
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Run firstRun = new Run(doc, "Proin eros metus, sagittis sed. ");
Run secondRun = new Run(doc, "Morbi enim nunc faucibus a.");
doc.getFirstSection().getBody().getFirstParagraph().appendChild(firstRun);
doc.getFirstSection().getBody().getFirstParagraph().appendChild(secondRun);
builder.moveTo(secondRun);
builder.startBookmark("Aspose bookmark");
// Ja NextSibling ir null, tad visticamāk šī ir pēdējā Run rindkopā.
if (secondRun.getNextSibling() != null)
builder.moveTo(secondRun.getNextSibling());
else
builder.moveTo(secondRun.getParentParagraph());
builder.endBookmark("Aspose bookmark");
doc.save("Output.html");
import com.aspose.words.*;
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Run firstRun = new Run(doc, "Proin eros metus, sagittis sed. ");
Run secondRun = new Run(doc, "Morbi enim nunc faucibus a.");
doc.getFirstSection().getBody().getFirstParagraph().appendChild(firstRun);
doc.getFirstSection().getBody().getFirstParagraph().appendChild(secondRun);
builder.moveTo(secondRun);
builder.startBookmark("Aspose bookmark");
// Ja NextSibling ir null, tad visticamāk šī ir pēdējā Run rindkopā.
if (secondRun.getNextSibling() != null)
builder.moveTo(secondRun.getNextSibling());
else
builder.moveTo(secondRun.getParentParagraph());
builder.endBookmark("Aspose bookmark");
PdfSaveOptions saveOptions = new PdfSaveOptions();
saveOptions.getOutlineOptions().getBookmarksOutlineLevels().add("Aspose bookmark", 1);
doc.save("Output.html", saveOptions);
import com.aspose.words.*;
Document doc = new Document();
Run run = new Run(doc, "Proin eros metus, sagittis sed.");
Paragraph para = doc.getFirstSection().getBody().getFirstParagraph();
para.appendChild(run);
Comment comment = new Comment(doc);
comment.setAuthor("John Doe");
comment.setInitial("JD");
comment.setDateTime(new Date());
comment.setText("Quisque fringilla leo.");
CommentRangeStart commentRangeStart = new CommentRangeStart(doc, comment.getId());
CommentRangeEnd commentRangeEnd = new CommentRangeEnd(doc, comment.getId());
run.getParentNode().insertBefore(commentRangeStart, run);
run.getParentNode().insertAfter(commentRangeEnd, run);
commentRangeEnd.getParentNode().insertAfter(comment, commentRangeEnd);
comment.addReply("Jane Doe", "JD", new Date(), "Pellentesque vel sapien justo.");
doc.save("Output.html");
import com.aspose.words.*;
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Run firstRun = new Run(doc, "Proin eros metus, sagittis sed. ");
Run secondRun = new Run(doc, "Morbi enim nunc faucibus a.");
doc.getFirstSection().getBody().getFirstParagraph().appendChild(firstRun);
doc.getFirstSection().getBody().getFirstParagraph().appendChild(secondRun);
builder.moveTo(secondRun);
builder.startBookmark("Aspose bookmark");
// Ja NextSibling ir null, tad visticamāk šī ir pēdējā Run rindkopā.
if (secondRun.getNextSibling() != null)
builder.moveTo(secondRun.getNextSibling());
else
builder.moveTo(secondRun.getParentParagraph());
builder.endBookmark("Aspose bookmark");
doc.save("Output.html");
import com.aspose.words.*;
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Run firstRun = new Run(doc, "Proin eros metus, sagittis sed. ");
Run secondRun = new Run(doc, "Morbi enim nunc faucibus a.");
doc.getFirstSection().getBody().getFirstParagraph().appendChild(firstRun);
doc.getFirstSection().getBody().getFirstParagraph().appendChild(secondRun);
builder.moveTo(secondRun);
builder.startBookmark("Aspose bookmark");
// Ja NextSibling ir null, tad visticamāk šī ir pēdējā Run rindkopā.
if (secondRun.getNextSibling() != null)
builder.moveTo(secondRun.getNextSibling());
else
builder.moveTo(secondRun.getParentParagraph());
builder.endBookmark("Aspose bookmark");
PdfSaveOptions saveOptions = new PdfSaveOptions();
saveOptions.getOutlineOptions().getBookmarksOutlineLevels().add("Aspose bookmark", 1);
doc.save("Output.html", saveOptions);
import com.aspose.words.*;
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Run firstRun = new Run(doc, "Proin eros metus, sagittis sed. ");
Run secondRun = new Run(doc, "Morbi enim nunc faucibus a.");
doc.getFirstSection().getBody().getFirstParagraph().appendChild(firstRun);
doc.getFirstSection().getBody().getFirstParagraph().appendChild(secondRun);
builder.moveTo(secondRun);
builder.startBookmark("Aspose bookmark");
// Ja NextSibling ir null, tad visticamāk šī ir pēdējā Run rindkopā.
if (secondRun.getNextSibling() != null)
builder.moveTo(secondRun.getNextSibling());
else
builder.moveTo(secondRun.getParentParagraph());
builder.endBookmark("Aspose bookmark");
doc.save("Output.html");
import com.aspose.words.*;
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Run firstRun = new Run(doc, "Proin eros metus, sagittis sed. ");
Run secondRun = new Run(doc, "Morbi enim nunc faucibus a.");
doc.getFirstSection().getBody().getFirstParagraph().appendChild(firstRun);
doc.getFirstSection().getBody().getFirstParagraph().appendChild(secondRun);
builder.moveTo(secondRun);
builder.startBookmark("Aspose bookmark");
// Ja NextSibling ir null, tad visticamāk šī ir pēdējā Run rindkopā.
if (secondRun.getNextSibling() != null)
builder.moveTo(secondRun.getNextSibling());
else
builder.moveTo(secondRun.getParentParagraph());
builder.endBookmark("Aspose bookmark");
doc.save("Output.html");
import com.aspose.words.*;
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Run firstRun = new Run(doc, "Proin eros metus, sagittis sed. ");
Run secondRun = new Run(doc, "Morbi enim nunc faucibus a.");
doc.getFirstSection().getBody().getFirstParagraph().appendChild(firstRun);
doc.getFirstSection().getBody().getFirstParagraph().appendChild(secondRun);
builder.moveTo(secondRun);
builder.startBookmark("Aspose bookmark");
// Ja NextSibling ir null, tad visticamāk šī ir pēdējā Run rindkopā.
if (secondRun.getNextSibling() != null)
builder.moveTo(secondRun.getNextSibling());
else
builder.moveTo(secondRun.getParentParagraph());
builder.endBookmark("Aspose bookmark");
PdfSaveOptions saveOptions = new PdfSaveOptions();
saveOptions.getOutlineOptions().getBookmarksOutlineLevels().add("Aspose bookmark", 1);
doc.save("Output.html", saveOptions);
import com.aspose.words.*;
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Shape shape = builder.insertChart(ChartType.PIE, 432, 252);
Chart chart = shape.getChart();
chart.getTitle().setText("Demo Chart");
chart.getSeries().clear();
chart.getSeries().add("Series 1",
new String[] { "Category1", "Category2", "Category3" },
new double[] { 2.7, 3.2, 0.8 });
doc.save("Output.html");
import com.aspose.words.*;
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Run firstRun = new Run(doc, "Proin eros metus, sagittis sed. ");
Run secondRun = new Run(doc, "Morbi enim nunc faucibus a.");
doc.getFirstSection().getBody().getFirstParagraph().appendChild(firstRun);
doc.getFirstSection().getBody().getFirstParagraph().appendChild(secondRun);
builder.moveTo(secondRun);
builder.startBookmark("Aspose bookmark");
// Ja NextSibling ir null, tad visticamāk šī ir pēdējā Run rindkopā.
if (secondRun.getNextSibling() != null)
builder.moveTo(secondRun.getNextSibling());
else
builder.moveTo(secondRun.getParentParagraph());
builder.endBookmark("Aspose bookmark");
doc.save("Output.html");
import com.aspose.words.*;
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Run firstRun = new Run(doc, "Proin eros metus, sagittis sed. ");
Run secondRun = new Run(doc, "Morbi enim nunc faucibus a.");
doc.getFirstSection().getBody().getFirstParagraph().appendChild(firstRun);
doc.getFirstSection().getBody().getFirstParagraph().appendChild(secondRun);
builder.moveTo(secondRun);
builder.startBookmark("Aspose bookmark");
// Ja NextSibling ir null, tad visticamāk šī ir pēdējā Run rindkopā.
if (secondRun.getNextSibling() != null)
builder.moveTo(secondRun.getNextSibling());
else
builder.moveTo(secondRun.getParentParagraph());
builder.endBookmark("Aspose bookmark");
PdfSaveOptions saveOptions = new PdfSaveOptions();
saveOptions.getOutlineOptions().getBookmarksOutlineLevels().add("Aspose bookmark", 1);
doc.save("Output.html", saveOptions);
Mēs mitinām savas Java pakotnes Maven krātuvēs. 'Aspose.Words for Java' ir izplatīts JAR fails, kas satur baitu kodu. Lūdzu, izpildiet soli pa solim sniegtos norādījumus, kā to instalēt savā Java izstrādātāja vidē.
Tiek atbalstītas Java SE 7 un jaunākās Java Mēs piedāvājam arī atsevišķu pakotni Java SE 6 gadījumam, ja jums ir pienākums izmantot šo novecojušo JRE.
Mūsu Java pakete ir vairāku platformu un darbojas visās operētājsistēmās ar JVM ieviešanu, ieskaitot Microsoft Windows, Linux, macOS, Android un iOS.
Lai iegūtu informāciju par papildu pakotņu atkarībām, piemēram, JogAmp JOGL, Harfbuzz fontu dzinēju, Java Advanced Imaging JAI, lūdzu, skatiet produkta dokumentāciju.
Varat izveidot dokumentus citos failu formātos: