示例#1
0
        public static void CombinePDF()
        {
            MergeDocument document = new MergeDocument(Util.GetPath("Resources/PDFs/DocumentA.pdf"));

            document.Append(Util.GetPath("Resources/PDFs/DocumentB.pdf"));
            document.Append(Util.GetPath("Resources/PDFs/DocumentC.pdf"), 1, 2);
            document.Draw(Util.GetPath("Output/CombinePDFs.pdf"));
        }
        public static void MergeOption()
        {
            MergeDocument document = new MergeDocument(Util.GetPath("Resources/PDFs/DocumentA.pdf"));
            MergeOptions  options  = MergeOptions.Append;

            options.Outlines = false;
            document.Append(Util.GetPath("Resources/PDFs/DocumentB.pdf"), options);
            document.Append(Util.GetPath("Resources/PDFs/DocumentC.pdf"));
            document.Draw(Util.GetPath("Output/MergeOption.pdf"));
        }
        // Combines PDF documents.
        // This code uses the DynamicPDF Merger for .NET product.
        // Use the ceTe.DynamicPDF.Merger namespace for the MergeDocument class.
        private static void CombinePDFs()
        {
            //Create MergeDocument object and append PDFs
            MergeDocument document = new MergeDocument(GetResourcePath("doc-a.pdf"));

            document.Append(GetResourcePath("doc-b.pdf"));
            document.Append(GetResourcePath("doc-c.pdf"), 1, 2);

            //Save merged document
            document.Draw("output-combined.pdf");
        }
        public static void Run(string outputPdfPath)
        {
            // Create a merge document and set it's properties
            MergeDocument document = MergeDocument.Merge(Util.GetResourcePath("PDFs/DocumentA.pdf"), Util.GetResourcePath("PDFs/DocumentB.pdf"));

            // Append additional PDF
            document.Append(Util.GetResourcePath("PDFs/DocumentC.pdf"));

            // Append 3 pages from an aditional PDF
            document.Append(Util.GetResourcePath("PDFs/DocumentD.pdf"), 1, 3);

            // Outputs the merged document to the current web page
            document.Draw(outputPdfPath);
        }
示例#5
0
        private static string BarcodeJobTicketPdf(string FullFileName, string JobName, string StockCode)
        {
            string pdfFullName = FullFileName.Replace(" .pdf", ".pdf");

            ceTe.DynamicPDF.Document.AddLicense("DPS70NEDJGMGEGWKOnLLQb4SjhbTTJhXnkpf9bj8ZzxFH+FFxctoPX+HThGxkpidUCHJ5b88fg4oUJSHiRBggzHdghUgkkuIvoag");
            var doc  = new ceTe.DynamicPDF.Document();
            var page = new ceTe.DynamicPDF.Page();

            MergeDocument MyDocJobTicket = new MergeDocument();
            PdfDocument   pdfTemplate    = new PdfDocument(FullFileName);
            var           qrCode         = new ceTe.DynamicPDF.PageElements.Image(Encode.QR(JobName), 300, 50);

            qrCode.Height = 90;
            qrCode.Width  = 90;

            MyDocJobTicket.Append(pdfTemplate);
            MyDocJobTicket.Pages[0].Dimensions.SetMargins(0);

            MyDocJobTicket.Pages[0].Elements.Add(qrCode);
            qrCode        = new ceTe.DynamicPDF.PageElements.Image(Encode.QR(StockCode), 50, 405);
            qrCode.Height = 38;
            qrCode.Width  = 38;
            MyDocJobTicket.Pages[0].Elements.Add(qrCode);
            MyDocJobTicket.FormFlattening = FormFlatteningOptions.Default;
            MyDocJobTicket.Draw(pdfFullName);
            MyDocJobTicket = null;
            FileInfo fi = new FileInfo(FullFileName);

            fi.Delete();
            return(pdfFullName);
        }
示例#6
0
        protected Arquivo inserirArquivosNaLista(string id, string opcao)
        {
            List <Arquivo> list_temp = new List <Arquivo>();

            list_temp = (List <Arquivo>)Session[opcao];
            Arquivo arq_temp = new Arquivo();

            if (list_temp != null)
            {
                string nomeArquivo = montarFormatoGD(id, opcao + ext);
                int    count       = list_temp.Count;
                if (count >= 2)
                {
                    MergeDocument document = MergeDocument.Merge(diretorio + list_temp.ElementAt(0).nome_Arquivo, diretorio + list_temp.ElementAt(1).nome_Arquivo);
                    if (count > 2)
                    {
                        for (int i = 2; i < count; i++)
                        {
                            document.Append(diretorio + list_temp.ElementAt(i).nome_Arquivo);
                        }
                    }
                    document.Draw(nomeArquivo);
                    System.IO.File.Delete(diretorio + nomeArquivo);
                    System.IO.File.Move(nomeArquivo, diretorio + nomeArquivo);
                }
                arq_temp.nome_Arquivo = nomeArquivo;
                arq_temp.tipo_Arquivo = opcao;
            }
            return(arq_temp);
        }
示例#7
0
        public void Merge(string sourceDirectory)
        {
            var coverPages = Directory.EnumerateFiles(sourceDirectory, coverPageIdentifier);

            foreach (string coverPage in coverPages)
            {
                string fileName   = coverPage.Substring(sourceDirectory.Length + 1);
                string filePrefix = fileName.Substring(0, fileName.IndexOf("_") + 1);

                var bodyPage = Directory.EnumerateFiles(sourceDirectory, filePrefix + bodyPageIdentifier).First();

                string      path      = sourceDirectory + @"\" + fileName;
                PdfDocument pdf       = new PdfDocument(path);
                var         pageCount = pdf.Pages.Count;

                for (int i = 1; i <= pageCount; i++)
                {
                    MergeDocument document = new MergeDocument(path, i, 1);
                    document.Append(bodyPage);

                    string planID = filePrefix + (i.ToString().PadLeft(5, '0')) + ".pdf";

                    string archivePath = sourceDirectory + @"\" + planID;
                    document.Draw(archivePath);
                }
            }
        }
        // A simple merge and appending two other PDFs with options.
        // Use the ceTe.DynamicPDF.Merger namespace for the MergeDocument and MergeOptions classes.
        static void MergeWithOptions()
        {
            //Create MergeDocument with MergeOptions
            var document = new MergeDocument(GetResourcePath("doc-a.pdf"), MergeOptions.All);

            var optionsNoOutlines = MergeOptions.Append;

            optionsNoOutlines.Outlines = false;
            document.Append(GetResourcePath("doc-with-outline.pdf"), optionsNoOutlines);

            var optionsNoAnnotations = MergeOptions.Append;

            optionsNoAnnotations.PageAnnotations = false;
            document.Append(GetResourcePath("doc-with-note.pdf"), optionsNoAnnotations);

            document.Draw("output-with-options.pdf");
        }
示例#9
0
        public static void CombinePDFWithOptions()
        {
            MergeOptions options = MergeOptions.All;

            options.DocumentProperties = false;
            MergeDocument document = new MergeDocument(Util.GetPath("Resources/PDFs/DocumentA.pdf"), options);

            document.Append(Util.GetPath("Resources/PDFs/DocumentB.pdf"));
            document.Draw(Util.GetPath("Output/CombinePDFWithOptions.pdf"));
        }
        // A simple merge and then appending another PDF.
        // Use the ceTe.DynamicPDF.Merger namespace for the MergeDocument class.
        static void MergeAndAppendPdfs()
        {
            //Create MergeDocument object with source PDFs to Merge
            MergeDocument document = MergeDocument.Merge(GetResourcePath("doc-a.pdf"), GetResourcePath("doc-b.pdf"));

            //Append a PDF document
            document.Append(GetResourcePath("doc-c.pdf"), 1, 2);

            //Save the merged PDF
            document.Draw("output-with-append.pdf");
        }
示例#11
0
        /// <summary>
        /// Método usado para deletar uma página especifica do documento.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Web.UI.ImageClickEventArgs"/> instance containing the event data.</param>
        protected void ImageButtonDeletePagina_Click(object sender, ImageClickEventArgs e)
        {
            string nomeArquivo = LabelArquivo.Text;

            LabelErro.Text         = "";
            ImageAttention.Visible = false;
            //verificar se o nome nao esta nulo
            if (nomeArquivo.Equals(""))
            {
                ScriptManager.RegisterStartupScript(Page, GetType(), Guid.NewGuid().ToString(), "window.alert('Não existe arquivo');", true);
            }
            else
            {
                int         page        = Convert.ToInt16(TextBoxDeletePagina.Text);
                PdfDocument originalPDF = new PdfDocument(pathDir + nomeArquivo);  //specify original file
                int         totalpages  = originalPDF.Pages.Count;

                if ((page > totalpages) || (page <= 0))
                {
                    ScriptManager.RegisterStartupScript(Page, GetType(), Guid.NewGuid().ToString(), "window.alert('Página fora do limite!');", true);
                }
                else if (totalpages == 1)
                {
                    System.IO.File.Delete(pathDir + nomeArquivo);
                    TableArquivo.Visible = false;
                    string abaAtiva = retornaAbaAtiva();
                    Session.Add("postou_" + abaAtiva, "nao");
                    ScriptManager.RegisterStartupScript(Page, GetType(), Guid.NewGuid().ToString(), "window.alert('Página deletada com sucesso!');", true);
                }
                else if (totalpages != 1)
                {
                    if (page == totalpages)
                    {
                        MergeDocument smallerPDF = new MergeDocument(originalPDF, 1, page - 1);
                        smallerPDF.Draw(nomeArquivo);
                        System.IO.File.Delete(pathDir + nomeArquivo);
                        System.IO.File.Move(nomeArquivo, pathDir + nomeArquivo);
                    }
                    else
                    {
                        MergeDocument smallerPDF  = new MergeDocument(originalPDF, 1, page - 1);
                        int           pagesAppend = totalpages - page;
                        smallerPDF.Append(originalPDF, page + 1, pagesAppend);  //append pages deleted plus one until page count;
                        smallerPDF.Draw(nomeArquivo);
                        System.IO.File.Delete(pathDir + nomeArquivo);
                        System.IO.File.Move(nomeArquivo, pathDir + nomeArquivo);
                    }
                    ScriptManager.RegisterStartupScript(Page, GetType(), Guid.NewGuid().ToString(), "window.alert('Página deletada com sucesso!');", true);
                }
            }
        }
        // Combines PDF documents with options.
        // This code uses the DynamicPDF Merger for .NET product.
        // Use the ceTe.DynamicPDF.Merger namespace for the MergeDocument class.
        private static void CombinePDFsWithOptions()
        {
            //Create MergeOptions with different settings
            MergeOptions options = MergeOptions.Append;

            options.Outlines = false;

            //Create MergeDocument object
            MergeDocument document = new MergeDocument();

            // Append a document with options
            document.Append(GetResourcePath("doc-with-outline.pdf"), options);

            //Save document
            document.Draw("output-with-options.pdf");
        }
示例#13
0
        protected void ImageButtonDeletePagina_Click(object sender, ImageClickEventArgs e)
        {
            string nomeArquivo = LabelArquivo.Text;

            LabelErro.Text         = "";
            ImageAttention.Visible = false;
            //verificar se o nome nao esta nulo
            if (nomeArquivo.Equals(""))
            {
                LabelErro.Text         = "Não existe arquivo";
                ImageAttention.Visible = true;
            }
            else
            {
                int         page        = Convert.ToInt16(TextBoxDeletePagina.Text);
                PdfDocument originalPDF = new PdfDocument(pathDir + nomeArquivo);  //specify original file
                int         totalpages  = originalPDF.Pages.Count;

                if ((page > totalpages) || (page <= 0))
                {
                    LabelErro.Text         = "Página fora do limite";
                    ImageAttention.Visible = true;
                }
                else if (page == totalpages)
                {
                    MergeDocument smallerPDF = new MergeDocument(originalPDF, 1, page - 1);
                    smallerPDF.Draw(nomeArquivo);
                    System.IO.File.Delete(pathDir + nomeArquivo);
                    System.IO.File.Move(nomeArquivo, pathDir + nomeArquivo);
                }
                else
                {
                    MergeDocument smallerPDF  = new MergeDocument(originalPDF, 1, page - 1);
                    int           pagesAppend = totalpages - page;
                    smallerPDF.Append(originalPDF, page + 1, pagesAppend);  //append pages deleted plus one until page count;
                    smallerPDF.Draw(nomeArquivo);
                    System.IO.File.Delete(pathDir + nomeArquivo);
                    System.IO.File.Move(nomeArquivo, pathDir + nomeArquivo);
                }
            }
        }
示例#14
0
        protected Arquivo inserirArquivosNaLista(string id, string opcao)
        {
            List <Arquivo> list_temp = new List <Arquivo>();

            list_temp = (List <Arquivo>)Session[opcao];
            Arquivo arq_temp = new Arquivo();

            if (list_temp != null)
            {
                string nomeArquivo = list_temp.ElementAt(0).nome_Arquivo;
                int    count       = list_temp.Count;

                if (count >= 2)
                {
                    MergeDocument document = MergeDocument.Merge(diretorio + list_temp.ElementAt(0).nome_Arquivo, diretorio + list_temp.ElementAt(1).nome_Arquivo);
                    if (count > 2)
                    {
                        for (int i = 2; i < count; i++)
                        {
                            document.Append(diretorio + list_temp.ElementAt(i).nome_Arquivo);
                        }
                    }
                    document.Draw(nomeArquivo);

                    //Deletando os arquivos temporarios usados no merge
                    for (int i = 0; i < count; i++)
                    {
                        if (!nomeArquivo.Equals((String)list_temp.ElementAt(i).nome_Arquivo))
                        {
                            System.IO.File.Delete(diretorio + list_temp.ElementAt(i).nome_Arquivo);
                        }
                    }
                    System.IO.File.Move(nomeArquivo, diretorio + nomeArquivo);
                }
                arq_temp.nome_Arquivo = nomeArquivo;
                arq_temp.tipo_Arquivo = opcao;
            }
            return(arq_temp);
        }
示例#15
0
        }    /*   end of main  */

        private static void createAccountingPDF(ReportRunner rr, Ward ward, DocHelper dh, string[] files, string outputFolder, string StartDate, string EndDate, OracleConnection connection)
        {
            decimal wardDocCount = 0;

            WardDocument[] wardDocArray;
            string[]       types = null;
            types = new string[] { "pdf" };
            string pdfTargetFolder = null;

            wardDocCount    = dh.getBankStatementCount(ward.getWardNumber(), connection, EndDate);                      // count all of the documents we need, doctype "MELLON" and "BANK"
            wardDocArray    = new WardDocument[(int)wardDocCount];
            pdfTargetFolder = System.IO.Path.Combine(outputFolder, ward.getWardName() + "_" + ward.getFileNumber());


            if (!System.IO.Directory.Exists(pdfTargetFolder))                                                           // create output directory as needed for each ward
            {
                System.IO.Directory.CreateDirectory(pdfTargetFolder);
            }

            string        document1 = System.IO.Path.Combine(pdfTargetFolder, ward.getWardNumber() + "_temporary.pdf"); // the document created by the RDL component
            string        document2;
            MergeDocument document;


            if (wardDocCount > 0)
            {
                dh.getWardBankDocs(wardDocArray, connection, ward.getWardNumber(), EndDate);                            // populate wardDocArray with the documents
                Console.WriteLine("Ward has {0} Bank document(s) to copy", wardDocCount);

                // rc.returnCode = returnCode;  // MBG 08/15/15
                rr.DoRender(pdfTargetFolder, files, types, ward.getWardNumber().ToString(), StartDate, EndDate);                                   //   create the AnnualAccounting PDF document
                document = new MergeDocument(document1);
                document = new MergeDocument(System.IO.Path.Combine(pdfTargetFolder, ward.getWardNumber() + "_temporary.pdf"));

                //   B E G I N       M E R G E   O F   P D F    D O C U M E N T S

                Console.WriteLine("output folder is: {0}", pdfTargetFolder);
                // loop over any additional documents here and merge with the AnnualAccouting pdf

                foreach (WardDocument w in wardDocArray)
                {
                    if (File.Exists(System.IO.Path.Combine(w.getStoragePath(), w.getDocPath())))
                    {
                        document.Append(System.IO.Path.Combine(w.getStoragePath(), w.getDocPath()));
                    }
                    else
                    {
                        System.IO.File.AppendAllText(@"P:\Annuals\AnnualAccountingLog.txt", "Could not find ward document: " + w.getStoragePath() + "/" + w.getDocPath() + " - " + DateTime.Now + "\r\n");
                    }
                }


                ceTe.DynamicPDF.PageList pl = new PageList();                 // find out how many pages the resulting PDF document has so we can add the count to the final filename
                pl = document.Pages;
                Console.WriteLine("File has {0} Pages", pl.Count);
                document2 = System.IO.Path.Combine(pdfTargetFolder, ward.getWardNumber() + "_AnnualAccounting_" + pl.Count.ToString() + ".pdf"); // name of the final output document
                document.Draw(document2);
                File.Delete(document1);                                                                                                          // delete the 9999_temporary.pdf
                document2 = null;
            }
            else
            {
                Console.WriteLine("LOG: => No Bank Documents found for ward {0}", ward.getWardNumber());
                System.IO.File.AppendAllText(@"C:\Annuals\AnnualAccountingLog.txt", "Ward: " + ward.getWardNumber() + " has no Bank Statements to process " + DateTime.Now + "\r\n");

                // rc.returnCode = returnCode;  // MBG 08/15/15
                rr.DoRender(pdfTargetFolder, files, types, ward.getWardNumber().ToString(), StartDate, EndDate);
                ceTe.DynamicPDF.PageList pl = new PageList();
                document  = new MergeDocument(document1);
                pl        = document.Pages;
                document2 = System.IO.Path.Combine(pdfTargetFolder, ward.getWardNumber() + "_AnnualAccounting_" + pl.Count.ToString() + ".pdf"); // name of the final output document
                document.Draw(document2);
                File.Delete(document1);                                                                                                          // delete the 9999_temporary.pdf
                document2 = null;

                connection.Close();
            }
            dh.updateAnnualAccounting(ward.getWardNumber(), connection);
            connection.Close();
        }       /* end of createAccountingPDF  */
示例#16
0
        private static void createCJISPDF(Ward ward, DocHelper dh, string outputFolder, OracleConnection connection, string logFile)
        {
            decimal guardianLetterCount = 0;
            decimal cjisMemoCount       = 0;

            WardDocument[] wardDocArray;
            string         pdfTargetFolder = null;

            PdfDocument   profilePDF = null;
            MergeDocument document   = new MergeDocument();

            string cjisProfileURL = ConfigurationManager.AppSettings["CJIS_ProfileURL"];

            guardianLetterCount = dh.getguardianLetterCount(ward.getWardNumber(), connection); // count all of the documents we need, doctype "GRDLET"

            wardDocArray = new WardDocument[(int)guardianLetterCount];                         // create an array large enough to contain all of the necessary documents

            pdfTargetFolder = System.IO.Path.Combine(outputFolder, ward.getWardName() + "_" + ward.getWardNumber());

            if (!System.IO.Directory.Exists(pdfTargetFolder))                                                           // create output directory as needed for each ward
            {
                System.IO.Directory.CreateDirectory(pdfTargetFolder);
            }


            string profileDocumentPath = System.IO.Path.Combine(pdfTargetFolder, ward.getWardNumber() + "_Profile.pdf");        // the document created by Jasper

            /*    C R E A T E    T H E  3  B A S E  C J I S    R E P O R T S */
            WebClient client = new WebClient();
            string    url    = cjisProfileURL + ward.getWardNumber();

            client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
            client.DownloadFile(url, profileDocumentPath);


            profilePDF = new PdfDocument(profileDocumentPath);
            document   = new MergeDocument(profilePDF);

            if (wardDocArray.Length > 0 && ward.getStatus() != "X")                         // if we have a letter of Guardianship
            {
                dh.getLetterOfGuardianship(wardDocArray, connection, ward.getWardNumber()); // populate wardDocArray with the documents
                Console.WriteLine("Ward has {0} Letter(s) of Guardianship to copy", guardianLetterCount);

                //   B E G I N       M E R G E   O F   P D F    D O C U M E N T S

                Console.WriteLine("output folder is: {0}", pdfTargetFolder);
                // loop over any additional documents here and merge with the Ward Profile pdf

                try
                {
                    foreach (WardDocument w in wardDocArray)
                    {
                        if (File.Exists(System.IO.Path.Combine(w.getStoragePath(), w.getDocPath())))
                        {
                            document.Append(System.IO.Path.Combine(w.getStoragePath(), w.getDocPath()));
                        }
                        else
                        {
                            System.IO.File.AppendAllText(@logFile, "Could not find ward document: " + w.getStoragePath() + "\\" + w.getDocPath() + " - " + DateTime.Now + "\r\n");
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("Letters of Guardianship should exist but could not be found for ward {0}", ward.getWardNumber());
                }
            }
            else
            {
                Console.WriteLine("LOG: => No Letters of Guardianship found for ward {0}", ward.getWardNumber());
                System.IO.File.AppendAllText(@logFile, "Ward: " + ward.getWardNumber() + " Missing Letter of Gurardianship or CJIS Memorandum " + DateTime.Now + "\r\n");
            }



            document.Draw(System.IO.Path.Combine(pdfTargetFolder, ward.getWardNumber() + "_CJISMemo_" + document.Pages.Count.ToString() + ".pdf")); // name of the final output document
            File.Delete(profileDocumentPath);                                                                                                       // delete the profile.pdf
            dh.updateCJISStatus(ward.getWardNumber(), guardianLetterCount, cjisMemoCount, connection, ward.getStatus());
            connection.Close();
        }
示例#17
0
        }       /* end of createAccountingPDF  */

        private static void createAnnualPlanPDF(Ward ward, DocHelper dh, string reportURL, string outputFolder, string StartDate, string EndDate, OracleConnection connection, string logFile)
        {
            decimal physicianDocCount = 0;

            WardDocument[] wardDocArray;
            string[]       types = null;
            types = new string[] { "pdf" };
            string pdfTargetFolder = null;

            Console.WriteLine("Processing Annual Plan");
            physicianDocCount = dh.getPhysicianDocumentCount(ward.getWardNumber(), connection);          // count all of the documents we need, doctype "MELLON" and "BANK"
            wardDocArray      = new WardDocument[(int)physicianDocCount];

            pdfTargetFolder = System.IO.Path.Combine(outputFolder, ward.getWardName() + "_" + ward.getFileNumber());

            if (!System.IO.Directory.Exists(pdfTargetFolder))                                                           // create output directory as needed for each ward
            {
                System.IO.Directory.CreateDirectory(pdfTargetFolder);
            }

            string        document1 = System.IO.Path.Combine(pdfTargetFolder, ward.getWardNumber() + "_deleteME.pdf"); // the document created by the RDL component
            string        document2;
            MergeDocument document;

            /*    C R E A T E    T H E   B A S E  A N N U A L  P L A N   R E P O R T  */
            WebClient client = new WebClient();
            string    url    = reportURL + ward.getWardNumber();;

            client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
            client.DownloadFile(url, document1);

            if (physicianDocCount > 0)
            {
                dh.getWardPhysicianReport(wardDocArray, connection, ward.getWardNumber());                            // populate wardDocArray with the documents
                Console.WriteLine("Ward has {0} Physician Report(s) to copy", physicianDocCount);
                dh.updatePlanStatus(ward.getWardNumber(), connection);
                connection.Close();
                //   create the AnnualAccounting PDF document
                document = new MergeDocument(document1);



                //   B E G I N       M E R G E   O F   P D F    D O C U M E N T S

                Console.WriteLine("output folder is: {0}", pdfTargetFolder);
                // loop over any additional documents here and merge with the AnnualAccouting pdf

                foreach (WardDocument w in wardDocArray)
                {
                    if (File.Exists(System.IO.Path.Combine(w.getStoragePath(), w.getDocPath())))
                    {
                        document.Append(System.IO.Path.Combine(w.getStoragePath(), w.getDocPath()));
                    }
                    else
                    {
                        System.IO.File.AppendAllText(@"AnnualAccountingLog.txt", "Could not find ward document: " + w.getStoragePath() + "\\" + w.getDocPath() + " - " + DateTime.Now + "\r\n");
                    }
                }


                ceTe.DynamicPDF.PageList pl = new PageList();                 // find out how many pages the resulting PDF document has so we can add the count to the final filename
                pl = document.Pages;
                Console.WriteLine("File has {0} Pages", pl.Count);
                document2 = System.IO.Path.Combine(pdfTargetFolder, ward.getWardNumber() + "_AnnualPlan_" + pl.Count.ToString() + ".pdf"); // name of the final output document
                document.Draw(document2);
                File.Delete(document1);                                                                                                    // delete the 9999_temporary.pdf
                document2 = null;
            }
            else
            {
                Console.WriteLine("LOG: => No Physician Documents found for ward {0}", ward.getWardNumber());
                System.IO.File.AppendAllText(@logFile, "Ward: " + ward.getWardNumber() + " has no Doctor Reports to process " + DateTime.Now + "\r\n");

                ceTe.DynamicPDF.PageList pl = new PageList();
                document  = new MergeDocument(document1);
                pl        = document.Pages;
                document2 = System.IO.Path.Combine(pdfTargetFolder, ward.getWardNumber() + "_AnnualPlan_" + pl.Count.ToString() + ".pdf"); // name of the final output document
                document.Draw(document2);
                File.Delete(document1);                                                                                                    // delete the 9999_temporary.pdf
                document2 = null;
                dh.updatePlanStatus(ward.getWardNumber(), connection);
                connection.Close();
            }
        }
示例#18
0
        /// <summary>
        /// Método usado para deletar uma página especifica do documento.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Web.UI.ImageClickEventArgs"/> instance containing the event data.</param>
        protected void ImageButtonDeletePagina_Click(object sender, ImageClickEventArgs e)
        {
            string nomeArquivo = LabelArquivo.Text;
            LabelErro.Text = "";
            ImageAttention.Visible = false;
            //verificar se o nome nao esta nulo
            if (nomeArquivo.Equals(""))
            {
                ScriptManager.RegisterStartupScript(Page, GetType(), Guid.NewGuid().ToString(), "window.alert('Não existe arquivo');", true);
            }
            else
            {
                int page = Convert.ToInt16(TextBoxDeletePagina.Text);
                PdfDocument originalPDF = new PdfDocument(pathDir + nomeArquivo);  //specify original file
                int totalpages = originalPDF.Pages.Count;

                if ((page > totalpages) || (page <= 0))
                {
                    ScriptManager.RegisterStartupScript(Page, GetType(), Guid.NewGuid().ToString(), "window.alert('Página fora do limite!');", true);
                }
                else if (totalpages == 1)
                {
                    System.IO.File.Delete(pathDir + nomeArquivo);
                    TableArquivo.Visible = false;
                    string abaAtiva = retornaAbaAtiva();
                    Session.Add("postou_" + abaAtiva, "nao");
                    ScriptManager.RegisterStartupScript(Page, GetType(), Guid.NewGuid().ToString(), "window.alert('Página deletada com sucesso!');", true);
                }
                else if (totalpages != 1)
                {
                    if (page == totalpages)
                    {
                        MergeDocument smallerPDF = new MergeDocument(originalPDF, 1, page - 1);
                        smallerPDF.Draw(nomeArquivo);
                        System.IO.File.Delete(pathDir + nomeArquivo);
                        System.IO.File.Move(nomeArquivo, pathDir + nomeArquivo);
                    }
                    else
                    {
                        MergeDocument smallerPDF = new MergeDocument(originalPDF, 1, page - 1);
                        int pagesAppend = totalpages - page;
                        smallerPDF.Append(originalPDF, page + 1, pagesAppend);  //append pages deleted plus one until page count;
                        smallerPDF.Draw(nomeArquivo);
                        System.IO.File.Delete(pathDir + nomeArquivo);
                        System.IO.File.Move(nomeArquivo, pathDir + nomeArquivo);
                    }
                    ScriptManager.RegisterStartupScript(Page, GetType(), Guid.NewGuid().ToString(), "window.alert('Página deletada com sucesso!');", true);
                }

            }
        }
示例#19
0
        protected void ImageButtonDeletePagina_Click(object sender, ImageClickEventArgs e)
        {
            string nomeArquivo = LabelArquivo.Text;
            LabelErro.Text = "";
            ImageAttention.Visible = false;
            //verificar se o nome nao esta nulo
            if (nomeArquivo.Equals(""))
            {
                LabelErro.Text = "Não existe arquivo";
                ImageAttention.Visible = true;
            }
            else
            {
                int page = Convert.ToInt16(TextBoxDeletePagina.Text);
                PdfDocument originalPDF = new PdfDocument(pathDir + nomeArquivo);  //specify original file
                int totalpages = originalPDF.Pages.Count;

                if ((page > totalpages) || (page <= 0))
                {
                    LabelErro.Text = "Página fora do limite";
                    ImageAttention.Visible = true;
                }
                else if (page == totalpages)
                {
                    MergeDocument smallerPDF = new MergeDocument(originalPDF, 1, page - 1);
                    smallerPDF.Draw(nomeArquivo);
                    System.IO.File.Delete(pathDir + nomeArquivo);
                    System.IO.File.Move(nomeArquivo, pathDir + nomeArquivo);
                }
                else
                {
                    MergeDocument smallerPDF = new MergeDocument(originalPDF, 1, page - 1);
                    int pagesAppend = totalpages - page;
                    smallerPDF.Append(originalPDF, page + 1, pagesAppend);  //append pages deleted plus one until page count;
                    smallerPDF.Draw(nomeArquivo);
                    System.IO.File.Delete(pathDir + nomeArquivo);
                    System.IO.File.Move(nomeArquivo, pathDir + nomeArquivo);
                }
            }
        }