Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            //Create a new PDF document
            PdfDocument pdf = new PdfDocument();

            //Load the file from disk.
            pdf.LoadFromFile(@"..\..\..\..\..\..\Data\Template_Pdf_2.pdf");

            //Get a collection of attachments on the PDF document
            PdfAttachmentCollection collection = pdf.Attachments;

            //Get the first attachment.
            PdfAttachment attachment = collection[0];

            //Get the information of the first attachment.
            StringBuilder content = new StringBuilder();

            content.AppendLine("Filename: " + attachment.FileName);
            content.AppendLine("Description: " + attachment.Description);
            content.AppendLine("Creation Date: " + attachment.CreationDate);
            content.AppendLine("Modification Date: " + attachment.ModificationDate);


            String result = "GetPdfAttachmentInfo_out.txt";

            //Save to file.
            File.WriteAllText(result, content.ToString());

            //Launch the file.
            DocumentViewer(result);
        }
Пример #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            //Create a new PDF document.
            PdfDocument pdf = new PdfDocument();

            //Load the file from disk.
            pdf.LoadFromFile(@"..\..\..\..\..\..\Data\Template_Pdf_2.pdf");

            //Get a collection of attachments on the PDF document.
            PdfAttachmentCollection collection = pdf.Attachments;

            //Get the second attachment in PDF file.
            PdfAttachment attachment = collection[1];

            //Save the second attachment to the file.
            File.WriteAllBytes(attachment.FileName, attachment.Data);
        }
Пример #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            //Create a new PDF document.
            PdfDocument pdf = new PdfDocument();

            //Load the file from disk.
            pdf.LoadFromFile(@"..\..\..\..\..\..\Data\Template_Pdf_2.pdf");

            //Get a collection of attachments on the PDF document.
            PdfAttachmentCollection collection = pdf.Attachments;

            //Save all the attachments to the files.
            for (int i = 0; i < collection.Count; i++)
            {
                File.WriteAllBytes(collection[i].FileName, collection[i].Data);
            }
        }
Пример #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            //pdf file
            string input = "..\\..\\..\\..\\..\\..\\..\\Data\\Sample7.pdf";

            //open pdf document
            PdfDocument doc = new PdfDocument(input);

            //get all attachments
            PdfAttachmentCollection attachments = doc.Attachments;

            //delete all attachments
            attachments.Clear();

            string output = "DeleteAllAttachments.pdf";

            //save pdf document
            doc.SaveToFile(output);

            //Launching the Pdf file
            PDFDocumentViewer(output);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            string input = @"..\..\..\..\..\..\Data\DeleteAllAttachments.pdf";

            //Open pdf document
            PdfDocument doc = new PdfDocument();

            doc.LoadFromFile(input);

            //Get all attachments
            PdfAttachmentCollection attachments = doc.Attachments;

            //Delete all attachments
            attachments.Clear();

            string output = "DeleteAllAttachments.pdf";

            //Save pdf document
            doc.SaveToFile(output);

            //Launch the Pdf file
            PDFDocumentViewer(output);
        }