Skip to content

Instantly share code, notes, and snippets.

@SiddiqueAhmad
Last active November 24, 2022 04:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SiddiqueAhmad/7ca3da59301ce21093b2435fc25b7b94 to your computer and use it in GitHub Desktop.
Save SiddiqueAhmad/7ca3da59301ce21093b2435fc25b7b94 to your computer and use it in GitHub Desktop.
custom fonts in BIRT, integrated with Axelor
public class AnyController {
private final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
public void print(
ActionRequest request, ActionResponse response) {
List<Long> ids = (List) request.getContext().get("_ids");
String fileLink;
String title;
PrintServiceImpl printService = Beans.get(PrintServiceImpl.class);
fileLink = printService.getFileLink(ids);
response.setView(ActionView.define(title).add("html", fileLink).map());
}
}
import com.axelor.app.AxelorModule;
public class AnyModule extends AxelorModule {
@Override
protected void configure() {
bind(PrintServiceImpl.class);
}
}
cp "/resources_path/report/fonts/font-family/font1.ttf" ~/.fonts
fc-cache -fv
import com.axelor.apps.tool.file.PdfTool;
import com.google.inject.Inject;
import com.lowagie.text.FontFactory;
import org.eclipse.birt.report.engine.api.IReportEngine;
import java.util.List;
import java.io.IOException;
public class PrintServiceImpl {
private IReportEngine engine;
@Inject
public PrintServiceImpl(IReportEngine engine) {
this.engine = engine;
FontFactory.register("/resources_path/report/fonts/font-family/font1.ttf", "alias-fontfamily");
}
public String getFileLink(List<Long> ids) throws IOException {
List<File> printedSaleOrders = new ArrayList<>();
return PdfTool.mergePdfToFileLink(printedSaleOrders, "prefix-SaleOrders-postfix.pdf");
}
}
@zeeshanA265
Copy link

Informative ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment