Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 55 additions & 1 deletion openpdf-core/src/main/java/org/openpdf/text/pdf/PdfWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,30 @@ public class PdfWriter extends DocWriter implements
* PDFA-1B level.
*/
public static final int PDFA1B = 4;
/**
* PDFA-2A level.
*/
public static final int PDFA2A = 5;
/**
* PDFA-2B level.
*/
public static final int PDFA2B = 6;
/**
* PDFA-2U level.
*/
public static final int PDFA2U = 7;
/**
* PDFA-3A level.
*/
public static final int PDFA3A = 8;
/**
* PDFA-3B level.
*/
public static final int PDFA3B = 9;
/**
* PDFA-3U level.
*/
public static final int PDFA3U = 10;
/**
* No encryption
*/
Expand Down Expand Up @@ -1790,6 +1814,9 @@ public void setPDFXConformance(int pdfx) {
}
if (pdfx == PDFA1A || pdfx == PDFA1B) {
setPdfVersion(VERSION_1_4);
} else if (pdfx == PDFA2A || pdfx == PDFA2B || pdfx == PDFA2U
|| pdfx == PDFA3A || pdfx == PDFA3B || pdfx == PDFA3U) {
setPdfVersion(VERSION_1_7);
} else if (pdfx != PDFXNONE) {
setPdfVersion(VERSION_1_3);
}
Expand All @@ -1809,6 +1836,33 @@ public boolean isPdfA1() {
return pdfxConformance.isPdfA1();
}

/**
* Checks if the PDF has to be in conformance with PDFA2
*
* @return true if the PDF has to be in conformance with PDFA2
*/
public boolean isPdfA2() {
return pdfxConformance.isPdfA2();
}

/**
* Checks if the PDF has to be in conformance with PDFA3
*
* @return true if the PDF has to be in conformance with PDFA3
*/
public boolean isPdfA3() {
return pdfxConformance.isPdfA3();
}

/**
* Checks if the PDF has to be in conformance with any PDF/A version
*
* @return true if the PDF has to be in conformance with any PDF/A version
*/
public boolean isPdfA() {
return pdfxConformance.isPdfA();
}

/**
* Sets the values of the output intent dictionary. Null values are allowed to suppress any key.
*
Expand Down Expand Up @@ -1843,7 +1897,7 @@ public void setOutputIntents(String outputConditionIdentifier, String outputCond
}

PdfName intentSubtype;
if (pdfxConformance.isPdfA1() || "PDFA/1".equals(outputCondition)) {
if (pdfxConformance.isPdfA() || "PDFA/1".equals(outputCondition)) {
intentSubtype = PdfName.GTS_PDFA1;
} else {
intentSubtype = PdfName.GTS_PDFX;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,39 @@ public boolean isPdfA1A() {
return pdfxConformance == PdfWriter.PDFA1A;
}

/**
* Checks if the PDF has to be in conformance with PDFA2
*
* @return true if the PDF has to be in conformance with PDFA2
*/
public boolean isPdfA2() {
return pdfxConformance == PdfWriter.PDFA2A
|| pdfxConformance == PdfWriter.PDFA2B
|| pdfxConformance == PdfWriter.PDFA2U;
}

/**
* Checks if the PDF has to be in conformance with PDFA3
*
* @return true if the PDF has to be in conformance with PDFA3
*/
public boolean isPdfA3() {
return pdfxConformance == PdfWriter.PDFA3A
|| pdfxConformance == PdfWriter.PDFA3B
|| pdfxConformance == PdfWriter.PDFA3U;
}

/**
* Checks if the PDF has to be in conformance with any PDF/A version
*
* @return true if the PDF has to be in conformance with any PDF/A version
*/
public boolean isPdfA() {
return isPdfA1() || isPdfA2() || isPdfA3();
}

public void completeInfoDictionary(PdfDictionary info) {
if (isPdfX() && !isPdfA1()) {
if (isPdfX() && !isPdfA()) {
if (info.get(PdfName.GTS_PDFXVERSION) == null) {
if (isPdfX1A2001()) {
info.put(PdfName.GTS_PDFXVERSION, new PdfString("PDF/X-1:2001"));
Expand All @@ -301,7 +332,7 @@ public void completeInfoDictionary(PdfDictionary info) {
}

public void completeExtraCatalog(PdfDictionary extraCatalog) {
if (isPdfX() && !isPdfA1()) {
if (isPdfX() && !isPdfA()) {
if (extraCatalog.get(PdfName.OUTPUTINTENTS) == null) {
PdfDictionary out = new PdfDictionary(PdfName.OUTPUTINTENT);
out.put(PdfName.OUTPUTCONDITION, new PdfString("SWOP CGATS TR 001-1995"));
Expand Down
32 changes: 28 additions & 4 deletions openpdf-core/src/main/java/org/openpdf/text/xml/xmp/XmpWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,37 @@ public XmpWriter(OutputStream os, PdfDictionary info, int PdfXConformance) throw
addRdfDescription(basic);
}
if (PdfXConformance == PdfWriter.PDFA1A || PdfXConformance == PdfWriter.PDFA1B) {
PdfA1Schema a1 = new PdfA1Schema();
PdfA1Schema pdfA1Schema = new PdfA1Schema();
if (PdfXConformance == PdfWriter.PDFA1A) {
a1.addConformance("A");
pdfA1Schema.addConformance("A");
} else {
a1.addConformance("B");
pdfA1Schema.addConformance("B");
}
addRdfDescription(a1);
addRdfDescription(pdfA1Schema);
} else if (PdfXConformance == PdfWriter.PDFA2A || PdfXConformance == PdfWriter.PDFA2B
|| PdfXConformance == PdfWriter.PDFA2U) {
PdfA1Schema pdfA2Schema = new PdfA1Schema();
pdfA2Schema.addPart("2");
if (PdfXConformance == PdfWriter.PDFA2A) {
pdfA2Schema.addConformance("A");
} else if (PdfXConformance == PdfWriter.PDFA2B) {
pdfA2Schema.addConformance("B");
} else {
pdfA2Schema.addConformance("U");
}
addRdfDescription(pdfA2Schema);
} else if (PdfXConformance == PdfWriter.PDFA3A || PdfXConformance == PdfWriter.PDFA3B
|| PdfXConformance == PdfWriter.PDFA3U) {
PdfA1Schema pdfA3Schema = new PdfA1Schema();
pdfA3Schema.addPart("3");
if (PdfXConformance == PdfWriter.PDFA3A) {
pdfA3Schema.addConformance("A");
} else if (PdfXConformance == PdfWriter.PDFA3B) {
pdfA3Schema.addConformance("B");
} else {
pdfA3Schema.addConformance("U");
}
addRdfDescription(pdfA3Schema);
}
}
}
Expand Down
Loading
Loading