Exemplo n.º 1
0
        /// <summary>
        /// Writes document information like author and subject to the PDF document.
        /// </summary>
        public void WriteDocumentInformation()
        {
            if (!_document.IsNull("Info"))
            {
                DocumentInfo           docInfo = _document.Info;
                PdfDocumentInformation pdfInfo = _pdfDocument.Info;

                if (!docInfo.IsNull("Author"))
                {
                    pdfInfo.Author = docInfo.Author;
                }

                if (!docInfo.IsNull("Keywords"))
                {
                    pdfInfo.Keywords = docInfo.Keywords;
                }

                if (!docInfo.IsNull("Subject"))
                {
                    pdfInfo.Subject = docInfo.Subject;
                }

                if (!docInfo.IsNull("Title"))
                {
                    pdfInfo.Title = docInfo.Title;
                }
            }
        }
        /// <summary>
        /// Writes document information like author and subject to the PDF document.
        /// </summary>
        public void WriteDocumentInformation() //!!!modTHHO 15.08.2006
        {
            if (!this.document.IsNull("Info"))
            {
                DocumentInfo           docInfo = this.document.Info;
                PdfDocumentInformation pdfInfo = this.pdfDocument.Info;

                if (!docInfo.IsNull("Author"))
                {
                    pdfInfo.Author = docInfo.Author;
                }

                if (!docInfo.IsNull("Keywords"))
                {
                    pdfInfo.Keywords = docInfo.Keywords;
                }

                if (!docInfo.IsNull("Subject"))
                {
                    pdfInfo.Subject = docInfo.Subject;
                }

                if (!docInfo.IsNull("Title"))
                {
                    pdfInfo.Title = docInfo.Title;
                }
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            String      input = "..\\..\\..\\..\\..\\..\\Data\\PDFTemplate-Az.pdf";
            PdfDocument doc   = new PdfDocument();

            // Read a pdf file
            doc.LoadFromFile(input);
            // Get document information
            PdfDocumentInformation docInfo = doc.DocumentInformation;

            // Create a StringBuilder object to put the details
            StringBuilder builder = new StringBuilder();

            builder.AppendLine("Author:" + docInfo.Author);
            builder.AppendLine("Creation Date: " + docInfo.CreationDate);
            builder.AppendLine("Keywords: " + docInfo.Keywords);
            builder.AppendLine("Modify Date: " + docInfo.ModificationDate);
            builder.AppendLine("Subject: " + docInfo.Subject);
            builder.AppendLine("Title: " + docInfo.Title);

            String result = "GetDocumentProperties_out.txt";

            File.WriteAllText(result, builder.ToString());
            //Launch the result file
            DocumentViewer(result);
        }
 private static DateTime GetSafeDocumentYear(PdfDocumentInformation doc_info)
 {
     try
     {
         return(doc_info.CreationDate);
     }
     catch (Exception)
     {
         return(DateTime.MinValue);
     }
 }
Exemplo n.º 5
0
        /**************************************************************************/

        public Dictionary <string, string> GetMetadata()
        {
            Dictionary <string, string> dicMetadata = new Dictionary <string, string> (32);

            if (Pdf != null)
            {
                PdfDocumentInformation pdfInfo = Pdf.Info;
                dicMetadata.Add("title", pdfInfo.Title);
            }

            return(dicMetadata);
        }
Exemplo n.º 6
0
    static void Main(string[] args)
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        PdfDocument document = PdfDocument.Load("Reading.pdf");

        // Get document information.
        PdfDocumentInformation info = document.Info;

        // Modify document information.
        info.Title    = "Document Information Example";
        info.Author   = "GemBox.Pdf";
        info.Subject  = "Introduction to GemBox.Pdf";
        info.Keywords = "GemBox, Pdf, Examples";

        document.SaveOptions.CloseOutput = true;
        document.Save("Document Information.pdf");
    }
Exemplo n.º 7
0
        private void VerifySC_Click(object sender, EventArgs e)
        {
            err = m_SecuBSP.EnumerateDevice();
            pdf = new PdfDocument();

            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Filter = "PDF document (*.pdf)|*.pdf";
            DialogResult result = dialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                try
                {
                    string pdfFile = dialog.FileName;

                    List <PdfSignature> signatures = new List <PdfSignature>();
                    //Open a pdf document and get its all signatures
                    using (PdfDocument pdf = new PdfDocument())
                    {
                        pdf.LoadFromFile(pdfFile);
                        PdfFormWidget form = pdf.Form as PdfFormWidget;
                        for (int i = 0; i < form.FieldsWidget.Count; i++)
                        {
                            PdfSignatureFieldWidget field = form.FieldsWidget[i] as PdfSignatureFieldWidget;
                            if (field != null && field.Signature != null)
                            {
                                PdfSignature signature = field.Signature;
                                signatures.Add(signature);
                            }
                        }

                        //Get the first signature
                        PdfSignature signatureOne = signatures[0];

                        //Detect if the pdf document was modified
                        bool modified = signatureOne.VerifyDocModified();

                        //FIND
                        err = m_SecuBSP.EnumerateDevice();
                        m_SecuBSP.DeviceID = (Int16)DeviceID.AUTO;

                        //OPEN
                        err = m_SecuBSP.OpenDevice();
                        if (err == BSPError.ERROR_NONE)
                        {
                            if (!modified)
                            {
                                PdfDocumentInformation docInfo = pdf.DocumentInformation;
                                err = m_SecuBSP.Capture(FIRPurpose.VERIFY);
                                if (err == BSPError.ERROR_NONE)
                                {
                                    err = m_SecuBSP.VerifyMatch(m_SecuBSP.FIRTextData, docInfo.Subject);

                                    if (err == BSPError.ERROR_NONE)
                                    {
                                        if (m_SecuBSP.IsMatched)
                                        {
                                            AutoClosingMessageBox.Show("The Document is Authentic", "", 1500);
                                        }
                                        else
                                        {
                                            AutoClosingMessageBox.Show("The Document is not Authentic", "", 1500);
                                        }
                                    }
                                }
                            }
                            else
                            {
                                AutoClosingMessageBox.Show("The Document is not Authentic", "", 1500);
                            }
                        }
                        else
                        {
                            AutoClosingMessageBox.Show("No Scanner Detected", "Error!", 1000);
                        }
                    }
                }
                catch (Exception exe)
                {
                    MessageBox.Show("Document is not Authentic", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemplo n.º 8
0
        private void VerifyDB_Click(object sender, EventArgs e)
        {
            if (matricTextBox.Text.Equals("") || matricTextBox.Text.Equals("Input Matric"))
            {
                MessageBox.Show("Please Input a Matric Number", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                MySqlCommand command = new MySqlCommand("SELECT * FROM `data` WHERE `matric`=@user", db.getConnection());
                command.Parameters.Add("@user", MySqlDbType.VarChar).Value = matricTextBox.Text;
                db.openConnection();
                MySqlDataReader rdr = command.ExecuteReader();
                f_data = "";
                while (rdr.Read())
                {
                    f_data = rdr.GetString(4);
                }
                rdr.Close();
                if (f_data.Equals(""))
                {
                    MessageBox.Show("Wrong Matric Number", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    pdf = new PdfDocument();

                    OpenFileDialog dialog = new OpenFileDialog();
                    dialog.Filter = "PDF document (*.pdf)|*.pdf";
                    DialogResult result = dialog.ShowDialog();

                    if (result == DialogResult.OK)
                    {
                        try
                        {
                            string pdfFile = dialog.FileName;

                            List <PdfSignature> signatures = new List <PdfSignature>();
                            //Open a pdf document and get its all signatures
                            using (PdfDocument pdf = new PdfDocument())
                            {
                                pdf.LoadFromFile(pdfFile);
                                PdfFormWidget form = pdf.Form as PdfFormWidget;
                                for (int i = 0; i < form.FieldsWidget.Count; i++)
                                {
                                    PdfSignatureFieldWidget field = form.FieldsWidget[i] as PdfSignatureFieldWidget;
                                    if (field != null && field.Signature != null)
                                    {
                                        PdfSignature signature = field.Signature;
                                        signatures.Add(signature);
                                    }
                                }

                                //Get the first signature
                                PdfSignature signatureOne = signatures[0];

                                //Detect if the pdf document was modified
                                bool modified = signatureOne.VerifyDocModified();

                                if (!modified)
                                {
                                    PdfDocumentInformation docInfo = pdf.DocumentInformation;
                                    err = m_SecuBSP.Capture(FIRPurpose.VERIFY);

                                    err = m_SecuBSP.VerifyMatch(f_data, docInfo.Subject);

                                    if (err == BSPError.ERROR_NONE)
                                    {
                                        if (m_SecuBSP.IsMatched)
                                        {
                                            AutoClosingMessageBox.Show("The Document is Authentic", "", 1500);
                                        }
                                        else
                                        {
                                            AutoClosingMessageBox.Show("The Document is not Authentic", "", 1500);
                                        }
                                    }
                                }
                                else
                                {
                                    AutoClosingMessageBox.Show("The Document is not Authentic", "", 1500);
                                }
                            }
                        }
                        catch (Exception exe)
                        {
                            MessageBox.Show("Document is not Authentic", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
        }
Exemplo n.º 9
0
 private static byte[] CreateRawXmpMetadata(PdfDocumentInformation info, (string, string) conformance)