Utilizing both a primary and secondary font in the Flying Saucer PDF generator for optimal document appearance

I'm struggling with getting flying saucer to utilize a secondary font for the characters that are not included in my main font.

The Java code I am currently using looks something like this:

    String result = getPrintHtmlContent(urlString);
    result = CharacterConverter.replaceInvalidCharacters(result);

    ITextRenderer renderer = new ITextRenderer();
    renderer.getFontResolver();
    renderer.getFontResolver().addFont(FONTS_DIR_PATH + "ARIALUNI.TTF", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
    renderer.getFontResolver().addFont(FONTS_DIR_PATH + "droidsans/DroidSans.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
    renderer.getFontResolver().addFont(FONTS_DIR_PATH + "droidsans/DroidSansBold.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);

    renderer.setDocumentFromString(result, "http://" + frontendHost + ":" + frontendPort + frontendContextRoot);
    renderer.layout();

    renderer.createPDF(os);

Additionally, here is the CSS snippet:

    body {
      font-family: "Droid Sans", "Arial Unicode MS";
    }

In the CSS, I have also added the fonts through the @font-face rule.

I have been successful in using either one of the fonts individually; hence, it appears that there are no issues regarding finding the fonts or rendering the CSS correctly by flying saucer.

However, when attempting to use both fonts as shown above, the resulting PDF exclusively uses Droid Sans...

My question is whether it is feasible to employ a "fallback font" in flying saucer, akin to how it's done on websites?

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

I attempted to utilize the <map> tag in creating a circular image that functions as a hyperlink, but unfortunately, it is not functioning correctly

I've been trying to create a round button using the code below, but something seems to be wrong with it. The issue I'm facing is that the area around the image is also clickable, even though I have used border-radius. Can someone please take a lo ...

Click the div to fold it

I would like the div to fold down when clicked on and then fold back up when clicked again. Here is my jQuery code: $(".fold_reply").click(function() { if ($('.reply').css('display') === 'none') { $(".reply").sh ...

Include a hyperlink in an email using PHP

I am currently using an HTML form textarea along with PHP to send emails through my website. My question is, how can I successfully insert a link into the email message body? I attempted to do it like this: <a href="http://www.xxxxx.com/">Visit the ...

I am attempting to transform a date String into a long integer

When converting a string date into a long, I am unsure how to return the value as long. Additionally, I am seeking guidance on how to convert a string into long and store it in a room database. package com.example.mybugetssimple; import java.text.Pars ...

Incorporating text alongside an image with the help of Bootstrap

https://i.sstatic.net/pCTxH.png I'm struggling to find a way to modify every <p> tag. It always appears next to the the name should be here. I want it to be displayed below the name. <div class="card" style="width: 25rem;" ...

Implementing automatic logout with Okta in a Spring Application

Is there a way to set up automatic logout with Okta in a Spring application that will destroy the user session and also log out from Okta's side? ...

Select either one checkbox out of two available options

My form includes two checkboxes, allowing users to click on both of them. I'm wondering if it's possible to set it up so that only one checkbox can be selected at a time. For example, clicking on the first checkbox would turn it on while turning ...

Submitting a form and then redirecting to a PHP page

I have a dynamic form and I am currently using jQuery to submit it. Here is the code I have been using: $('#formsite').on('submit', function (e) { //prevent the default submithandling e.preventDefault(); //send the data of ' ...

It appears that the box-shadow feature is malfunctioning on Internet Explorer 8

Hey there, I'm having an issue with the box shadow not displaying correctly in IE 8. Here's my CSS code: .lt-ie9 .imageonHover:hover { box-shadow:1px 1px 5px 5px #E7E0E7; border-radius:3px; zoom: 1; filter: progid:DX ...

Problem with onblur and onchange events not being triggered in input tag

After encountering this issue, I came to the realization that the events onblur and onchange function properly. However, I noticed that if your page contains only ONE <input type="text" onblur="loadXMLDoc()"> Change Content</input> The behav ...

What is the best method for displaying HTML files using modal.open in jQuery?

I have been utilizing a well-functioning code to open a modal with JQuery: $(document).ready(function(){ $("span.ico-detail").click(function(){ modal.open({content: "View detail of " + $(this).parent().par ...

I'm finding it difficult to decide which comparison operators to utilize for my JavaScript game. Experimenting with both the "&&" and "||" options has left me unsure of which

In this scenario: If the user enters a number in the text box, such as 2 (paper) or 3 (scissors), the "ComputerChoice" will randomly generate a number between 1 and 3. The goal is to make the computer understand and react to different scenarios... For exa ...

css failing to load properly following javascript redirection

Upon clicking the button labeled id=cancel, the user will be directed to index.php. $('#cancel').click(function() { if(changes > 0){ $('#dialog-confirm').dialog('open'); }else{ window.location.href = ". ...

Using Thymeleaf for EL expressions allows for type casting in a seamless and efficient

Is there a way to change object types in EL expressions? The Thymeleaf engine seems to have trouble understanding something like this: <span th:text="${((NewObjectType)obj).amount"></span> Thank you. Update: Here is the class hierarchy I am ...

Troubleshooting a problem with CSS Matrix animations

Lately, I've been working on creating some matrix animations. However, I noticed an unusual issue. The code below seems to function differently across Firefox, Safari, and Chrome: @-moz-keyframes matrix { from { -moz-transform: matri ...

.bootstrapMaterialDatePicker does not work within Codeigniter version 3

I am experiencing an issue with my form that has two date fields stored as varchar <div class="row clearfix"> <div class="col-lg-2 col-md-2 col-sm-4 col-xs-5 form-control-label"> <label for="ar ...

To increment a counter variable when the sentence does not conclude with a period

Hey everyone, I'm currently working on creating a simple Lexical analyzer. In order to do this, I need to separate a string into sentences. If a sentence ends with a full stop, it should be split. However, I also need to account for situations where p ...

I am attempting to create a stylish border for the .navbar-collapse element, but unfortunately, my efforts have been unsuccessful so far

I need assistance with adding a border around my mobile drop-down menu. I've tried using .navbar-collapse but it's not working. Any suggestions? Here is a sample image of the mobile size: https://i.sstatic.net/O9oA1.png Below is my code: < ...

Classes aren't displaying properly for elements inside

Is there a way to display the header only in a small size using the col-sm-* class of the div inside a container? It seems like the col-sm-* class is not working correctly and not floating them properly. <link href="https://maxcdn.bootstrapcdn.com/b ...

How can I stop the page from jumping when a Button is clicked in ReactJS?

I've created a ShowcaseMovie component that fetches data using componentDidMount(), stores it in state, and renders Card components to display the data. The component also features four button elements for toggling between different filters: upcoming, ...