فهرست منبع

Add support for ToC options

When creating the command line, all parameters were added before the 'toc' argument.
Therefore, the ToC parameters didn't work (they should be placed after the 'toc' param).
I added a separate tocParams data member with the relevant addTocParam() method.
Oren Cohen 7 سال پیش
والد
کامیت
a6b54ac877
1فایلهای تغییر یافته به همراه10 افزوده شده و 1 حذف شده
  1. 10 1
      src/main/java/com/github/jhonnymertz/wkhtmltopdf/wrapper/Pdf.java

+ 10 - 1
src/main/java/com/github/jhonnymertz/wkhtmltopdf/wrapper/Pdf.java

@@ -28,6 +28,8 @@ public class Pdf {
 
     private final Params params;
 
+    private final Params tocParams;
+
     private final List<Page> pages;
 
     private boolean hasToc = false;
@@ -39,6 +41,7 @@ public class Pdf {
     public Pdf(WrapperConfig wrapperConfig) {
         this.wrapperConfig = wrapperConfig;
         this.params = new Params();
+        this.tocParams = new Params();
         this.pages = new ArrayList<Page>();
     }
 
@@ -81,6 +84,10 @@ public class Pdf {
         this.params.add(param, params);
     }
 
+    public void addTocParam(Param param, Param... params) {
+        this.tocParams.add(param, params);
+    }
+
     public File saveAs(String path) throws IOException, InterruptedException {
         File file = new File(path);
         FileUtils.writeByteArrayToFile(file, getPDF());
@@ -120,8 +127,10 @@ public class Pdf {
 
         commandLine.addAll(params.getParamsAsStringList());
 
-        if (hasToc)
+        if (hasToc) {
             commandLine.add("toc");
+            commandLine.addAll(tocParams.getParamsAsStringList());
+        }
 
         for (Page page : pages) {
             if (page.getType().equals(PageType.htmlAsString)) {