Ejemplo n.º 1
0
    public void pdfTest()
    {
        RawImage rawImage = gameObject.AddComponent <RawImage>();

        string          sentence          = bipSeed;
        QRCodeGenerator qrGenerator       = new QRCodeGenerator();
        QRCodeData      qrCodeData        = qrGenerator.CreateQrCode(sentence, QRCodeGenerator.ECCLevel.Q);
        UnityQRCode     qrCode            = new UnityQRCode(qrCodeData);
        Texture2D       qrCodeAsTexture2D = qrCode.GetGraphic(20);

        rawImage.texture = qrCodeAsTexture2D;
        byte[] bytes = qrCodeAsTexture2D.EncodeToJPG(); // .EncodeToPNG();

        pdfDocument myDoc  = new sharpPDF.pdfDocument("qr_pdf_test", "qr tester");
        pdfPage     myPage = myDoc.addPage(500, 500);

        myPage.addImage(bytes, 1, 150, 200, 200);

        myPage.addText("Your seed entropy is: ", 10, 470, sharpPDF.Enumerators.predefinedFont.csCourier, 15);
        myPage.addText(hexSeed, 10, 450, sharpPDF.Enumerators.predefinedFont.csCourier, 15);
        myPage.addText(bipSeed, 10, 425, sharpPDF.Enumerators.predefinedFont.csCourier, 10);

        // need to change this code depending on the current operating system/build type
        myDoc.createPDF("qr_pdf_test.pdf");
        myPage = null;
        myDoc  = null;
    }
Ejemplo n.º 2
0
    public void pdfTest()
    {
        string          sentence          = "ugly call give address amount venture misery dose quick spoil weekend inspire";
        QRCodeGenerator qrGenerator       = new QRCodeGenerator();
        QRCodeData      qrCodeData        = qrGenerator.CreateQrCode(sentence, QRCodeGenerator.ECCLevel.Q);
        UnityQRCode     qrCode            = new UnityQRCode(qrCodeData);
        Texture2D       qrCodeAsTexture2D = qrCode.GetGraphic(20);

        rawImage.texture = qrCodeAsTexture2D;
        byte[] bytes = qrCodeAsTexture2D.EncodeToJPG(); // .EncodeToPNG();

        pdfDocument myDoc  = new sharpPDF.pdfDocument("qr_pdf_test", "qr tester");
        pdfPage     myPage = myDoc.addPage(500, 500);

        myPage.addImage(bytes, 1, 150, 200, 200);

        myPage.addText("Your seed entropy is: ", 10, 470, sharpPDF.Enumerators.predefinedFont.csCourier, 15);
        myPage.addText("0x3720B025A102812744F830F55DDA275C5", 10, 450, sharpPDF.Enumerators.predefinedFont.csCourier, 15);
        myPage.addText("ugly call give address amount venture misery dose quick spoil weekend inspire", 10, 425, sharpPDF.Enumerators.predefinedFont.csCourier, 10);

        myDoc.createPDF("qr_pdf_test.pdf");
        myPage = null;
        myDoc  = null;
    }
Ejemplo n.º 3
0
 private static void SaveImage(int x, int y, int w, int h, MemoryStream ms, Bitmap b, bool pdf)
 {
     Rectangle r = MainForm.getRectangle(b, x, y, w, h);
     if (!r.IsEmpty)
     {
         b = b.Clone(r, b.PixelFormat);
     }
     if (pdf)
     {
         pdfDocument doc = new pdfDocument("Image scanned", "ScanIt by Martin Dobias");
         ScanHandler.DrawPage(doc, 1, b);
         doc.createPDF(ms);
     }
     else
     {
         b.Save(ms, ImageFormat.Png);
     }
 }
    // Update is called once per frame
    public IEnumerator CreatePDF()
    {
        Prix_Script _prix_Script = GetComponent<Prix_Script> ();

        attacName = Path.GetRandomFileName();
        attacName = attacName.Substring(0,6);
        attacName = attacName.ToUpper();
        dosName = attacName;
        attacName = attacName + ".pdf";

        Data_Client_Script _data_Client_Script = _menuFormulaire.GetComponent<Data_Client_Script>();

        string nom = _data_Client_Script._lastName;
        string prenom = _data_Client_Script._firstName;
        string adresse = _data_Client_Script._address;
        string mail = _data_Client_Script._email;
        string commentaire = _data_Client_Script._commentaire;

        pdfDocument myDoc = new pdfDocument("Sample Application","Me", false);
        pdfPage myFirstPage = myDoc.addPage();
        pdfPage mySecondPage = myDoc.addPage();
        //pdfPage myThirdPage = myDoc.addPage();
        //pdfPage myFourthPage = myDoc.addPage();

        int longueur = MySingleton.Instance._length;
        int largeur = MySingleton.Instance._width;

        bool _Wall_Main = MySingleton.Instance._Wall_Main;
        bool _Wall_Left = MySingleton.Instance._Wall_Left;
        bool _Wall_Right = MySingleton.Instance._Wall_Right;
        bool _Wall_Behind = MySingleton.Instance._Wall_Behind;

        bool _Enseigne = MySingleton.Instance._Enseigne;
        int longueur_Enseigne = MySingleton.Instance._longueur_Enseigne;
        int largeur_Enseigne = MySingleton.Instance._largeur_Enseigne;

        bool _Reserve = MySingleton.Instance._Reserve;
        int longueur_Reserve = MySingleton.Instance._longueur_Reserve;
        int largeur_Reserve = MySingleton.Instance._largeur_Reserve;

        //width = 612
        //height = ?
        myFirstPage.newAddImageV4 (bandeau, 180,myFirstPage.height - 130);

        //myFirstPage.addText("Devis",10,650,predefinedFont.csHelveticaOblique,30,new pdfColor(predefinedColor.csBlueStandExpo));

        myFirstPage.addText("Nom : " +nom,55,650,predefinedFont.csHelveticaOblique,11,new pdfColor(predefinedColor.csBlack));
        myFirstPage.addText("Prénom : " +prenom,55,630,predefinedFont.csHelveticaOblique,11,new pdfColor(predefinedColor.csBlack));
        myFirstPage.addText("Nom de la société: " +adresse,55,610,predefinedFont.csHelveticaOblique,11,new pdfColor(predefinedColor.csBlack));
        myFirstPage.addText("Email : " + mail, 55, 590, predefinedFont.csHelveticaOblique, 11, new pdfColor(predefinedColor.csBlack));

        if (commentaire != "") {
            string newParagraph = "Commentaire : \n" + commentaire;
            myFirstPage.addParagraph (newParagraph, 306, 660, predefinedFont.csHelveticaOblique, 11, myFirstPage.width / 2 - 20, 12, new pdfColor (predefinedColor.csBlack));
        }
        /*
        pdfTable remarqueTable = new pdfTable();
        remarqueTable.borderSize = 1;
        remarqueTable.tableHeader.addColumn(new pdfTableColumn("", predefinedAlignment.csLeft, myThirdPage.width - 50));
        remarqueTable.cellpadding = 60;
        myThirdPage.addTable(remarqueTable, 20, 150);

        remarqueTable = null;
        */

        yield return new WaitForEndOfFrame();

        /*Table's creation*/

        pdfTable myTable = new pdfTable();
        //Set table's border
        myTable.borderSize = 1;
        myTable.borderColor = new pdfColor(predefinedColor.csBlack);
        /*Create table's header*/
        int nbrRow = 0;
        myTable.tableHeader.addColumn(new pdfTableColumn("Stand",predefinedAlignment.csCenter,160));
        myTable.tableHeader.addColumn(new pdfTableColumn("Mesure",predefinedAlignment.csCenter,120));
        myTable.tableHeader.addColumn(new pdfTableColumn("Prix unit",predefinedAlignment.csCenter,120));
        myTable.tableHeader.addColumn(new pdfTableColumn("Prix",predefinedAlignment.csCenter,100));

        //Create table's rows
        pdfTableRow myRow;
        /*
         * Si erreur : taille de la cellule trop petite par rapport au texte
         */

        float _prixObjet = 0;

        myRow = myTable.createRow();//myRow[0].columnSize
        myRow[0].columnValue = "Sol";
        myRow[1].columnValue = (longueur*largeur) + "m²";
        myRow[2].columnValue = _prix_Script.prixSol[0] + " Euros/m² HT";
        myRow[3].columnValue = _prix_Script.pSol + " Euros HT";
        myTable.addRow(myRow);
        _prixObjet += _prix_Script.pSol;
        nbrRow = 2;

        if (_Wall_Main || _Wall_Left || _Wall_Right)
        {

            int longueurGaineCoton = 0;
            int longueurMelamineeBlanc = 0;
            int longueurMelamineeNoir = 0;
            int longueurPersonnalise = 0;

            float prixGaineCoton = 0;
            float prixMelamineeBlanc = 0;
            float prixMelamineeNoir = 0;
            float prixPersonnalise = 0;

            if( _Wall_Main )
            {
                if( _prix_Script.matiereMur[0] == "Gainée coton" )
                {
                    longueurGaineCoton += longueur;
                    prixGaineCoton += _prix_Script.pMurMain;
                }
                else if( _prix_Script.matiereMur[0] == "Mélaminée blanc" )
                {
                    longueurMelamineeBlanc += longueur;
                    prixMelamineeBlanc += _prix_Script.pMurMain;
                }
                else if( _prix_Script.matiereMur[0] == "Mélaminée noir" )
                {
                    longueurMelamineeNoir += longueur;
                    prixMelamineeNoir += _prix_Script.pMurMain;
                }
                else if( _prix_Script.matiereMur[0] == "Personnalisée" )
                {
                    longueurPersonnalise += longueur;
                    prixPersonnalise += _prix_Script.pMurMain;
                }
            }
            if( _Wall_Left )
            {
                if( _prix_Script.matiereMur[1] == "Gainée coton" )
                {
                    longueurGaineCoton += largeur;
                    prixGaineCoton += _prix_Script.pMurGauche;
                }
                else if( _prix_Script.matiereMur[1] == "Mélaminée blanc" )
                {
                    longueurMelamineeBlanc += largeur;
                    prixMelamineeBlanc += _prix_Script.pMurGauche;
                }
                else if( _prix_Script.matiereMur[1] == "Mélaminée noir" )
                {
                    longueurMelamineeNoir += largeur;
                    prixMelamineeNoir += _prix_Script.pMurGauche;
                }
                else if( _prix_Script.matiereMur[1] == "Personnalisée" )
                {
                    longueurPersonnalise += largeur;
                    prixPersonnalise += _prix_Script.pMurGauche;
                }
            }
            if( _Wall_Right )
            {
                if( _prix_Script.matiereMur[2] == "Gainée coton" )
                {
                    longueurGaineCoton += largeur;
                    prixGaineCoton += _prix_Script.pMurDroite;
                }
                else if( _prix_Script.matiereMur[2] == "Mélaminée blanc" )
                {
                    longueurMelamineeBlanc += largeur;
                    prixMelamineeBlanc += _prix_Script.pMurDroite;
                }
                else if( _prix_Script.matiereMur[2] == "Mélaminée noir" )
                {
                    longueurMelamineeNoir += largeur;
                    prixMelamineeNoir += _prix_Script.pMurDroite;
                }
                else if( _prix_Script.matiereMur[2] == "Personnalisée" )
                {
                    longueurPersonnalise += largeur;
                    prixPersonnalise += _prix_Script.pMurDroite;
                }
            }

            if( prixGaineCoton > 0)
            {

                myRow = myTable.createRow();
                myRow[0].columnValue = "Cloison Gainée coton";
                myRow[1].columnValue = longueurGaineCoton+" m";
                myRow[2].columnValue = _prix_Script.prixMur[0] + " Euros/m HT";
                myRow[3].columnValue = prixGaineCoton + " Euros HT";
                myTable.addRow(myRow);
                _prixObjet += prixGaineCoton;
                nbrRow++;

            }
            if( prixMelamineeBlanc > 0)
            {

                myRow = myTable.createRow();
                myRow[0].columnValue = "Cloison Mélaminée blanc";
                myRow[1].columnValue = longueurMelamineeBlanc+" m";
                myRow[2].columnValue = _prix_Script.prixMur[1] + " Euros/m HT";
                myRow[3].columnValue = prixMelamineeBlanc + " Euros HT";
                myTable.addRow(myRow);
                _prixObjet += prixMelamineeBlanc;
                nbrRow++;

            }
            if( prixMelamineeNoir > 0)
            {

                myRow = myTable.createRow();
                myRow[0].columnValue = "Cloison Mélaminée noir";
                myRow[1].columnValue = longueurMelamineeNoir+" m";
                myRow[2].columnValue = _prix_Script.prixMur[2] + " Euros/m HT";
                myRow[3].columnValue = prixMelamineeNoir + " Euros HT";
                myTable.addRow(myRow);
                _prixObjet += prixMelamineeNoir;
                nbrRow++;

            }
            if( prixPersonnalise > 0)
            {

                myRow = myTable.createRow();
                myRow[0].columnValue = "Cloison Personnalisée";
                myRow[1].columnValue = longueurPersonnalise+" m";
                myRow[2].columnValue = _prix_Script.prixMur[3] + " Euros/m HT";
                myRow[3].columnValue = prixPersonnalise + " Euros HT";
                myTable.addRow(myRow);
                _prixObjet += prixPersonnalise;
                nbrRow++;

            }

        }

        if( _Reserve )
        {
            myRow = myTable.createRow();
            myRow[0].columnValue = "Reserve " + _prix_Script.matiereReserve;
            myRow[1].columnValue = longueur_Reserve * largeur_Reserve + "m²";
            myRow[2].columnValue = _prix_Script.prixReserve[_prix_Script._reserve.GetComponent<Texture_Script>().tex] + " Euros/m² HT";
            //myRow[3].columnValue = _prix_Script.matiereReserve;
            myRow[3].columnValue = _prix_Script.pReserve + " Euros HT";
            myTable.addRow(myRow);
            _prixObjet += _prix_Script.pReserve;
            nbrRow++;
        }
        if( _Enseigne )
        {
            myRow = myTable.createRow();
            myRow[0].columnValue = "Enseigne";
            if( !_sceneManager.GetComponent<SceneManager_Script>()._isCarre )
                myRow[1].columnValue = longueur_Enseigne + "m ";
            else
                myRow[1].columnValue = longueur_Enseigne + "m * 4";
            myRow[2].columnValue = _prix_Script.prixEnseigne[_prix_Script._enseigne[0].GetComponent<Texture_Script>().tex] + " Euros/m HT";
            //myRow[3].columnValue = _prix_Script.matiereEnseigne;
            myRow[3].columnValue = _prix_Script.pEnseigne + " Euros HT";
            myTable.addRow(myRow);
            _prixObjet += _prix_Script.pEnseigne;
            nbrRow++;
        }

        int nbrBecSigne = 0;
        int nbrPelleTarte = 0;

        if( _Wall_Main )
        {
            nbrBecSigne += _prix_Script._lightManager_Script.nbrLightWallMain;
        }
        if( _Wall_Left )
        {
            nbrBecSigne += _prix_Script._lightManager_Script.nbrLightWallLeft;
        }
        if( _Wall_Right )
        {
            nbrBecSigne += _prix_Script._lightManager_Script.nbrLightWallRight;
        }
        if( _Reserve )
        {
            nbrBecSigne += _prix_Script._lightManager_Script.nbrLightWallReserve;
        }

        if( _Enseigne )
        {
            nbrPelleTarte += _prix_Script._lightManager_Script.nbrLightWallEnseigne;
        }

        if (nbrBecSigne > 0) {
            myRow = myTable.createRow ();
            myRow [0].columnValue = "Col de cygne";
            myRow [1].columnValue = nbrBecSigne + " Lampe(s)";
            myRow [2].columnValue = _prix_Script.prixLampeStand [0] + " Euros HT";
            myRow [3].columnValue = ( _prix_Script.pLightMurDroite + _prix_Script.pLightMurMain + _prix_Script.pLightMurGauche  + _prix_Script.pLightReserve ) + " Euros HT";
            myTable.addRow (myRow);
            nbrRow++;
        }
        if (nbrPelleTarte > 0) {
            myRow = myTable.createRow ();
            myRow [0].columnValue = "Pelle à Tarte";
            myRow [1].columnValue = nbrPelleTarte + " Lampe(s)";
            myRow [2].columnValue = _prix_Script.prixLampeEnseigne [0] + " Euros HT";
            myRow [3].columnValue = _prix_Script.pLightEnseigne + " Euros HT";
            myTable.addRow (myRow);
            nbrRow++;
        }

        myRow = myTable.createRow();
        myRow[0].columnValue = "Total";
        myRow[1].columnValue = "";
        myRow[2].columnValue = "";
        myRow[3].columnValue = (_prixObjet + _prix_Script.pLightTotal) + " Euros HT";
        myTable.addRow(myRow);
        nbrRow++;

        /*Set Header's Style*/
        int sizeRowTitle = 10;
        myTable.tableHeaderStyle = new pdfTableRowStyle(predefinedFont.csCourierBoldOblique,sizeRowTitle,new pdfColor(predefinedColor.csBlack),new pdfColor(predefinedColor.csBlueStandExpo));
        /*Set Row's Style*/
        int sizeRow = 9;
        myTable.rowStyle = new pdfTableRowStyle(predefinedFont.csCourier,sizeRow,new pdfColor(predefinedColor.csBlack),new pdfColor(predefinedColor.csWhite));
        /*Set Alternate Row's Style*/
        myTable.alternateRowStyle = new pdfTableRowStyle(predefinedFont.csCourier,sizeRow,new pdfColor(predefinedColor.csBlack),new pdfColor(predefinedColor.csLightYellow));
        /*Set Cellpadding*/
        myTable.cellpadding = 13;
        //Put the table on the page object
        myFirstPage.addTable(myTable, 55, (myFirstPage.height/2));
        myTable = null;

        int ligne = (mySecondPage.height - 20) - ((13*3) * nbrRow);

        //yield return new WaitForEndOfFrame();

        /*

        pdfTable myTableLight = new pdfTable();
        //Set table's border
        myTableLight.borderSize = 1;
        myTableLight.borderColor = new pdfColor(predefinedColor.csBlack);
        /
        nbrRow = 0;
        myTableLight.tableHeader.addColumn(new pdfTableColumn("Lampe",predefinedAlignment.csCenter,130));
        myTableLight.tableHeader.addColumn(new pdfTableColumn("Nombre",predefinedAlignment.csCenter,130));
        myTableLight.tableHeader.addColumn(new pdfTableColumn("Prix unitaire",predefinedAlignment.csCenter,150));
        myTableLight.tableHeader.addColumn(new pdfTableColumn("Prix",predefinedAlignment.csCenter,130));
        nbrRow ++;
        //Create table's rows
        pdfTableRow myRowLight;
        float _prixLight = 0;

        if( _Wall_Main )
        {
            myRowLight = myTableLight.createRow();
            myRowLight[0].columnValue = "Cloison 1";
            myRowLight[1].columnValue = _prix_Script._lightManager_Script.nbrLightWallMain + " lampe(s)";
            myRowLight[2].columnValue = _prix_Script.prixLampeStand[0] + " Euro";
            myRowLight[3].columnValue = _prix_Script.pLightMurMain + " Euros";
            myTableLight.addRow(myRowLight);
            _prixLight += _prix_Script.pLightMurMain;
            nbrRow++;
        }
        if( _Wall_Left )
        {
            myRowLight = myTableLight.createRow();
            myRowLight[0].columnValue = "Cloison 2";
            myRowLight[1].columnValue = _prix_Script._lightManager_Script.nbrLightWallLeft + " lampe(s)";
            myRowLight[2].columnValue = _prix_Script.prixLampeStand[0] + " Euros";
            myRowLight[3].columnValue = _prix_Script.pLightMurGauche + " Euros";
            myTableLight.addRow(myRowLight);
            _prixLight += _prix_Script.pLightMurGauche;
            nbrRow++;
        }
        if( _Wall_Right )
        {
            myRowLight = myTableLight.createRow();
            myRowLight[0].columnValue = "Cloison 3";
            myRowLight[1].columnValue = _prix_Script._lightManager_Script.nbrLightWallRight + " lampe(s)";
            myRowLight[2].columnValue = _prix_Script.prixLampeStand[0] + " Euros";
            myRowLight[3].columnValue = _prix_Script.pLightMurDroite + " Euros";
            myTableLight.addRow(myRowLight);
            _prixLight += _prix_Script.pLightMurDroite;
            nbrRow++;
        }
        if( _Reserve )
        {
            myRowLight = myTableLight.createRow();
            myRowLight[0].columnValue = "Reserve";
            myRowLight[1].columnValue = _prix_Script._lightManager_Script.nbrLightWallReserve + " lampe(s)";
            myRowLight[2].columnValue = _prix_Script.prixLampeStand[0] + " Euros";
            myRowLight[3].columnValue = _prix_Script.pLightReserve + " Euros";
            myTableLight.addRow(myRowLight);
            _prixLight += _prix_Script.pLightReserve;
            nbrRow++;
        }
        if( _Enseigne )
        {
            myRowLight = myTableLight.createRow();
            myRowLight[0].columnValue = "Enseigne";
            myRowLight[1].columnValue = _prix_Script._lightManager_Script.nbrLightWallEnseigne + " lampe(s)";
            myRowLight[2].columnValue = _prix_Script.prixLampeEnseigne[0] + " Euros";
            myRowLight[3].columnValue = _prix_Script.pLightEnseigne + " Euros";
            myTableLight.addRow(myRowLight);
            _prixLight += _prix_Script.pLightEnseigne;
            nbrRow++;
        }

        myRow = myTableLight.createRow();
        myRow[0].columnValue = "Total";
        myRow[1].columnValue = "";
        myRow[2].columnValue = "";
        myRow[3].columnValue = _prixLight + " Euros";
        myTableLight.addRow(myRow);
        nbrRow++;

        sizeRowTitle = 15;
        myTableLight.tableHeaderStyle = new pdfTableRowStyle(predefinedFont.csCourierBoldOblique,sizeRowTitle,new pdfColor(predefinedColor.csBlack),new pdfColor(predefinedColor.csBlueStandExpo));

        sizeRow = 12;
        myTableLight.rowStyle = new pdfTableRowStyle(predefinedFont.csCourier,sizeRow,new pdfColor(predefinedColor.csBlack),new pdfColor(predefinedColor.csWhite));

        myTableLight.alternateRowStyle = new pdfTableRowStyle(predefinedFont.csCourier,sizeRow,new pdfColor(predefinedColor.csBlack),new pdfColor(predefinedColor.csLightYellow));

        myTableLight.cellpadding = 13;
        //Put the table on the page object
        mySecondPage.addTable(myTableLight, 10, ligne);
        myTableLight = null;

        ligne -= (10 + ((13*3) * nbrRow ));

        yield return new WaitForEndOfFrame();

        pdfTable myTableTotal = new pdfTable();
        //Set table's border
        myTableTotal.borderSize = 1;
        myTableTotal.borderColor = new pdfColor(predefinedColor.csBlack);

        nbrRow = 0;
        myTableTotal.tableHeader.addColumn(new pdfTableColumn("Total",predefinedAlignment.csCenter,130));
        myTableTotal.tableHeader.addColumn(new pdfTableColumn(_prixLight + _prixObjet + " Euros",predefinedAlignment.csCenter,130));

        sizeRowTitle = 15;
        myTableTotal.tableHeaderStyle = new pdfTableRowStyle(predefinedFont.csCourierBoldOblique,sizeRowTitle,new pdfColor(predefinedColor.csBlack),new pdfColor(predefinedColor.csVertStandExpo));

        sizeRow = 12;
        myTableTotal.rowStyle = new pdfTableRowStyle(predefinedFont.csCourier,sizeRow,new pdfColor(predefinedColor.csBlack),new pdfColor(predefinedColor.csWhite));

        myTableTotal.alternateRowStyle = new pdfTableRowStyle(predefinedFont.csCourier,sizeRow,new pdfColor(predefinedColor.csBlack),new pdfColor(predefinedColor.csLightYellow));

        myTableTotal.cellpadding = 13;
        //Put the table on the page object
        mySecondPage.addTable(myTableTotal, 10, ligne);
        myTableTotal = null;

        */

        yield return new WaitForSeconds(3.0f);
        mySecondPage.newAddImageV2 (GetComponent<Capture_Script>()._texture, mySecondPage.width/ 2 - ((GetComponent<Capture_Script> ()._texture.width/2)/2), mySecondPage.height - 10 - (GetComponent<Capture_Script> ()._texture.height)/2);
        mySecondPage.newAddImageV2(GetComponent<Capture_Script>()._texture2, mySecondPage.width / 2 - ((GetComponent<Capture_Script>()._texture2.width / 2) / 2)/*25*/, mySecondPage.height - 20 - (GetComponent<Capture_Script>()._texture.height));

        /*
        pdfTable remarqueTable = new pdfTable();
        remarqueTable.borderSize = 1;
        remarqueTable.tableHeader.addColumn(new pdfTableColumn("", predefinedAlignment.csCenter, mySecondPage.width-50));
        remarqueTable.cellpadding = 60;
        myFirstPage.addTable(remarqueTable, 20, 150);

        remarqueTable = null;

        myFirstPage.addText("Remarque : ", 23, 130, predefinedFont.csHelveticaOblique, 15, new pdfColor(predefinedColor.csBlack));
        */

        //print (myFirstPage.width);->612
        myDoc.createPDF(attacName);

        buffer = System.IO.File.ReadAllBytes(attacName);

        WWWForm form = new WWWForm();
        form.AddField("action", "createPDF");
        form.AddField("add", "*****@*****.**");
        form.AddField("file","file");
        form.AddField("Dos",dosName);

        form.AddBinaryData( "file", buffer, attacName,"pdf");

        WWW www = new WWW("http://www.pointcube.com/StandExpo/UploadPDF.php",form);
        yield return www;
        print("SenMail");

        //_menuFormulaire.SetActive (true);
        _sceneManager.GetComponent<Select_Object_Script> ()._block = false;
        //_sceneManager.GetComponent<Select_Object_Script> ()._cacheBool = false;

        _cam1.SetActive (true);
        //_cam2.SetActive (true);
        //_slider.SetActive (true);

        _messVALIDATION.transform.GetChild(0).GetComponent<Text>().text = "Merci pour votre montage";
        timerMessValidation = 3.0f;
        _messVALIDATION.SetActive(true);

        /*
        if (www.error != null)
        {
            print (www.error);
        }
        else
        {
            //print (www.uploadProgress);
            if(www.uploadProgress == 1  && www.isDone)
            {

                yield return new WaitForSeconds(1);
                //change the url to the url of the folder you want it the levels to be stored, the one you specified in the php file
                WWW w2 = new WWW("http://www.pointcube.com/StandExpo/" + dosName + "/" + attacName);
                while(!w2.isDone){yield return w2;}

                if(w2.error != null)
                {
                    print("error 2");
                    print ( w2.error );
                }
                else
                {
                    //WWW.LoadFromCacheOrDownload
                    print("SenMail");
                    //GetComponent<mono_gmail>().SendMail(myDoc._myFileStream);

                }

            }
        }
        */
    }
Ejemplo n.º 5
0
        private void CreatePdf(string pdfFilePath)
        {
            var pdfDoc = new pdfDocument("BREEAM Materials Report", "");

            var coverPage = pdfDoc.addPage(predefinedPageSize.csA4Page);

            coverPage.addText("BREEAM Materials", 40, coverPage.height - 140, pdfDoc.getFontReference(predefinedFont.csHelveticaBold), 20);
            coverPage.addText(string.Format("Project Name: {0}", projectName), 40, coverPage.height - 165, pdfDoc.getFontReference(predefinedFont.csHelvetica), 10);
            coverPage.addText(string.Format("Project Type: {0}", projectType), 40, coverPage.height - 180, pdfDoc.getFontReference(predefinedFont.csHelvetica), 10);
            coverPage.addText(string.Format("Building Type: {0}", buildingType), 40, coverPage.height - 195, pdfDoc.getFontReference(predefinedFont.csHelvetica), 10);
            coverPage.addText(string.Format("Project Phase: {0}", projectPhase), 40, coverPage.height - 210, pdfDoc.getFontReference(predefinedFont.csHelvetica), 10);

            if (documentCertficate.ContainsKey("Mat1"))
            {
                var mat1Items = new Dictionary<string, List<Dictionary<string, object>>>();

                var gr = externalWalls.GroupBy(ew => ew.ElementNumber);

                var mat1ExternalWallGroup =
                    gr
                     .Select(
                         ew =>
                             new Dictionary<string, object>()
                            {
                                {"Name", ew.First().Name},
                                {"Element Number", ew.Key},
                                {"Area", ew.Sum(w => w.NetSideArea).ToString("N")},
                                {"Green Guide Rating", ew.First().Point}
                            });
                if (mat1ExternalWallGroup.Any())
                {
                    mat1Items.Add("External Wall", mat1ExternalWallGroup.ToList());
                }

                var mat1CurtainWallGroup = curtainWalls.GroupBy(ew => ew.ElementNumber)
                        .Select(
                            ew =>
                                new Dictionary<string, object>()
                            {
                                {"Name", ew.First().Name},
                                {"Element Number", ew.Key},
                                {"Area", ew.Sum(w => w.GrossSideArea).ToString("N")},
                                {"Green Guide Rating", ew.First().Point}
                            });
                if (mat1CurtainWallGroup.Any())
                {
                    mat1Items.Add("Curtain Wall", mat1CurtainWallGroup.ToList());
                }

                var mat1WindowGroup = windows.GroupBy(ew => ew.ElementNumber)
                        .Select(
                            w =>
                                new Dictionary<string, object>()
                            {
                                {"Name", w.First().Name},
                                {"Element Number", w.Key},
                                {"Area", w.Sum(wi => wi.NetArea).ToString("N")},
                                {"Green Guide Rating", w.First().Point}
                            });
                if (mat1WindowGroup.Any())
                {
                    mat1Items.Add("Window", mat1WindowGroup.ToList());
                }

                var mat1FloorSlabsGroup = slabs.Where(s => s.SlabType == SlabType.Floor).GroupBy(s => s.ElementNumber)
                        .Select(
                            s =>
                                new Dictionary<string, object>()
                            {
                                {"Name", s.First().Name},
                                {"Element Number", s.Key},
                                {"Area", s.Sum(sl => sl.NetArea).ToString("N")},
                                {"Green Guide Rating", s.First().Point}
                            });
                if (mat1FloorSlabsGroup.Any())
                {
                    mat1Items.Add("Upper Floor", mat1FloorSlabsGroup.ToList());
                }

                var mat1RoofSlabGroup = slabs.Where(s => s.SlabType == SlabType.Roof).GroupBy(s => s.ElementNumber)
                        .Select(
                            s =>
                                new Dictionary<string, object>()
                            {
                                {"Name", s.First().Name},
                                {"Element Number", s.Key},
                                {"Area", s.Sum(sl => sl.NetArea).ToString("N")},
                                {"Green Guide Rating", s.First().Point}
                            });
                if (mat1RoofSlabGroup.Any())
                {
                    mat1Items.Add("Roof", mat1RoofSlabGroup.ToList());
                }
                if (!mat1Items.Any())
                {
                    mat1Items.Add("Material Specification", new List<Dictionary<string, object>>());
                }
                AddTable("Mat 1", mat1Items, ref pdfDoc);
            }

            if (documentCertficate.ContainsKey("Mat2a"))
            {
                var mat2aItems = new Dictionary<string, List<Dictionary<string, object>>>();
                mat2aItems.Add("Natural Boundary", new List<Dictionary<string, object>>());
                AddTable("Mat 2a", mat2aItems, ref pdfDoc);
            }
            if (documentCertficate.ContainsKey("Mat2b"))
            {
                var mat2BItems = new Dictionary<string, List<Dictionary<string, object>>>();

                var mat2BBoundaryWallGroup = boundaryWalls.GroupBy(bw => bw.ElementNumber)
                    .Select(
                        bw =>
                            new Dictionary<string, object>()
                            {
                                {"Name", bw.First().Name},
                                {"Element Number", bw.Key},
                                {"Area", bw.Sum(w => w.NetSideArea).ToString("N")},
                                {"Green Guide Rating", bw.First().Point}
                            });
                if (mat2BBoundaryWallGroup.Any())
                {
                    mat2BItems.Add("Boundary Protection", mat2BBoundaryWallGroup.ToList());
                }

                var mat2BLandingSlabGroup = slabs.Where(s => s.SlabType == SlabType.Landing).GroupBy(s => s.ElementNumber)
                        .Select(
                            s =>
                                new Dictionary<string, object>()
                            {
                                {"Name", s.First().Name},
                                {"ElementNumber", s.Key},
                                {"Area", s.Sum(sl => sl.NetArea).ToString("N")},
                                {"Green Guide Rating", s.First().Point}
                            });
                if (mat2BLandingSlabGroup.Any())
                {
                    mat2BItems.Add("Hard Landscaping", mat2BLandingSlabGroup.ToList());
                }
                if (!mat2BItems.Any())
                {
                    mat2BItems.Add("Hard Landscaping and Boundary Protection", new List<Dictionary<string, object>>());
                }
                AddTable("Mat 2b", mat2BItems, ref pdfDoc);
            }

            if (documentCertficate.ContainsKey("Mat3"))
            {

                var mat3Items = new Dictionary<string, List<Dictionary<string, object>>>();

                if (documentCertficate["Mat3"] == "No Credit")
                {
                    mat3Items.Add("Façade Reuse", new List<Dictionary<string, object>>());
                }
                else
                {
                    var mat3ExternalWallGroup = externalWalls.Where(ew => ew.FacadeReuse).GroupBy(ew => ew.ElementNumber)
                    .Select(
                        ew =>
                            new Dictionary<string, object>()
                            {
                                {"Name", ew.First().Name},
                                {"ElementNumber", ew.Key},
                                {"Area", ew.Sum(w => w.NetSideArea).ToString("N")},
                                {"Percentage", (ew.Sum(w => w.NetSideArea)/externalWalls.Sum(w => w.NetSideArea)).ToString("P")}
                            });
                    if (mat3ExternalWallGroup.Any())
                    {
                        mat3Items.Add("Reused External Wall", mat3ExternalWallGroup.ToList());
                    }

                    var mat3CurtainWallGroup = curtainWalls.Where(cw => cw.FacadeReuse).GroupBy(ew => ew.ElementNumber)
                            .Select(
                                cw =>
                                    new Dictionary<string, object>()
                            {
                                {"Name", cw.First().Name},
                                {"ElementNumber", cw.Key},
                                {"Area", cw.Sum(w => w.GrossSideArea).ToString("N")},
                                {"Percentage", (cw.Sum(w => w.GrossSideArea)/curtainWalls.Sum(w => w.GrossSideArea)).ToString("P")}
                            });
                    if (mat3CurtainWallGroup.Any())
                    {
                        mat3Items.Add("Reused Curtain Wall", mat3CurtainWallGroup.ToList());
                    }

                    var mat3WindowGroup = windows.Where(w => w.FacadeReuse).GroupBy(w => w.ElementNumber)
                            .Select(
                                w =>
                                    new Dictionary<string, object>()
                            {
                                {"Name", w.First().Name},
                                {"ElementNumber", w.Key},
                                {"Area", w.Sum(wi => wi.NetArea).ToString("N")},
                                {"Percentage", (w.Sum(wi => wi.NetArea)/windows.Sum(wi => wi.NetArea)).ToString("P")}
                            });

                    if (mat3WindowGroup.Any())
                    {
                        mat3Items.Add("Reused Window", mat3WindowGroup.ToList());
                    }
                    if (!mat3Items.Any())
                    {
                        mat3Items.Add("Façade Reuse", new List<Dictionary<string, object>>());
                    }
                }

                AddTable("Mat 3", mat3Items, ref pdfDoc);

            }

            if (documentCertficate.ContainsKey("Mat4"))
            {
                var mat4Items = new Dictionary<string, List<Dictionary<string, object>>>();
                if (documentCertficate["Mat4"] == "No Credit")
                {
                    mat4Items.Add("Structure Reuse", new List<Dictionary<string, object>>());
                }
                else
                {
                    var mat4ExternalWallGroup = externalWalls.Where(ew => ew.LoadBearing && ew.StructureReuse).GroupBy(ew => ew.ElementNumber)
                        .Select(
                            ew =>
                                new Dictionary<string, object>()
                            {
                                {"Name", ew.First().Name},
                                {"ElementNumber", ew.Key},
                                {"Volume", ew.Sum(w => w.NetVolume).ToString("N")},
                                {"Percentage", (ew.Sum(w => w.NetVolume)/externalWalls.Where(w => w.LoadBearing).Sum(w => w.NetVolume)).ToString("P")}
                            });
                    if (mat4ExternalWallGroup.Any())
                    {
                        mat4Items.Add("Reused External Wall", mat4ExternalWallGroup.ToList());
                    }

                    var mat4InteriorWallGroup = interiorWalls.Where(iw => iw.LoadBearing && iw.StructureReuse).GroupBy(iw => iw.ElementNumber)
                            .Select(
                                cw =>
                                    new Dictionary<string, object>()
                            {
                                {"Name", cw.First().Name},
                                {"ElementNumber", cw.Key},
                                {"Volume", cw.Sum(w => w.NetVolume).ToString("N")},
                                {"Percentage", (cw.Sum(w => w.NetVolume)/interiorWalls.Where(w => w.LoadBearing).Sum(w => w.NetVolume)).ToString("P")}
                            });
                    if (mat4InteriorWallGroup.Any())
                    {
                        mat4Items.Add("Reused Interior Wall", mat4InteriorWallGroup.ToList());
                    }

                    var mat4SlabsGroup = slabs.Where(s => s.SlabType == SlabType.Floor && s.LoadBearing && s.StructureReuse).GroupBy(s => s.ElementNumber)
                            .Select(
                                s =>
                                    new Dictionary<string, object>()
                            {
                                {"Name", s.First().Name},
                                {"ElementNumber", s.Key},
                                {"Volume", s.Sum(w => w.NetVolume).ToString("N")},
                                {"Percentage", (s.Sum(w => w.NetVolume)/slabs.Where(w => w.SlabType == SlabType.Floor && w.LoadBearing).Sum(w => w.NetVolume)).ToString("P")}
                            });

                    if (mat4SlabsGroup.Any())
                    {
                        mat4Items.Add("Reused Slab", mat4SlabsGroup.ToList());
                    }

                    var mat4ColumnGroup = columns.Where(c => c.StructureReuse).GroupBy(c => c.ElementNumber)
                            .Select(
                                c =>
                                    new Dictionary<string, object>()
                            {
                                {"Name", c.First().Name},
                                {"ElementNumber", c.Key},
                                {"Volume", c.Sum(w => w.NetVolume).ToString("N")},
                                {"Percentage", (c.Sum(co => co.NetVolume)/columns.Sum(co => co.NetVolume)).ToString("P")}
                            });

                    if (mat4ColumnGroup.Any())
                    {
                        mat4Items.Add("Reused Column", mat4ColumnGroup.ToList());
                    }

                    var mat4BeamGroup = beams.Where(b => b.StructureReuse).GroupBy(b => b.ElementNumber)
                            .Select(
                                b =>
                                    new Dictionary<string, object>()
                            {
                                {"Name", b.First().Name},
                                {"ElementNumber", b.Key},
                                {"Volume", b.Sum(w => w.NetVolume).ToString("N")},
                                {"Percentage", (b.Sum(be => be.NetVolume)/columns.Sum(be => be.NetVolume)).ToString("P")}
                            });
                    if (mat4BeamGroup.Any())
                    {
                        mat4Items.Add("Reused Beam", mat4BeamGroup.ToList());
                    }
                    if (!mat4Items.Any())
                    {
                        mat4Items.Add("Structure Reuse", new List<Dictionary<string, object>>());
                    }
                }
                AddTable("Mat 4", mat4Items, ref pdfDoc);
            }

            if (documentCertficate.ContainsKey("Mat5"))
            {
                var mat5Items = new Dictionary<string, List<Dictionary<string, object>>>();
                var mat5ExternalWallGroup = externalWalls.Where(ew => ew.Rsm).GroupBy(ew => ew.ElementNumber)
                    .Select(
                        ew =>
                            new Dictionary<string, object>()
                            {
                                {"Name", ew.First().Name},
                                {"Element Number", ew.Key},
                                {"Area", ew.Sum(w => w.NetSideArea).ToString("N")},
                                {"Percentage", (ew.Sum(w => w.NetSideArea)/externalWalls.Sum(w => w.NetSideArea)).ToString("P")},
                                {"Tier Level", ew.First().RsmText}
                            });

                if (mat5ExternalWallGroup.Any())
                {
                    mat5Items.Add("Responsibly Sourced Walls", mat5ExternalWallGroup.ToList());
                }

                var mat5InteriorWallGroup = interiorWalls.Where(iw => iw.Rsm).GroupBy(iw => iw.ElementNumber)
                        .Select(
                            iw =>
                                new Dictionary<string, object>()
                            {
                                {"Name", iw.First().Name},
                                {"Element Number", iw.Key},
                                {"Area", iw.Sum(w => w.GrossSideArea).ToString("N")},
                                {"Percentage", (iw.Sum(w => w.GrossSideArea)/interiorWalls.Sum(w => w.GrossSideArea)).ToString("P")},
                                {"Tier Level", iw.First().RsmText}
                            });
                if (mat5InteriorWallGroup.Any())
                {
                    mat5Items.Add("Responsibly Sourced Walls", mat5InteriorWallGroup.ToList());
                }

                var mat5RoofGroup =
                    slabs.Where(s => s.Rsm && s.SlabType == SlabType.Roof)
                        .GroupBy(s => s.ElementNumber)
                        .Select(s => new Dictionary<string, object>
                    {
                        {"Name", s.First().Name},
                        {"Element Number", s.Key},
                        {"Area", s.Sum(w => w.NetArea).ToString("N")},
                        {"Percentage", (s.Sum(w => w.NetArea)/slabs.Where(sl => sl.SlabType == SlabType.Roof).Sum(w => w.NetArea)).ToString("P")},
                        {"Tier Level", s.First().RsmText}
                    });
                if (mat5RoofGroup.Any())
                {
                    mat5Items.Add("Responsibly Sourced Roof", mat5RoofGroup.ToList());
                }

                var mat5FloorGroup = slabs.Where(s => s.Rsm && s.SlabType == SlabType.Floor)
                        .GroupBy(s => s.ElementNumber)
                        .Select(s => new Dictionary<string, object>
                    {
                        {"Name", s.First().Name},
                        {"Element Number", s.Key},
                        {"Area", s.Sum(w => w.NetArea).ToString("N")},
                        {"Percentage", (s.Sum(w => w.NetArea)/slabs.Where(sl => sl.SlabType == SlabType.Floor).Sum(w => w.NetArea)).ToString("P")},
                        {"Tier Level", s.First().RsmText}
                    });

                if (mat5FloorGroup.Any())
                {
                    mat5Items.Add("Responsibly Sourced Floor", mat5FloorGroup.ToList());
                }

                var mat5BaselabGroup = slabs.Where(s => s.Rsm && s.SlabType == SlabType.BaseSlab)
                        .GroupBy(s => s.ElementNumber)
                        .Select(s => new Dictionary<string, object>
                    {
                        {"Name", s.First().Name},
                        {"Element Number", s.Key},
                        {"Area", s.Sum(w => w.NetArea).ToString("N")},
                        {"Percentage", (s.Sum(w => w.NetArea)/slabs.Where(sl => sl.SlabType == SlabType.BaseSlab).Sum(w => w.NetArea)).ToString("P")},
                        {"Tier Level", s.First().RsmText}
                    });

                if (mat5BaselabGroup.Any())
                {
                    mat5Items.Add("Responsibly Sourced Foundation", mat5BaselabGroup.ToList());
                }

                var mat5ColumnGroup =
                    columns.Where(c => c.Rsm).GroupBy(c => c.ElementNumber).Select(c => new Dictionary<string, object>
                {
                    {"Name", c.First().Name},
                    {"Element Number", c.Key},
                    {"Area", c.Sum(w => w.GrossSurfaceArea).ToString("N")},
                    {"Percentage", (c.Sum(w => w.GrossSurfaceArea)/columns.Sum(w => w.GrossSurfaceArea)).ToString("P")},
                    {"Tier Level", c.First().RsmText}
                });

                if (mat5ColumnGroup.Any())
                {
                    mat5Items.Add("Responsibly Sourced Column", mat5ColumnGroup.ToList());
                }

                var mat5BeamGroup = beams.Where(c => c.Rsm).GroupBy(c => c.ElementNumber).Select(c => new Dictionary<string, object>
                {
                    {"Name", c.First().Name},
                    {"Element Number", c.Key},
                    {"Area", c.Sum(w => w.GrossSurfaceArea).ToString("N")},
                    {"Percentage", (c.Sum(w => w.GrossSurfaceArea)/beams.Sum(w => w.GrossSurfaceArea)).ToString("P")},
                    {"Tier Level", c.First().RsmText}
                });
                if (mat5BeamGroup.Any())
                {
                    mat5Items.Add("Responsibly Sourced Beam", mat5BeamGroup.ToList());
                }

                var mat5StairGroup =
                    stairs.Where(s => s.Rsm).GroupBy(s => s.ElementNumber).Select(s => new Dictionary<string, object>
                {
                    {"Name", s.First().Name},
                    {"Element Number", s.Key},
                    {"Area", s.Sum(sf => sf.Area).ToString("N")},
                    {"Percentage", (s.Sum(sf => sf.Area)/stairs.Sum(sf => sf.Area)).ToString("P")},
                    {"Tier Level", s.First().RsmText}
                });

                if (mat5StairGroup.Any())
                {
                    mat5Items.Add("Responsibly Sourced Stair", mat5StairGroup.ToList());
                }
                if (!mat5Items.Any())
                {
                    mat5Items.Add("Responsibly Sourced Materials", new List<Dictionary<string, object>>());
                }
                AddTable("Mat 5", mat5Items, ref pdfDoc);
            }

            if (documentCertficate.ContainsKey("Mat6a"))
            {
                var mat6AItems = new Dictionary<string, List<Dictionary<string, object>>>();

                var mat6AExternalWallGroup =
                externalWalls.Where(ew => ew.InsulationLayerThickness > 0)
                    .GroupBy(ew => ew.InsulationMaterialElementNumber)
                    .Select(ew => new Dictionary<string, object>
                    {
                        {"Name", ew.First().InsulationMaterialName},
                        {"Element Number", ew.Key},
                        {"Area", ew.Sum(w => w.NetSideArea).ToString("N")},
                        //{"Percentage", (ew.Sum(w => w.NetSideArea) / externalWalls.Sum(w => w.NetSideArea)).ToString("P")},
                        {"Green Guide Rating", ew.First().InsulationLayerMaterialPoint}
                    });

                mat6AItems.Add("External Wall Insulation", mat6AExternalWallGroup.ToList());

                var mat6ABaseSlabGroup = slabs.Where(s => s.InsulationLayerThickness > 0 && s.SlabType == SlabType.BaseSlab)
                        .GroupBy(s => s.InsulationMaterialElementNumber)
                        .Select(s => new Dictionary<string, object>
                    {
                        {"Name", s.First().InsulationMaterialName},
                        {"Element Number", s.Key},
                        {"Area", s.Sum(w => w.NetArea).ToString("N")},
                        //{"Percentage", (s.Sum(w => w.NetArea) / slabs.Where(sl => sl.SlabType == SlabType.BaseSlab).Sum(w => w.NetArea)).ToString("P")},
                        {"Green Guide Rating", s.First().InsulationLayerMaterialPoint}
                    });

                mat6AItems.Add("Ground Insulation", mat6ABaseSlabGroup.ToList());

                var mat6ARoofSlabGroup = slabs.Where(s => s.InsulationLayerThickness > 0 && s.SlabType == SlabType.Roof)
                        .GroupBy(s => s.InsulationMaterialElementNumber)
                        .Select(s => new Dictionary<string, object>
                    {
                        {"Name", s.First().InsulationMaterialName},
                        {"Element Number", s.Key},
                        {"Area", s.Sum(w => w.NetArea).ToString("N")},
                        //{"Percentage", (s.Sum(w => w.NetArea) / slabs.Where(sl => sl.SlabType == SlabType.Roof).Sum(w => w.NetArea)).ToString("P")},
                        {"Green Guide Rating", s.First().InsulationLayerMaterialPoint}
                    });

                mat6AItems.Add("Roof Insulation", mat6ARoofSlabGroup.ToList());
                if (!mat6AItems.Any())
                {
                    mat6AItems.Add("Insulation", new List<Dictionary<string, object>>());
                }
                AddTable("Mat 6a", mat6AItems, ref pdfDoc);
            }

            if (documentCertficate.ContainsKey("Mat6b"))
            {
                var mat6BItems = new Dictionary<string, List<Dictionary<string, object>>>();
                var mat6BExternalWallGroup =
                externalWalls.Where(ew => ew.InsulationLayerThickness > 0 && ew.InsulationMaterialName.Contains("RSM"))
                    .GroupBy(ew => ew.InsulationMaterialElementNumber)
                    .Select(ew => new Dictionary<string, object>
                    {
                        {"Name", ew.Single().InsulationMaterialName},
                        {"Element Number", ew.Key},
                        {"Area", ew.Sum(w => w.NetSideArea).ToString("N")},
                        {"Percentage", (ew.Sum(w => w.NetSideArea) / externalWalls.Sum(w => w.NetSideArea)).ToString("P")},
                        {"Green Guide Rating", ew.Single().InsulationLayerMaterialPoint}
                    });
                if (mat6BExternalWallGroup.Any())
                {
                    mat6BItems.Add("Responsibly Sourced External Wall Insulation", mat6BExternalWallGroup.ToList());
                }

                var mat6BBaseSlabGroup = slabs.Where(s => s.InsulationLayerThickness > 0 && s.SlabType == SlabType.BaseSlab && s.InsulationMaterialName.Contains("RSM"))
                        .GroupBy(s => s.InsulationMaterialElementNumber)
                        .Select(s => new Dictionary<string, object>
                    {
                        {"Name", s.First().InsulationMaterialName},
                        {"Element Number", s.Key},
                        {"Area", s.Sum(w => w.NetArea).ToString("N")},
                        {"Percentage", (s.Sum(w => w.NetArea) / slabs.Where(sl => sl.SlabType == SlabType.BaseSlab).Sum(w => w.NetArea)).ToString("P")},
                        {"Green Guide Rating", s.First().InsulationLayerMaterialPoint}
                    });
                if (mat6BBaseSlabGroup.Any())
                {
                    mat6BItems.Add("Responsibly Sourced Ground Insulation", mat6BBaseSlabGroup.ToList());
                }

                var mat6BRoofSlabGroup = slabs.Where(s => s.InsulationLayerThickness > 0 && s.SlabType == SlabType.Roof && s.InsulationMaterialName.Contains("RSM"))
                        .GroupBy(s => s.InsulationMaterialElementNumber)
                        .Select(s => new Dictionary<string, object>
                    {
                        {"Name", s.First().InsulationMaterialName},
                        {"Element Number", s.Key},
                        {"Area", s.Sum(w => w.NetArea).ToString("N")},
                        {"Percentage", (s.Sum(w => w.NetArea) / slabs.Where(sl => sl.SlabType == SlabType.Roof).Sum(w => w.NetArea)).ToString("P")},
                        {"Green Guide Rating", s.First().InsulationLayerMaterialPoint}
                    });
                if (mat6BRoofSlabGroup.Any())
                {
                    mat6BItems.Add("Responsibly Sourced Roof Insulation", mat6BRoofSlabGroup.ToList());
                }
                if (!mat6BItems.Any())
                {
                    mat6BItems.Add("Responsibly Sourced Insulation", new List<Dictionary<string, object>>());
                }
                AddTable("Mat 6b", mat6BItems, ref pdfDoc);
            }

            if (documentCertficate.ContainsKey("Mat7"))
            {
                var mat7Items = new Dictionary<string, List<Dictionary<string, object>>>();
                mat7Items.Add("Designing for Robustness", new List<Dictionary<string, object>>());
                AddTable("Mat 7", mat7Items, ref pdfDoc);
            }

            pdfDoc.createPDF(pdfFilePath);
            pdfDoc = null;
        }
Ejemplo n.º 6
0
 private static void SaveImage(int x, int y, int w, int h, MemoryStream ms, List<Bitmap> bs, bool pdf)
 {
     int count = 1;
     if (pdf)
     {
         pdfDocument doc = new pdfDocument("Images scanned", "ScanIt by Martin Dobias");
         foreach (Bitmap b in bs)
         {
             DrawPage(doc, count++, b);
         }
         doc.createPDF(ms);
     }
     else
     {
         using (ZipFile zip = new ZipFile())
         {
             foreach (Bitmap b in bs)
             {
                 using (MemoryStream mst = new MemoryStream())
                 {
                     ScanHandler.SaveImage(x, y, w, h, mst, b, false);
                     zip.AddEntry("" + count++ + ".png", mst.ToArray());
                 }
             }
             zip.Save(ms);
         }
     }
 }
    /// <summary>
    /// Exports the chart to the specified output stream as binary. When 
    /// exporting to a web response the WriteToHttpResponse() method is likely
    /// preferred.
    /// </summary>
    /// <param name="outputStream">An output stream.</param>
    internal void WriteToStream(Stream outputStream)
    {
      switch (this.ContentType)
      {
        case "image/jpeg":
          CreateSvgDocument().Draw().Save(
            outputStream,
            ImageFormat.Jpeg);
          break;

        case "image/png":
          // PNG output requires a seekable stream.
          using (MemoryStream seekableStream = new MemoryStream())
          {
            CreateSvgDocument().Draw().Save(
                seekableStream,
                ImageFormat.Png);
            seekableStream.WriteTo(outputStream);
          } 
          break;

        case "application/pdf":
          SvgDocument svgDoc = CreateSvgDocument();
          Bitmap bmp = svgDoc.Draw();

          pdfDocument doc = new pdfDocument(this.Name, null);
          pdfPage page = doc.addPage(bmp.Height, bmp.Width);
          page.addImage(bmp, 0, 0);
          doc.createPDF(outputStream);
          break;

        case "image/svg+xml":
          using (StreamWriter writer = new StreamWriter(outputStream))
          {
            writer.Write(this.Svg);
            writer.Flush();
          }

          break;

        default:
          throw new InvalidOperationException(string.Format(
            "ContentType '{0}' is invalid.", this.ContentType));
      }

      outputStream.Flush();
    }
Ejemplo n.º 8
0
        public void PrintPDF()
        {
            pdfDocument myDoc = new pdfDocument(this.title, this.author, false);
            pdfPage myFirstPage = myDoc.addPage();
            myFirstPage.addText(this.firstPageText, 100, 660, predefinedFont.csHelveticaOblique, 30, new pdfColor(predefinedColor.csCyan));

            /*Table's creation*/
            pdfTable myTable = new pdfTable();

            //Set table's border
            myTable.borderSize = 1;
            myTable.borderColor = new pdfColor(predefinedColor.csDarkBlue);

            CreateHeaderRow(myTable);

            /*Create table's rows*/
            pdfTableRow myRow = myTable.createRow();
            myRow[0].columnValue = "1";
            myRow[1].columnValue = "Andrew Red";
            myRow[2].columnValue = "898-0210989";
            myRow[3].columnValue = "*****@*****.**";
            myTable.addRow(myRow);

            myRow = myTable.createRow();
            myRow[0].columnValue = "2";
            myRow[1].columnValue = "Andrew Green";
            myRow[2].columnValue = "298-55109";
            myRow[3].columnValue = "*****@*****.**";
            myTable.addRow(myRow);

            myRow = myTable.createRow();
            myRow[0].columnValue = "3";
            myRow[1].columnValue = "Andrew White";
            myRow[2].columnValue = "24-5510943";
            myRow[3].columnValue = "*****@*****.**";

            /*Set Header's Style*/
            myTable.tableHeaderStyle = new pdfTableRowStyle(predefinedFont.csCourierBoldOblique, 12, new pdfColor(predefinedColor.csBlack), new pdfColor(predefinedColor.csLightCyan));

            /*Set Row's Style*/
            myTable.rowStyle = new pdfTableRowStyle(predefinedFont.csCourier, 8, new pdfColor(predefinedColor.csBlack), new pdfColor(predefinedColor.csWhite));

            /*Set Alternate Row's Style*/
            myTable.alternateRowStyle = new pdfTableRowStyle(predefinedFont.csCourier, 8, new pdfColor(predefinedColor.csBlack), new pdfColor(predefinedColor.csLightYellow));

            /*Set Cellpadding*/
            myTable.cellpadding = 20;

            /*Put the table on the page object*/
            myFirstPage.addTable(myTable, 100, 600);
            myTable = null;
            myDoc.createPDF(PDFName);
        }
        private void btnGeneratePDF_Click(object sender, EventArgs e)
        {
            // Si un employé est sélectionné
            if (this.dataEmployes.SelectedRows.Count > 0)
            {
                FolderBrowserDialog folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog();
                DialogResult result = folderBrowserDialog.ShowDialog();

                if (result == DialogResult.OK)
                {
                    IGestionEmployes
                    gestionEmployes = GestionEmployesBuilderClassFactory.getInterface();

                    string folderName = folderBrowserDialog.SelectedPath;
                    int selectedRowIndex = this.dataEmployes.SelectedRows[0].Index;
                    int IdUtilisateur = Convert.ToInt32(this.dataEmployes.Rows[selectedRowIndex].Cells["IdUtilisateur"].Value);
                    object[] tabInfoUser = gestionEmployes.findUtilisateur(IdUtilisateur);
                    Utilisateur utilisateur = (Utilisateur)tabInfoUser[0];
                    Adresse adresse = (Adresse)tabInfoUser[1];
                    Societe societe = (Societe)tabInfoUser[2];
                    Role role = (Role)tabInfoUser[3];
                    Ville ville = (Ville)tabInfoUser[4];
                    FormModificationEmploye form = new FormModificationEmploye();

                    // Génération du fichier PDF
                    try
                    {
                        pdfDocument myDoc = new pdfDocument("Sample Application", "Me", false);
                        pdfPage myFirstPage = myDoc.addPage(700, 700);
                        myFirstPage.addText("Fiche d'information - " + utilisateur.Prenom.Trim() + " " + utilisateur.Nom.Trim(),
                                            100, 630, predefinedFont.csHelvetica, 30, new pdfColor(predefinedColor.csBlack));
                        /*Table's creation*/
                        pdfTable myTable = new pdfTable();
                        //Set table's border
                        myTable.borderSize = 0;
                        myTable.borderColor = new pdfColor(predefinedColor.csBlack);
                        /*Create table's header*/
                        myTable.tableHeader.addColumn(new pdfTableColumn("Information", predefinedAlignment.csLeft, 150));
                        myTable.tableHeader.addColumn(new pdfTableColumn("Valeur", predefinedAlignment.csCenter, 250));

                        /*Create table's rows*/
                        pdfTableRow myRow = myTable.createRow();
                        myRow[0].columnValue = "Prénom";
                        myRow[1].columnValue = utilisateur.Prenom.Trim();
                        myTable.addRow(myRow);

                        myRow = myTable.createRow();
                        myRow[0].columnValue = "Nom";
                        myRow[1].columnValue = utilisateur.Nom.Trim();
                        myTable.addRow(myRow);

                        myRow = myTable.createRow();
                        myRow[0].columnValue = "Identifiant";
                        myRow[1].columnValue = utilisateur.Identifiant;
                        myTable.addRow(myRow);

                        myRow = myTable.createRow();
                        myRow[0].columnValue = "Mot de passe";
                        myRow[1].columnValue = utilisateur.MotPasse;
                        myTable.addRow(myRow);

                        myRow = myTable.createRow();
                        myRow[0].columnValue = "Rôle";
                        myRow[1].columnValue = role.CodeRole;
                        myTable.addRow(myRow);

                        myRow = myTable.createRow();
                        myRow[0].columnValue = "Date de début";
                        myRow[1].columnValue = utilisateur.DateDebut.ToShortDateString();
                        myTable.addRow(myRow);

                        myRow = myTable.createRow();
                        myRow[0].columnValue = "Date de fin";
                        myRow[1].columnValue = utilisateur.DateFin.ToShortDateString();
                        myTable.addRow(myRow);

                        myRow = myTable.createRow();
                        myRow[0].columnValue = "Adresse";
                        myRow[1].columnValue = adresse.NumeroRue + " " + adresse.NomRue + ", " + adresse.CodePostal + " " +
                                               ville.CodeVille;
                        myTable.addRow(myRow);

                        myRow = myTable.createRow();
                        myRow[0].columnValue = "Nom de société";
                        myRow[1].columnValue = societe.NomSociete;
                        myTable.addRow(myRow);

                        myRow = myTable.createRow();
                        myRow[0].columnValue = "Description de société";
                        myRow[1].columnValue = societe.DescriptionSociete;
                        myTable.addRow(myRow);

                        myRow = myTable.createRow();
                        myRow[0].columnValue = "Numéro de siret";
                        myRow[1].columnValue = societe.NumeroSiret;
                        myTable.addRow(myRow);

                        /*Set Header's Style*/
                        myTable.tableHeaderStyle = new pdfTableRowStyle(predefinedFont.csHelveticaBold, 12,
                                                   new pdfColor(predefinedColor.csWhite), new pdfColor(predefinedColor.csRed));
                        /*Set Row's Style*/
                        myTable.rowStyle = new pdfTableRowStyle(predefinedFont.csHelvetica, 10, new pdfColor(predefinedColor.csBlack),
                                           new pdfColor(predefinedColor.csWhite));
                        /*Set Alternate Row's Style*/
                        myTable.alternateRowStyle = new pdfTableRowStyle(predefinedFont.csHelvetica, 10,
                                                    new pdfColor(predefinedColor.csBlack), new pdfColor(predefinedColor.csLightGray));
                        /*Set Cellpadding*/
                        myTable.cellpadding = 10;
                        /*Put the table on the page object*/
                        myFirstPage.addTable(myTable, 150, 550);
                        myTable = null;
                        myDoc.createPDF(folderName + "\\FicheInformation.pdf");
                        MessageBox.Show("Le fichier PDF a bien été créé", "Génération de PDF");
                        Process.Start(folderName + "\\FicheInformation.pdf");
                        // Fin de génération du fichier PDF
                    }
                    // Quand il y a une erreur
                    catch (Exception exception)
                    {
                        MessageBox.Show("L'erreur suivante s'est produite : " + exception.Message + "", "Erreur lors de l'éxécution");
                    }
                }
            }
            // Si aucun employé n'est sélectionné
            else
            {
                MessageBox.Show("Sélectionnez un utilisateur.", "Génération fichier PDF");
            }
        }
Ejemplo n.º 10
0
        private void Main()
        {
            try
            {
                string source;
                using (var client = new WebClient())
                {
                    source = client.DownloadString("http://www.mangahit.com/" + CurrentChapter.Link);
                }
                _pages = int.Parse(Regex.Match(source, TotalRegex).Groups["pages"].Value);
                _link = Regex.Match(source, LinkRegex).Groups["link"].Value;
            }
            catch (Exception ex)
            {
                LogError("Error occured while gathering information.",ex.Message);
                goto DONE;
            }

            for (var page = 1; page <= _pages; page++)
            {
                download.Invoke(new Action<int, int>((current, total) =>
                    {
                        download.Text = string.Format("Downloading {0} of {1}", current, total);
                    }),page,_pages);
                var rTime = 0;
                RETRY:
                try
                {
                    if (!(Profile.Settings.Resume && File.Exists(GetPath(page))))
                    {

                        if (rTime <= Profile.Settings.Retries)
                        {
                            Http.Download(GetLink(page), GetPath(page));
                        }
                        else
                        {
                            LogError("Error occured while downloading the image","Unable to download within given number of retries.");
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogError("Error occured while downloading the image",ex.Message);
                    rTime++;
                    goto RETRY;
                }

                Invoke(new Action<int>(progress =>
                    {
                        Tag.Text = string.Format(ProgressFormat, CurrentChapter.Name, progress);
                        Text = string.Format(ProgressFormat, CurrentChapter.Name, progress);
                        progressBar.Value = progress;
                    }),(int)(((double)page/_pages)*100));
            }

            if (Profile.Settings.CreatePdf)
            {
                try
                {
                    using (var pdf=new pdfDocument(CurrentChapter.Name,"Abdullah Saleem"))
                    {
                        for (var page = 1; page <= _pages; page++)
                        {
                            var file = GetPath(page);

                            if (!File.Exists(file))
                            {
                                LogError("Error occured while creating the PDF","File not found.");
                                continue;
                            }

                            try
                            {
                                pdf.addImageReference(file, page.ToString("00"));
                                var refrenceImage = pdf.getImageReference(page.ToString("00"));
                                var currentPage = pdf.addPage(refrenceImage.height, refrenceImage.width);
                                currentPage.addImage(refrenceImage, 0, 0, refrenceImage.height, refrenceImage.width);
                            }
                            catch (Exception ex)
                            {
                                LogError("Error occured while creating the PDF[Internal]", ex.Message);
                            }
                        }
                        var pdfPath = Path.Combine(_directory, CurrentChapter.Name + ".pdf");
                        pdf.createPDF(pdfPath);
                        if (Profile.Settings.OpenPdf)
                        {
                            Process.Start(pdfPath);
                        }
                    }

                }
                catch (Exception ex)
                {
                    LogError("Error occured while creating the PDF", ex.Message);
                }
            }

            if (Profile.Settings.DeleteImages)
            {
                for (var page = 1; page <= _pages; page++)
                {
                    var file = GetPath(page);

                    if (!File.Exists(file))
                    {
                        LogError("Error occured while deleting the images","Image not found.");
                        continue;
                    }

                    try
                    {
                       File.Delete(file);
                    }
                    catch (Exception ex)
                    {
                        LogError("Error occured while deleting the images", ex.Message);
                    }
                }
            }
            DONE:
            Invoke(new MethodInvoker(Close));
        }
        private void onCreatePDFFile()
        {
            if (string.IsNullOrWhiteSpace(fileName))
            {
                NotifyWindow notifyWindow = new NotifyWindow("错误", "请先输入生成PDF文件名称!");
                notifyWindow.Show();
                return;
            }

            if (ImagesList.Count == 0)
            {
                NotifyWindow notifyWindow = new NotifyWindow("错误", "请先添加文件!");
                notifyWindow.Show();
                return;
            }

            pdfDocument doc = new pdfDocument(fileName, "", false);
            bool getIamge = false;
            foreach (AddImageEntity imageEntity in ImagesList)
            {
                try
                {
                    WriteableBitmap bitmap;
                    using (FileStream fs = new FileStream(imageEntity.FilePath, FileMode.Open))
                    {
                        BitmapImage bi = new BitmapImage();
                        bi.SetSource(fs);
                        bitmap = new WriteableBitmap(bi);
                    }

                    if (null != bitmap)
                    {
                        pdfPage page = doc.addPage((int)bitmap.PixelHeight, (int)bitmap.PixelWidth);
                        page.addImage(bitmap, 0, 0);
                        getIamge = true;
                        createPDFFileSuccess = true;
                    }
                    else
                    {
                        createPDFFileSuccess = false;
                    }
                }
                catch
                {
                    createPDFFileSuccess = false;

                    NotifyWindow notifyWindow = new NotifyWindow("错误", string.Format("打开图片文件{0}失败,请检查文件!!!", imageEntity.FilePath));
                    notifyWindow.Show();
                }

            }

            if (getIamge)
            {
                tempPDFFile = System.IO.Path.GetTempFileName();

                using (FileStream fs = new FileStream(tempPDFFile, FileMode.Create))
                {
                    doc.createPDF(fs);
                }

                UserFile = new UserFile();
                UserFile.FileName = fileName;
                UserFile.FileFolder = taxPayerEntity.TaxPayerId.ToString();
                UserFile.FileStream = (new FileInfo(tempPDFFile)).OpenRead();

                taxPayerDocumentEntity = new TaxPayerDocumentEntity();
                taxPayerDocumentEntity.TaxPayerDocumentBytes = UserFile.FileStream.Length;

                (OnUpdate as DelegateCommand).RaiseCanExecuteChanged();

                UpdateChanged("UserFile");
            }
        }