Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
تسمح Aspose.PDF بإنشاء مستندات محفظة PDF باستخدام فئة Document. أضف ملفًا إلى كائن Document.Collection بعد الحصول عليه باستخدام فئة FileSpecification. عندما يتم إضافة الملفات، استخدم طريقة Save لفئة Document لحفظ مستند المحفظة.
المثال التالي يستخدم ملف Microsoft Excel، مستند Word وملف صورة لإنشاء محفظة PDF.
الكود أدناه ينتج عنه المحفظة التالية.
تعمل مقتطفات الكود التالية أيضًا مع مكتبة Aspose.PDF.Drawing.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void CreatePortfolio()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_TechnicalArticles();
// Create PDF document
using (var document = new Aspose.Pdf.Document())
{
// Instantiate document Collection object
document.Collection = new Aspose.Pdf.Collection();
// Get Files to add to Portfolio
var excel = new Aspose.Pdf.FileSpecification(dataDir + "HelloWorld.xlsx");
var word = new Aspose.Pdf.FileSpecification(dataDir + "HelloWorld.docx");
var image = new Aspose.Pdf.FileSpecification(dataDir + "aspose-logo.jpg");
// Provide description of the files
excel.Description = "Excel File";
word.Description = "Word File";
image.Description = "Image File";
// Add files to document collection
document.Collection.Add(excel);
document.Collection.Add(word);
document.Collection.Add(image);
// Save PDF document
document.Save(dataDir + "CreatePortfolio_out.pdf");
}
}
تسمح محافظ PDF بجمع المحتوى من مجموعة متنوعة من المصادر (على سبيل المثال، PDF، Word، Excel، ملفات JPEG) في حاوية موحدة واحدة. تحتفظ الملفات الأصلية بهوياتها الفردية ولكن يتم تجميعها في ملف محفظة PDF. يمكن للمستخدمين فتح وقراءة وتحرير وتنسيق كل ملف مكون بشكل مستقل عن الملفات المكونة الأخرى.
تسمح Aspose.PDF بإنشاء مستندات محفظة PDF باستخدام فئة Document. كما أنها تقدم القدرة على استخراج الملفات من محفظة PDF.
تظهر مقتطفات الكود التالية الخطوات لاستخراج الملفات من محفظة PDF.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void ExtractPortfolioFiles()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_TechnicalArticles();
// Open PDF document
using (var document = new Aspose.Pdf.Document(dataDir + "PDFPortfolio.pdf"))
{
// Get collection of embedded files
Aspose.Pdf.EmbeddedFileCollection embeddedFiles = document.EmbeddedFiles;
// Iterate through individual file of Portfolio
foreach (Aspose.Pdf.FileSpecification fileSpecification in embeddedFiles)
{
// Get the attachment and write to file or stream
byte[] fileContent = new byte[fileSpecification.Contents.Length];
fileSpecification.Contents.Read(fileContent, 0, fileContent.Length);
string filename = Path.GetFileName(fileSpecification.Name);
// Save the extracted file to some location
using (FileStream fileStream = new FileStream(dataDir + filename + "_out", FileMode.Create))
{
fileStream.Write(fileContent, 0, fileContent.Length);
}
}
}
}
من أجل حذف/إزالة الملفات من محفظة PDF، حاول استخدام أسطر الكود التالية.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void RemovePortfolioFiles()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_TechnicalArticles();
// Open PDF document
using (var document = new Aspose.Pdf.Document(dataDir + "PDFPortfolio.pdf"))
{
document.Collection.Delete();
// Save PDF document
document.Save(dataDir + "NoPortFolio_out.pdf");
}
}
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.