PDF를 PDF/A 형식으로 변환
Aspose.PDF for .NET 은 PDF 파일을 PDF/A 준수 PDF 파일로 변환할 수 있게 해줍니다. 이를 수행하기 전에 파일을 검증해야 합니다. 이 주제에서는 그 방법을 설명합니다.
우리는 PDF/A 준수를 검증하기 위해 Adobe Preflight와 veraPDF를 따릅니다. 시장의 모든 도구는 PDF/A 준수에 대한 고유한 “표현"을 가지고 있습니다. 참조를 위해 PDF/A 검증 도구에 대한 이 기사를 확인하세요. Aspose.PDF가 PDF 파일을 생성하는 방식을 검증하기 위해 Adobe 제품을 선택했습니다. Adobe는 PDF와 관련된 모든 것의 중심에 있기 때문입니다.
Document 클래스의 Convert 메서드를 사용하여 파일을 변환합니다. PDF를 PDF/A 준수 파일로 변환하기 전에 Validate 메서드를 사용하여 PDF를 검증합니다. 검증 결과는 XML 파일에 저장되며, 이 결과는 Convert 메서드에도 전달됩니다. ConvertErrorAction 열거형을 사용하여 변환할 수 없는 요소에 대한 작업을 지정할 수도 있습니다.
PDF를 PDF/A로 온라인 변환해 보세요
Aspose.PDF for .NET은 “PDF to PDF/A-1A” 라는 온라인 무료 애플리케이션을 제공하여 기능과 품질을 조사해 볼 수 있습니다.
다음 코드 스니펫은 Aspose.PDF.Drawing 라이브러리와 함께 작동합니다.
지원되는 표준
다음 표준을 지원합니다: PDF/A-1b, PDF/A-1a, PDF/A-2b, PDF/A-2u, PDF/A-2a, PDF/A-3b, PDF/A-3u, PDF/A-3a, PDF/A-4, PDF/A-4e, PDF/A-4f.
PDF 파일을 PDF/A-1b로 변환
PDF를 PDF/A-1b로 변환
다음 코드 스니펫은 PDF 파일을 PDF/A-1b 준수 PDF로 변환하는 방법을 보여줍니다.
검증만 수행하려면 다음 코드 줄을 사용하세요:
PDF 파일을 PDF/A-3b로 변환
PDF를 PDF/A-3b로 변환
Aspose.PDF for .NET은 PDF 파일을 PDF/A-3b 형식으로 변환하는 기능도 지원합니다.
PDF 파일을 PDF/A-4로 변환
PDF를 PDF/A-4로 변환
Aspose.PDF for .NET은 PDF 파일을 PDF/A-4 형식으로 변환하는 기능도 지원합니다.
.NET Core 3.1
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void ConvertPdfToPdfA4 ()
{
// The path to the documents directory
var dataDir = RunExamples . GetDataDir_AsposePdf_DocumentConversion ();
// Open PDF document
using ( var document = new Aspose . Pdf . Document ( dataDir + "PDFToPDFA.pdf" ))
{
// If the document version is less than PDF-2.0, it must be converted to PDF-2.0
document . Convert ( Stream . Null , Aspose . Pdf . PdfFormat . v_2_0 , Aspose . Pdf . ConvertErrorAction . Delete );
// Convert to the PDF/A-4 format
document . Convert ( dataDir + "PDFA4ConversionLog.xml" , Aspose . Pdf . PdfFormat . PDF_A_4 , Aspose . Pdf . ConvertErrorAction . Delete );
// Save PDF document
document . Save ( dataDir + "PDFToPDFA4_out.pdf" );
}
}
.NET 8
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void ConvertPdfToPdfA4 ()
{
// The path to the documents directory
var dataDir = RunExamples . GetDataDir_AsposePdf_DocumentConversion ();
// Open PDF document
using var document = new Aspose . Pdf . Document ( dataDir + "PDFToPDFA.pdf" );
// If the document version is less than PDF-2.0, it must be converted to PDF-2.0
document . Convert ( Stream . Null , Aspose . Pdf . PdfFormat . v_2_0 , Aspose . Pdf . ConvertErrorAction . Delete );
// Convert to the PDF/A-4 format
document . Convert ( dataDir + "PDFA4ConversionLog.xml" , Aspose . Pdf . PdfFormat . PDF_A_4 , Aspose . Pdf . ConvertErrorAction . Delete );
// Save PDF document
document . Save ( dataDir + "PDFToPDFA4_out.pdf" );
}
PDF/A 파일에 첨부 파일 추가
PDF/A 준수 문서에 파일을 첨부해야 하는 경우, Aspose.PDF.PdfFormat 열거형에서 PDF_A_3A 값을 사용하는 것을 권장합니다.
PDF/A-3a는 PDF/A 준수 파일에 첨부 파일로 모든 파일 형식을 첨부할 수 있는 기능을 제공하는 형식입니다.
.NET Core 3.1
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void AddAttachmentToPdfA ()
{
// The path to the documents directory
var dataDir = RunExamples . GetDataDir_AsposePdf_DocumentConversion ();
// Open PDF document
using ( var document = new Aspose . Pdf . Document ( dataDir + "PDFToPDFA.pdf" ))
{
// Setup new file to be added as attachment
using ( var fileSpecification = new Aspose . Pdf . FileSpecification ( dataDir + "aspose-logo.jpg" , "Large Image file" ))
{
// Add attachment to document's attachment collection
document . EmbeddedFiles . Add ( fileSpecification );
// Perform conversion to PDF/A-3a, so that the attachment is included in the resultant file
document . Convert ( dataDir + "PDFA3aConversionLog.xml" , Aspose . Pdf . PdfFormat . PDF_A_3A , Aspose . Pdf . ConvertErrorAction . Delete );
// Save PDF document
document . Save ( dataDir + "AddAttachmentToPDFA_out.pdf" );
}
}
}
.NET 8
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void AddAttachmentToPdfA ()
{
// The path to the documents directory
var dataDir = RunExamples . GetDataDir_AsposePdf_DocumentConversion ();
// Open PDF document
using var document = new Aspose . Pdf . Document ( dataDir + "PDFToPDFA.pdf" );
// Setup new file to be added as attachment
using var fileSpecification = new Aspose . Pdf . FileSpecification ( dataDir + "aspose-logo.jpg" , "Large Image file" );
// Add attachment to document's attachment collection
document . EmbeddedFiles . Add ( fileSpecification );
// Perform conversion to PDF/A-3a, so that the attachment is included in the resultant file
document . Convert ( dataDir + "PDFA3aConversionLog.xml" , Aspose . Pdf . PdfFormat . PDF_A_3A , Aspose . Pdf . ConvertErrorAction . Delete );
// Save PDF document
document . Save ( dataDir + "AddAttachmentToPDFA_out.pdf" );
}
누락된 글꼴을 대체 글꼴로 교체
PDF/A 표준에 따라 글꼴은 PDF/A 문서에 포함되어야 합니다. 그러나 소스 문서에 글꼴이 포함되어 있지 않거나 기계에 존재하지 않으면 PDF/A 변환이 실패합니다. 이 경우, 누락된 글꼴을 기계에 존재하는 대체 글꼴로 교체해야 합니다. 누락된 글꼴은 PDF에서 PDF/A로 변환하는 동안 SimpleFontSubsitution 클래스를 사용하여 대체할 수 있습니다.
.NET Core 3.1
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void ReplaceMissingFonts ()
{
// The path to the documents directory
var dataDir = RunExamples . GetDataDir_AsposePdf_DocumentConversion ();
try
{
// Check whether a font, used in the source document, is installed in the system
Aspose . Pdf . Text . FontRepository . FindFont ( "AgencyFB" );
}
catch ( Aspose . Pdf . FontNotFoundException )
{
// Font is missing on the destination machine. Replace it with the Arial font installed in the system
var fontSubstitution = new Aspose . Pdf . Text . SimpleFontSubstitution ( "AgencyFB" , "Arial" );
Aspose . Pdf . Text . FontRepository . Substitutions . Add ( fontSubstitution );
}
// Open PDF document
using ( var document = new Aspose . Pdf . Document ( dataDir + "PDFToPDFA.pdf" ))
{
// During the conversion, the missing font will be replaced with the substitution one
document . Convert ( dataDir + "ReplaceMissingFonts.xml" , PdfFormat . PDF_A_1B , ConvertErrorAction . Delete );
// Save PDF document
document . Save ( dataDir + "ReplaceMissingFonts_out.pdf" );
}
}
.NET 8
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void ReplaceMissingFonts ()
{
// The path to the documents directory
var dataDir = RunExamples . GetDataDir_AsposePdf_DocumentConversion ();
try
{
// Check whether a font, used in the source document, is installed in the system
Aspose . Pdf . Text . FontRepository . FindFont ( "AgencyFB" );
}
catch ( Aspose . Pdf . FontNotFoundException )
{
// Font is missing on the destination machine. Replace it with the Arial font installed in the system
var fontSubstitution = new Aspose . Pdf . Text . SimpleFontSubstitution ( "AgencyFB" , "Arial" );
Aspose . Pdf . Text . FontRepository . Substitutions . Add ( fontSubstitution );
}
// Open PDF document
using var document = new Aspose . Pdf . Document ( dataDir + "PDFToPDFA.pdf" );
// During the conversion, the missing font will be replaced with the substitution one
document . Convert ( dataDir + "ReplaceMissingFonts.xml" , PdfFormat . PDF_A_1B , ConvertErrorAction . Delete );
// Save PDF document
document . Save ( dataDir + "ReplaceMissingFonts_out.pdf" );
}
문서 논리 구조 태그 자동 생성
PDF 문서는 접근성과 조직을 향상시키기 위해 논리 구조 태그를 포함할 수 있습니다. 이러한 태그는 문서의 내용을 섹션, 단락 등과 같은 논리적 부분으로 나누어 구조화합니다. 문서가 PDF/A로 변환될 때, Aspose.PDF는 기본 논리 구조 마크업을 자동으로 생성할 수 있습니다. 사용자는 이 구조를 수동으로 다듬어 문서 내용에 대한 추가 통찰력을 추가할 수 있습니다.
논리 문서 구조를 생성하려면 Aspose.Pdf.AutoTaggingSettings 클래스의 인스턴스를 생성하고, AutoTaggingSettings.EnableAutoTagging 을 true
로 설정한 후 PdfFormatConversionOptions.AutoTaggingSettings 속성에 할당합니다.
문서에 이미 논리 구조 태그가 있는 경우, 자동 태그 생성을 활성화하면 기존 논리 구조가 파괴되고 새로운 구조가 생성됩니다.