Wie benutze ich benutzerdefinierte Schriftart mit OpenHTMLTOPDF?Java

Java-Forum
Anonymous
 Wie benutze ich benutzerdefinierte Schriftart mit OpenHTMLTOPDF?

Post by Anonymous »

Ich entwickle einen Microservice im Springboot, um PDF mithilfe von Freemarker und OpenHTMLTOPDF -Bibliotheken zu generieren. Ich möchte eine benutzerdefinierte Schriftart (tamilische Sprache) vorstellen. Aber nur #### als Ausgabe. Ich bin mir nicht sicher, wo ich falsch gehe.

Code: Select all

private fun convertToPdf(htmlContent: String): ByteArrayResource {
val jsoupDocument = Jsoup.parse(htmlContent)
jsoupDocument.outputSettings().syntax(Document.OutputSettings.Syntax.html)
val xmlDocument = W3CDom().fromJsoup(jsoupDocument)

val FONT_FILE = File("resources/fonts/NotoSansTamil.ttf")

val byteArrayOutputStream = ByteArrayOutputStream()
val baseUrl = javaClass
.protectionDomain
.codeSource
.location
.toString()

PdfRendererBuilder()
.withW3cDocument(xmlDocument, baseUrl)
.useFont(FONT_FILE, "Nota Sans")
.toStream(byteArrayOutputStream)
.run()
return ByteArrayResource(byteArrayOutputStream.toByteArray())
}
Freiemarker -Vorlage

Code: Select all




FreeMarker

@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 400;
src: url(./fonts/NotoSansTamil.ttf);
}



 Welcome to FreeMarker ${name} 


Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post