Skip to content

Commit

Permalink
feat(pdf-engines): add conversion properties and options
Browse files Browse the repository at this point in the history
  • Loading branch information
cherfia committed Apr 6, 2024
1 parent 45b572e commit 1d1d94a
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package dev.inaka.pdfengines;

/**
* The PDFEnginesConversionOptions class is used to configure LibreOffice conversion options.
*/
public final class PDFEnginesConversionOptions extends PDFEnginesOptions {

private PDFEnginesConversionOptions(Builder builder) {
super(builder);
}

/**
* The Builder class is used to construct instances of PDFEnginesConversionOptions with specific configuration options.
*/
public static class Builder extends PDFEnginesOptions.Builder<PDFEnginesConversionOptions> {

@Override
public PDFEnginesConversionOptions build() {
return new PDFEnginesConversionOptions(this);
}
}
}
39 changes: 39 additions & 0 deletions src/main/java/dev/inaka/pdfengines/PDFEnginesMergeOptions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package dev.inaka.pdfengines;

import org.json.JSONObject;

/**
* The PDFEnginesMergeOptions class is used to configure LibreOffice conversion options.
*/
public final class PDFEnginesMergeOptions extends PDFEnginesOptions {
private final String metadata;

private PDFEnginesMergeOptions(Builder builder) {
super(builder);
metadata = builder.metadata;
}

/**
* The Builder class is used to construct instances of PDFEnginesMergeOptions with specific configuration options.
*/
public static class Builder extends PDFEnginesOptions.Builder<PDFEnginesMergeOptions> {
private String metadata = null;

/**
* Sets the metadata to be used by PDF Engines.
*
* @param metadata The metadata.
* @return The Builder instance for method chaining.
*/
public Builder addMetadata(JSONObject metadata) {
this.metadata = String.valueOf(metadata);
return this;
}

@Override
public PDFEnginesMergeOptions build() {
return new PDFEnginesMergeOptions(this);
}
}
}

54 changes: 54 additions & 0 deletions src/main/java/dev/inaka/pdfengines/PDFEnginesOptions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package dev.inaka.pdfengines;

import dev.inaka.common.PdfFormat;

/**
* The PDFEnginesOptions class is used to configure LibreOffice conversion options.
*/
public abstract class PDFEnginesOptions {
protected final String pdfa;
protected final String pdfua;

protected PDFEnginesOptions(Builder builder) {
pdfa = builder.pdfa;
pdfua = builder.pdfua;
}

/**
* The Builder class is used to construct instances of PDFEnginesOptions with specific configuration options.
*/
public static abstract class Builder<T extends PDFEnginesOptions> {
protected String pdfa = null;
protected String pdfua = "false";

/**
* Sets the PDF/A format to be used by PDF Engines.
*
* @param pdfa The PDF/A format.
* @return The Builder instance for method chaining.
*/
public Builder<T> addPdfa(PdfFormat pdfa) {
this.pdfa = String.valueOf(pdfa);
return this;
}

/**
* Sets whether to use PDF/UA.
*
* @param pdfua Whether to use PDF/UA.
* @return The Builder instance for method chaining.
*/
public Builder<T> addPdfua(String pdfua) {
this.pdfua = pdfua;
return this;
}

/**
* Builds and returns an instance of PDFEnginesOptions with the configured options.
*
* @return An instance of PDFEnginesOptions with the configured options.
*/
public abstract T build();
}
}

0 comments on commit 1d1d94a

Please sign in to comment.