تحويل ملفات PDF إلى تنسيقات PDF/A
Aspose.PDF for .NET يتيح لك تحويل ملف PDF إلى ملف PDF متوافق مع PDF/A . قبل القيام بذلك، يجب التحقق من صحة الملف. يشرح هذا الموضوع كيفية القيام بذلك.
نتبع Adobe Preflight و veraPDF للتحقق من توافق PDF/A. جميع الأدوات في السوق لديها “تمثيل” خاص بها لتوافق PDF/A. يرجى مراجعة هذه المقالة حول أدوات التحقق من PDF/A للرجوع إليها. اخترنا منتجات Adobe للتحقق من كيفية إنتاج Aspose.PDF لملفات PDF لأن Adobe هي في مركز كل ما يتعلق بـ PDF.
قم بتحويل الملف باستخدام طريقة Convert من فئة Document. قبل تحويل PDF إلى ملف متوافق مع PDF/A، تحقق من صحة PDF باستخدام طريقة Validate. يتم تخزين نتيجة التحقق في ملف XML ثم يتم تمرير هذه النتيجة أيضًا إلى طريقة Convert. يمكنك أيضًا تحديد الإجراء للعناصر التي لا يمكن تحويلها باستخدام تعداد ConvertErrorAction.
حاول تحويل PDF إلى PDF/A عبر الإنترنت
Aspose.PDF for .NET يقدم لك تطبيقًا مجانيًا عبر الإنترنت “PDF إلى 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 متوافقة مع PDF/A-1b.
لإجراء التحقق فقط، استخدم السطر التالي من الكود:
تحويل ملف 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، فإننا نوصي باستخدام قيمة PDF_A_3A من تعداد Aspose.PDF.PdfFormat.
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 يفشل. في هذه الحالة، من الضروري استبدال الخطوط المفقودة ببعض الخطوط البديلة الموجودة على الجهاز. يمكن استبدال الخطوط المفقودة باستخدام فئة SimpleFontSubsitution أثناء تحويل PDF إلى 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 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 .
إذا كان المستند يحتوي بالفعل على علامات هيكل منطقي، فإن تمكين التمييز التلقائي سيدمر الهيكل المنطقي الحالي وينشئ هيكلًا جديدًا.