コード例 #1
0
        public void ProducePDFDocumentWithImage()
        {
            String fileName        = String.Format(@"C:\Users\Akash Paul\Dropbox\XMLFile1.pdfx");
            String DestinationPath = String.Format(@"C:\Users\Akash Paul\Downloads");
            var    outputPath      = String.Format(@"{0}\{1}.pdf", DestinationPath, Guid.NewGuid().ToString());
            var    stream          = new FileStream(outputPath, FileMode.CreateNew, FileAccess.ReadWrite);

            using (Scryber.Components.PDFDocument document = Scryber.Components.PDFDocument.ParseDocument(fileName))
            {
                document.ProcessDocument(stream);
                document.Info.Author       = System.Environment.UserName;
                document.Info.CreationDate = DateTime.Now;
                stream.Flush();
                stream.Close();
            }
        }
コード例 #2
0
        public void CreateDynamicPdfFromDatabase()
        {
            String fileName         = String.Format(@"C:\Users\Akash Paul\Dropbox\XMLFile1.pdfx");
            String DestinationPath  = String.Format(@"C:\Users\Akash Paul\Downloads");
            var    dto              = new TestDto();
            var    connectionString = String.Format("Server=localhost;Database=test;username=root;password=;Port=3306");
            var    connect          = new MySql.Data.MySqlClient.MySqlConnection(connectionString);

            connect.Open();
            var command = connect.CreateCommand();

            command.CommandText = String.Format("select * from test.t_test_data");
            command.Prepare();
            var reader = command.ExecuteReader();
            var table  = new DataTable();

            table.Load(reader);
            foreach (DataRow row in table.Rows)
            {
                dto.getFirstName       = row.ItemArray[0].ToString();
                dto.getSecondName      = row.ItemArray[1].ToString();
                dto.getFirstYearGrade  = int.Parse(row.ItemArray[2].ToString());
                dto.getSecondYearGrade = int.Parse(row.ItemArray[3].ToString());
                dto.getUsername        = row.ItemArray[4].ToString();
                dto.getEmail           = row.ItemArray[5].ToString();
                dto.getSUN             = int.Parse(row.ItemArray[6].ToString());

                var outputPath = String.Format(@"{0}\{1}.pdf", DestinationPath, Guid.NewGuid().ToString());
                var stream     = new FileStream(outputPath, FileMode.CreateNew, FileAccess.ReadWrite);

                using (Scryber.Components.PDFDocument document = Scryber.Components.PDFDocument.ParseDocument(fileName))
                {
                    document.Items["Firstname"]       = dto.getFirstName;
                    document.Items["Secondname"]      = dto.getSecondYearGrade;
                    document.Items["FirstYearGrade"]  = dto.getFirstYearGrade;
                    document.Items["SecondYearGrade"] = dto.getSecondYearGrade;
                    document.Items["Username"]        = dto.getUsername;
                    document.Items["Email"]           = dto.getEmail;
                    document.Items["SUN"]             = dto.getSUN;
                    document.ProcessDocument(stream, true);
                    stream.Flush();
                    stream.Close();
                }
                connect.Close();
            }
        }
コード例 #3
0
        public void OpenPDFPreview()
        {
            String fileName        = String.Format(@"C:\Users\Akash Paul\Dropbox\XMLFile1.pdfx");
            String DestinationPath = String.Format(@"C:\Users\Akash Paul\Downloads");
            var    outputPath      = String.Format(@"{0}\{1}.pdf", DestinationPath, Guid.NewGuid().ToString());
            var    stream          = new FileStream(outputPath, FileMode.CreateNew, FileAccess.ReadWrite);

            using (Scryber.Components.PDFDocument document = Scryber.Components.PDFDocument.ParseDocument(fileName))
            {
                document.ProcessDocument(stream);
                document.Info.Author       = System.Environment.UserName;
                document.Info.CreationDate = DateTime.Now;
                System.Diagnostics.Process.Start("explorer.exe", outputPath);
                Assert.IsTrue(true, "Preview Successful");
                stream.Flush();
                stream.Close();
            }
        }