PDF Generation Template Editor
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
ComPDFKit PDF SDK supports converting PDF documents to various PDF standard formats, including PDF/A (for long-term archiving), PDF/X (for printing), PDF/E (for engineering documents), PDF/UA (for accessibility), and PDF/VT (for variable data printing).
Use the WriteStandardPDFToFilePath method to convert an existing PDF file to a specified PDF standard format. This method analyzes the content of the existing PDF file and makes a series of modifications to generate a document compliant with the target standard.
During the conversion process, features unsuitable for the target standard (such as encryption, outdated compression schemes, missing fonts, or device-dependent colors) will be replaced with standard-compliant equivalents. Since the conversion process applies only the necessary changes to the source file, minimal information loss occurs.
Method Signature:
public bool WriteStandardPDFToFilePath(
PDFDocumentType standardType, // PDF standard type
String iccFilePath, // ICC color profile path (optional, leave empty for default)
String saveFilePath, // Output file save path
CPDFUAConfig uaConfig // PDF/UA configuration (only required for PDF/UA format)
)Parameters:
| Parameter | Type | Description |
|---|---|---|
| standardType | PDFDocumentType | Target PDF standard type, containing format, version number, and subtype |
| iccFilePath | string | ICC color profile path. If the file does not exist, the default configuration file will be automatically selected based on the standard type |
| saveFilePath | string | Save path for the converted document |
| uaConfig | CPDFUAConfig | PDF/UA configuration (optional), used to set document title and language |
Example - Convert to PDF/A-1a:
CPDFDocument doc1 = new CPDFDocument();
doc1.open("test.pdf");
boolean ok1 = doc1.WriteStandardPDFToFilePath(
CPDFDocument.PDFDocumentType.PDFTypeA1a,
"sRGB2014.icc",
"convpdfa1a.pdf");
doc1.close();Example - Convert to PDF/UA:
String filePath = "test.pdf";
CPDFDocument document = new CPDFDocument();
document.open(filePath);
CPDFUAConfig ua = new CPDFUAConfig();
ua.title = "document";
ua.language = CPDFUAConfig.UALanguage.cs_CZ;
String iccPath = "sRGB2014.icc";
String outPath = "convpdfUA_config.pdf";
boolean ok = document.WriteStandardPDFToFilePath(
CPDFDocument.PDFDocumentType.PDFTypeUA1, iccPath, outPath, ua);
document.close();
System.out.println("convertPDFUA with config: " + ok);Use the GetPDFStandardType method to detect whether a document currently conforms to a PDF standard format.
Method Signature:
public PDFStandardType GetPDFStandardType()Return Value:
Returns a PDFStandardType struct containing the following fields:
| Field | Type | Description |
|---|---|---|
| Format | CPDFStandardFormat | PDF standard format (StandardPDF, StandardPDFA, StandardPDFX, etc.) |
| TypeNum | int | Version number (e.g., TypeNum is 1 for PDF/A-1) |
| Type | CPDFPartType | Subtype (PDF_a, PDF_b, PDF_u, or None) |
Example:
CPDFDocument doc1 = new CPDFDocument();
doc1.open("test.pdf");
CPDFStandardType standardType = document.GetPDFStandardType();
switch (standardType.Format)
{
case CPDFStandardFormat.StandardPDF:
System.out.println("common PDF document");
break;
case CPDFStandardFormat.StandardPDFA:
System.out.println("PDF/A-"+standardType.TypeNum + GetPartTypeSuffix(standardType.Type) + "document");
break;
case CPDFStandardFormat.StandardPDFX:
System.out.println("PDF/X-"+standardType.TypeNum + "document");
break;
case CPDFStandardFormat.StandardPDFUA:
System.out.println("PDF/UA-" + standardType.TypeNum + "document");
break;
default:
System.out.println("Other standard format: " + standardType.Format);
break;
}
// Helper method: get subtype suffix
String GetPartTypeSuffix(CPDFPartType partType)
{
if (partType == PDFPartType.PDF_a) {
return "a";
} else if (partType == PDFPartType.PDF_b) {
return "b";
} else if (partType == PDFPartType.PDF_u) {
return "u";
} else return "";
}