예제 #1
0
        public BlocoQrCodeNFC(DanfeViewModel viewModel, Estilo estilo, PrimitiveComposer primitiveComposer, float y, Document context) : base(estilo)
        {
            var result = new MemoryStream();

            primitiveComposer.BeginLocalState();
            primitiveComposer.SetFont(estilo.FonteCampoConteudo.FonteInterna, estilo.FonteCampoConteudo.Tamanho);
            primitiveComposer.ShowText("CONSULTA VIA LEITOR DE QR CODE", new PointF(140, y + 10), XAlignmentEnum.Center, YAlignmentEnum.Top, 0);

            var bitmap = GerarQrCode.GerarQRCode(viewModel.QrCode);

            bitmap.Save(result, ImageFormat.Jpeg);
            result.Position = 0;
            org.pdfclown.documents.contents.entities.Image   image        = org.pdfclown.documents.contents.entities.Image.Get(result);
            org.pdfclown.documents.contents.xObjects.XObject imageXObject = image.ToXObject(context);

            primitiveComposer.ShowXObject(imageXObject, new PointF(140, y + 20), new SizeF(150, 150), XAlignmentEnum.Center, YAlignmentEnum.Top, 0);

            if (viewModel.CalculoImposto.ValorAproximadoTributos > 0)
            // valor aproximado dos tributos
            {
                primitiveComposer.SetFont(estilo.FonteCampoConteudoNegrito.FonteInterna, 7);

                primitiveComposer.ShowText($"CONFORME LEI 12.741/2012 o valor aproximado dos tributos é {viewModel.CalculoImposto.ValorAproximadoTributos.Formatar()}", new PointF(140, y + 180), XAlignmentEnum.Center, YAlignmentEnum.Middle, 0);
                primitiveComposer.ShowText($"O valor aproximado dos tributos Federais é {viewModel.CalculoImposto.ValorAproximadoTributosFederais.Formatar()}", new PointF(140, y + 190), XAlignmentEnum.Center, YAlignmentEnum.Middle, 0);
                primitiveComposer.ShowText($"O valor aproximado dos tributos Estaduais é {viewModel.CalculoImposto.ValorAproximadoTributosEstaduais.Formatar()}", new PointF(140, y + 200), XAlignmentEnum.Center, YAlignmentEnum.Middle, 0);
            }
        }
예제 #2
0
        private org.pdfclown.documents.contents.xObjects.XObject GetJpegLogo(string path)
        {
            org.pdfclown.documents.contents.entities.Image img = org.pdfclown.documents.contents.entities.Image.Get(path);

            if (img == null)
            {
                throw new Exception("O logotipo não pode ser carregado.");
            }

            var logo = img.ToXObject(this.Document);

            return(logo);
        }
예제 #3
0
        private void createPDF()
        {
            SaveFileDialog saveFileDialog2 = new SaveFileDialog();

            saveFileDialog2.Filter   = "PDF File|*.pdf";
            saveFileDialog2.Title    = "Save as PDF";
            saveFileDialog2.FileName = "" + profile.fname + " " + profile.sname + " 6CIT Results";

            File     file     = new File();
            Document document = file.Document;
            Page     page     = new Page(document);

            document.Pages.Add(page);

            PrimitiveComposer Composer = new PrimitiveComposer(page);

            Composer.SetLineWidth(200);

            //Image
            Image image = Image.Get("brain100.jpg");

            org.pdfclown.documents.contents.xObjects.XObject imageXObject = image.ToXObject(document);
            Composer.ShowXObject(imageXObject, new PointF(450, 40));
            Composer.Flush();

            //Title
            Composer.SetFont(new StandardType1Font(document, StandardType1Font.FamilyEnum.Helvetica, true, false), 32);
            Composer.ShowText("6CIT Results", new PointF(32, 40));

            //Heading 1
            Composer.SetFont(new StandardType1Font(document, StandardType1Font.FamilyEnum.Helvetica, true, false), 24);
            Composer.ShowText("Patient Details", new PointF(32, 100));

            //Heading 1 - Body
            Composer.SetFont(new StandardType1Font(document, StandardType1Font.FamilyEnum.Helvetica, true, false), 12);
            Composer.ShowText("NHS ID: " + profile.ID, new PointF(32, 140));
            Composer.ShowText("Name: " + profile.fname + " " + profile.sname, new PointF(32, 160));
            Composer.ShowText("Sex: " + profile.sex, new PointF(32, 180));
            Composer.ShowText("DOB: " + profile.DOB, new PointF(32, 200));
            Composer.ShowText("Address: " + profile.al1 + " " + profile.al2, new PointF(32, 220));
            Composer.ShowText("Postcode: " + profile.postcode, new PointF(32, 240));
            Composer.ShowText("Occupation: " + profile.occupation, new PointF(32, 260));
            Composer.ShowText("Test Score: " + score + " , Advice: " + calcAdvice(score), new PointF(32, 300));


            //Patient Notes
            BlockComposer bc = new BlockComposer(Composer);

            bc.Hyphenation = false;
            bc.LineSpace   = new Length(1.0, Length.UnitModeEnum.Relative);

            int notesLength = profile.notes.Length;
            int notesHeight = 40;
            int notesY      = 320;

            if (notesLength < 300)
            {
                notesHeight = 150;
            }
            else if (notesLength > 300 && notesLength < 600)
            {
                notesHeight = 200;
            }
            else if (notesLength > 600 && notesLength <= 1000)
            {
                notesHeight = 350;
            }

            RectangleF area = new RectangleF(new PointF(32, notesY), new SizeF(400, notesHeight));

            bc.Begin(area, XAlignmentEnum.Left, YAlignmentEnum.Top);
            bc.ShowText("Notes: " + "\n" + profile.notes);
            bc.End();

            Composer.Flush();

            var date = DateTime.Now;

            //Add Page 2
            Page page2 = new Page(document);

            document.Pages.Add(page2);
            Composer = new PrimitiveComposer(page2);

            //Heading 2
            Composer.SetFont(new StandardType1Font(document, StandardType1Font.FamilyEnum.Helvetica, true, false), 24);
            Composer.ShowText("6CIT Results ", new PointF(32, 40));

            Composer.SetFont(new StandardType1Font(document, StandardType1Font.FamilyEnum.Helvetica, true, false), 12);
            Composer.ShowText("Test Carried out on: " /*+ Clinician Details Input Get*/ + " on: " + date, new PointF(32, 80));

            //Convert Question Answers to Temporary Text
            string six_q1_txt = "Incorrect";
            string six_q2_txt = "Incorrect";
            string six_q3_txt = "Incorrect";
            string six_q4_txt = "Incorrect";
            string six_q5_txt = "Incorrect";
            string six_q6_txt;

            if (q1 == 0)
            {
                six_q1_txt = "Correct";
            }
            if (q2 == 0)
            {
                six_q2_txt = "Correct";
            }
            if (q3 == 0)
            {
                six_q3_txt = "Correct";
            }

            //Q4
            if (q4 == 0)
            {
                six_q4_txt = "Correct";
            }
            else if (q4 == 4)
            {
                six_q4_txt = "More Than One Incorrect";
            }

            //Q5
            if (q5 == 0)
            {
                six_q5_txt = "Correct";
            }
            else if (q5 == 2)
            {
                six_q5_txt = "One Incorrect";
            }
            else if (q5 == 4)
            {
                six_q5_txt = "More Than One Incorrect";
            }

            //Q6
            if (q6 == 0)
            {
                six_q6_txt = "Correct";
            }
            else if (q6 == 2)
            {
                six_q6_txt = "One Incorrect";
            }
            else if (q6 == 4)
            {
                six_q6_txt = "More Than One Incorrect";
            }
            else if (q6 == 6)
            {
                six_q6_txt = "More Than Two Incorrect";
            }
            else if (q6 == 8)
            {
                six_q6_txt = "More Than Three Incorrect";
            }
            else if (q6 == 10)
            {
                six_q6_txt = "More Than Four Incorrect";
            }
            else
            {
                six_q6_txt = "All Incorrect";
            }

            Composer.ShowText("Question 1: What Year Is It? : ", new PointF(32, 120));
            Composer.ShowText(six_q1_txt, new PointF(32, 140));

            Composer.ShowText("Question 2: What Month Is It? : ", new PointF(32, 180));
            Composer.ShowText(six_q2_txt, new PointF(32, 200));

            Composer.ShowText("Question 3: What Time Is It? : ", new PointF(32, 240));
            Composer.ShowText(six_q3_txt, new PointF(32, 260));

            Composer.ShowText("Question 4: Count Backwards From 20 to 1: ", new PointF(32, 300));
            Composer.ShowText(six_q4_txt, new PointF(32, 320));

            Composer.ShowText("Question 5: Say The Months of the Year Backwards: ", new PointF(32, 360));
            Composer.ShowText(six_q5_txt, new PointF(32, 380));

            Composer.ShowText("Question 6: Repeat the Memory Phrase: ", new PointF(32, 420));
            Composer.ShowText(six_q6_txt, new PointF(32, 440));

            Composer.ShowText("Test Result was:  " + score, new PointF(32, 480));
            Composer.ShowText("Advice: " + calcAdvice(score), new PointF(32, 500));

            Composer.Flush();

            if (saveFileDialog2.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    file.Save(saveFileDialog2.FileName, SerializationModeEnum.Incremental);
                }
                catch (IOException)
                {
                    MessageBox.Show("File is open somewhere else; Cannot Save to PDF.");
                }
            }
        }