Add pdf-invoice module: one invoice in OpenPDF 3.0.5, iText Core 9.8.0 and Flying Saucer 10.7.0, Devanagari shaping checked by rendering, streamed vs buffered download, subset sizes and timings
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b6Kg9RWSTJzyz6KP9X
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package com.ankurm.pdfinvoice;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Rupee formatting with Indian digit grouping (12,34,567.00), shared by all three writers.
|
||||
* It is a class of our own because Thymeleaf 3.1 refuses to call methods on {@code java.*} types
|
||||
* from a template expression ("Calling method 'format' is forbidden for type DecimalFormat").
|
||||
*/
|
||||
public final class Money {
|
||||
|
||||
private Money() {}
|
||||
|
||||
public static String inr(BigDecimal v) {
|
||||
NumberFormat f = NumberFormat.getNumberInstance(Locale.of("en", "IN"));
|
||||
f.setMinimumFractionDigits(2);
|
||||
f.setMaximumFractionDigits(2);
|
||||
return "₹ " + f.format(v);
|
||||
}
|
||||
|
||||
/** Template-friendly instance wrapper: {@code ${money.inr(x)}}. */
|
||||
public static final class Fmt {
|
||||
public String inr(BigDecimal v) {
|
||||
return Money.inr(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user