PDF/X Print Production
PDF/X (ISO 15930) é o padrão para troca confiável de arquivos PDF prontos para impressao. PDF Oxide validates all major PDF/X levels, checking página boxes, color spaces, transparency, ICC profiles, and output intents.
Níveis Suportados
| Level | Standard | Transparency | RGB | Layers | External ICC | External Graphics |
|---|---|---|---|---|---|---|
| X-1a:2001 | ISO 15930-1 | Não | Não | Não | Não | Não |
| X-1a:2003 | ISO 15930-4 | Não | Não | Não | Não | Não |
| X-3:2002 | ISO 15930-3 | Não | Sim | Não | Não | Não |
| X-3:2003 | ISO 15930-6 | Não | Sim | Não | Não | Não |
| X-4 | ISO 15930-7 | Sim | Sim | Sim | Não | Não |
| X-4p | ISO 15930-7 | Sim | Sim | Sim | Sim | Não |
| X-5g | ISO 15930-8 | Sim | Sim | Sim | Não | Sim |
| X-5n | ISO 15930-8 | Sim | Sim | Sim | Não | Sim |
| X-5pg | ISO 15930-8 | Sim | Sim | Sim | Sim | Sim |
| X-6 | ISO 15930-9 | Sim | Sim | Sim | Não | Não |
| X-6n | ISO 15930-9 | Sim | Sim | Sim | Não | Sim |
| X-6p | ISO 15930-9 | Sim | Sim | Sim | Sim | Não |
PDF/X-1a is the most restrictive: CMYK-only, sem transparência, no layers. PDF/X-4 is the most commonly used modern level, allowing transparency and RGB with ICC profiles.
Validação Rápida
from pdf_oxide import PdfDocument
doc = PdfDocument("document.pdf")
result = doc.validate_pdf_x("4")
print(f"Valid: {result.valid}")
use pdf_oxide::PdfDocument;
use pdf_oxide::compliance::pdf_x::{validate_pdf_x, PdfXLevel};
let mut doc = PdfDocument::open("print-ready.pdf")?;
let result = validate_pdf_x(&mut doc, PdfXLevel::X4)?;
if result.has_errors() {
println!("Not PDF/X-4 compliant ({} errors):", result.errors.len());
for error in &result.errors {
println!(" [{}] {} (clause {})",
error.code, error.message,
error.clause.as_deref().unwrap_or("n/a"));
}
} else {
println!("Document is PDF/X-4 compliant");
}
API do Validador
O builder PdfXValidator configura a execução da validação:
use pdf_oxide::PdfDocument;
use pdf_oxide::compliance::pdf_x::{PdfXValidator, PdfXLevel};
let mut doc = PdfDocument::open("artwork.pdf")?;
let result = PdfXValidator::new(PdfXLevel::X1a2001)
.stop_on_first_error(false)
.include_warnings(true)
.validate(&mut doc)?;
println!("Errors: {}", result.errors.len());
println!("Warnings: {}", result.warnings.len());
println!("Total issues: {}", result.total_issues());
O Que e Verificado
XMP Identification
O validador confirma que os metadados XMP declaram a versão correta do PDF/X:
pdfxid:GTS_PDFXVersionmust match the target level- The declared version is compared against the
gts_pdfx_version()for the target level
Página Box Relationships
PDF/X requires specific nesting of página boxes:
TrimBox <= BleedBox <= MediaBox
ArtBox <= MediaBox
O validador verifica cada página para garantir:
- TrimBox is present (required by all PDF/X levels)
- TrimBox is contained within BleedBox (if BleedBox is defined)
- BleedBox is contained within MediaBox
- ArtBox is contained within MediaBox (if ArtBox is defined)
- Tolerance of 0.01 points for floating-point rounding
Transparency Detection
Para PDF/X-1a and PDF/X-3, sem transparência is permitted. The validator checks:
- SMask in ExtGState dictionaries (must be
/Noneor absent) - CA (stroke opacity) must equal 1.0
- ca (fill opacity) must equal 1.0
- BM (blend mode) must be
NormalorCompatible
PDF/X-4 and later levels permit transparency.
Color Space Validation
O validador verifica o uso de cores dependentes de dispositivo:
- DeviceRGB is not allowed in PDF/X-1a (CMYK-only)
- DeviceRGB, DeviceCMYK, and DeviceGray used without an output intent trigger errors in stricter levels
- Color operators
rg,RG,k,K,g,Gin página content streams are scanned
ICC Profile Validation
Para ICCBased color spaces, the validator checks:
- The profile stream contains the required
/N(number of components) entry - The
/Nvalue matches the expected color space dimension (1 for gray, 3 for RGB, 4 for CMYK) - The profile data is present and non-empty
Output Intent
PDF/X requires an output intent that describes the intended print condition:
/OutputIntentsarray must be present in the document catalog- At least one entry with subtype
GTS_PDFXis required - The output intent should reference an ICC profile or a registered print condition
XValidationResult
pub struct XValidationResult {
pub level: PdfXLevel,
pub errors: Vec<XComplianceError>,
pub warnings: Vec<XComplianceError>,
pub stats: XValidationStats,
}
XComplianceError
pub struct XComplianceError {
pub code: XErrorCode,
pub message: String,
pub severity: XSeverity,
pub page: Option<usize>,
pub object_id: Option<u32>,
pub clause: Option<String>,
}
Errors include the página number and object ID where the violation was found, making it straightforward to locate and fix issues in the source file.
XErrorCode Categories
O enum XErrorCode contém mais de 40 códigos de erro específicos organizados por categoria:
Metadata: MissingOutputIntent, InvalidGtsPdfxVersion, MissingXmpIdentification
Page boxes: MissingTrimBox, TrimBoxOutsideBleedBox, BleedBoxOutsideMediaBox, ArtBoxOutsideMediaBox
Transparency: TransparencyNotAllowed, InvalidBlendMode, InvalidSMask, InvalidOpacity
Color: DeviceRgbNotAllowed, DeviceDependentColorWithoutIntent, InvalidIccProfile, MissingIccComponents
Content: ExternalContentNotAllowed, CriptografiaNotAllowed, JavaScriptNotAllowed
Métodos PdfXLevel
| Método | Retorno | Descrição |
|---|---|---|
iso_standard() |
&str |
ISO standard number (e.g., "ISO 15930-7") |
required_pdf_version() |
&str |
Minimum Versão do PDF (e.g., "1.6") |
allows_transparency() |
bool |
Whether transparency groups are permitted |
allows_rgb() |
bool |
Whether Cor RGB space is permitted |
allows_layers() |
bool |
Whether optional content groups are permitted |
allows_external_icc() |
bool |
Whether external ICC profiles are permitted |
allows_external_graphics() |
bool |
Whether external graphics references are permitted |
gts_pdfx_version() |
&str |
Expected GTS_PDFXVersion value |
xmp_version() |
&str |
Expected XMP version identifier |
from_gts_version(version) |
Option<Self> |
Parse level from a GTS version string |
Exemplo Pratico: Prepress Check
use pdf_oxide::PdfDocument;
use pdf_oxide::compliance::pdf_x::{validate_pdf_x, PdfXLevel, XSeverity};
let mut doc = PdfDocument::open("magazine-cover.pdf")?;
let result = validate_pdf_x(&mut doc, PdfXLevel::X4)?;
println!("=== PDF/X-4 Prepress Report ===");
println!("Status: {}", if result.has_errors() { "REJECT" } else { "ACCEPT" });
// Group errors by severity
let critical: Vec<_> = result.errors.iter()
.filter(|e| e.is_error())
.collect();
let advisory: Vec<_> = result.warnings.iter().collect();
if !critical.is_empty() {
println!("\nCritical ({}):", critical.len());
for e in &critical {
let page_str = e.page
.map(|p| format!("page {}", p + 1))
.unwrap_or_else(|| "document".into());
println!(" [{}] {} ({})", e.code, e.message, page_str);
}
}
if !advisory.is_empty() {
println!("\nAdvisory ({}):", advisory.len());
for w in &advisory {
println!(" [{}] {}", w.code, w.message);
}
}
Próximos Passos
- PDF/A Validation – archival compliance
- PDF/UA Accessibility – accessibility validation
- API Reference – API Rust completa