Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Aspose.PDF permite criar documentos de Portfólio PDF usando a Document classe. Adicione um arquivo em um objeto Document.Collection após obtê-lo com a FileSpecification classe. Quando os arquivos forem adicionados, use o método Save da classe Document para salvar o documento do portfólio.
O exemplo a seguir usa um arquivo Microsoft Excel, um documento Word e um arquivo de imagem para criar um Portfólio PDF.
O código abaixo resulta no seguinte portfólio.
O seguinte trecho de código também funciona com a biblioteca 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");
}
}
Portfólios PDF permitem reunir conteúdo de uma variedade de fontes (por exemplo, arquivos PDF, Word, Excel, JPEG) em um único contêiner unificado. Os arquivos originais mantêm suas identidades individuais, mas são montados em um arquivo de Portfólio PDF. Os usuários podem abrir, ler, editar e formatar cada arquivo componente independentemente dos outros arquivos componentes.
Aspose.PDF permite a criação de documentos de Portfólio PDF usando a Document classe. Também oferece a capacidade de extrair arquivos de um portfólio PDF.
O seguinte trecho de código mostra os passos para extrair arquivos de um portfólio 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);
}
}
}
}
Para deletar/remover arquivos do portfólio PDF, tente usar as seguintes linhas de código.
// 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.