Open mahaairong opened 3 years ago
To create attributes, use the AttributesBuilder
, then inject them into the OptionsBuilder with attributes
method.
And if you are passing paths, pass the absolute path as a string.
AttributesBuilder
I used the method you provided, and I have two questions. First, I can't get the Builder.The prompt message is "Cannot resolve method 'builder()".I import org.asciidoctor.*. The other one, I added the font, how do I put the theme in? like XXX.yml. Thank again for your reading and support.
To learn how to add fonts for your PDF theme, please refer to this document: https://github.com/asciidoctor/asciidoctor-pdf/blob/v1.5.x/docs/theming-guide.adoc#fonts
First, I can't get the Builder.The prompt message is "Cannot resolve method 'builder()".I import org.asciidoctor.*.
I see the docs update from main branch and we made some changes not yet released. Use these:
Asciidoctor asciidoctor = Asciidoctor.Factory.create();
Attributes attributes = AttributesBuilder.attributes()
.attribute("pdf-theme", "path_to_theme")
.attribute("pdf-fontsdir", "path_to_fonts")
.tableOfContents(Placement.LEFT)
.icons("font")
.get();
Options options = OptionsBuilder.options()
.backend("pdf")
.attributes(attributes)
.get();
asciidoctor.convertFile(file("sample.adoc"), options);
Not sure what is your use case, but you may be interested in having a look at the maven example to build PDF with CN fonts https://github.com/asciidoctor/asciidoctor-maven-examples/tree/main/asciidoctor-pdf-cjk-example. If you want to build docs in some automated way, maybe that's also al option and you don't need to deal with Asciidoctorj internals.
First, I can't get the Builder.The prompt message is "Cannot resolve method 'builder()".I import org.asciidoctor.*.
I see the docs update from main branch and we made some changes not yet released. Use these:
Asciidoctor asciidoctor = Asciidoctor.Factory.create(); Attributes attributes = AttributesBuilder.attributes() .attribute("pdf-theme", "path_to_theme") .attribute("pdf-fontsdir", "path_to_fonts") .tableOfContents(Placement.LEFT) .icons("font") .get(); Options options = OptionsBuilder.options() .backend("pdf") .attributes(attributes) .get(); asciidoctor.convertFile(file("sample.adoc"), options);
Not sure what is your use case, but you may be interested in having a look at the maven example to build PDF with CN fonts https://github.com/asciidoctor/asciidoctor-maven-examples/tree/main/asciidoctor-pdf-cjk-example. If you want to build docs in some automated way, maybe that's also al option and you don't need to deal with Asciidoctorj internals.
Sorry to be late with the new one. I used this method and was happy to convert successfully, but there were formatting problems.
When I use include, it generates a link, not a reference to its text. Could you please take a look at it again!Thank you!
Hello!Thank you for reading! I successfully converted ADOC to PDF with asciidoctorj api , but I'm very upset how to add some style? jdk1.8,asciidoctor v2.0.14 asciidoctorj v2.4.2 Please help me! Thank again for your reading and support.