Skip to content

Commit

Permalink
Fiks for å kunne kjøre tester på mac (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
hildenok authored Dec 5, 2023
1 parent 86ba0df commit 5ce172f
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package no.nav.sosialhjelp.kotlin.utils.pdf.filkonvertering.word
import no.nav.sosialhjelp.kotlin.utils.pdf.filkonvertering.FilTilPdfConverter
import no.nav.sosialhjelp.kotlin.utils.pdf.filkonvertering.exception.WordKonverteringException
import org.docx4j.Docx4J
import org.docx4j.fonts.PhysicalFonts
import org.docx4j.openpackaging.packages.WordprocessingMLPackage
import java.io.ByteArrayInputStream
import java.io.ByteArrayOutputStream
Expand All @@ -14,6 +15,10 @@ object WordToPdfConverter : FilTilPdfConverter {
WordprocessingMLPackage.load(it)
}
return ByteArrayOutputStream().use {
// For å unngå feil med font på Mac slik at tester kan kjøre lokalt
if (System.getProperty("os.name").equals("Mac OS X", ignoreCase = true)) {
PhysicalFonts.setRegex(".*(Courier New|Arial|Times New Roman|Comic Sans|Georgia|Impact|Lucida Console|Lucida Sans Unicode|Palatino Linotype|Tahoma|Trebuchet|Verdana|Symbol|Webdings|Wingdings|MS Sans Serif|MS Serif).*")
}
Docx4J.toPDF(wordFile, it)
it.flush()
it.toByteArray()
Expand Down

0 comments on commit 5ce172f

Please sign in to comment.