Exemple #1
0
        public string CreateRawPDFinTemp(Stone stone)
        {
            string filename = Path.Combine(Path.GetTempPath(), Path.GetFileNameWithoutExtension(stone.Filename) + ".pdf");

            Document document = this.CreateDocument();

            DefineStyles();
            PlaceImage(stone);

            PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true);

            // Set the MigraDoc document
            pdfRenderer.Document = document;

            // Create the PDF document
            pdfRenderer.RenderDocument();

               pdfRenderer.Save(filename);

               if (File.Exists(filename))
               {
               return filename;
               }
               else
               {
               return String.Empty;
               }

            // ...and start a viewer.
        }
Exemple #2
0
        public string CreatePDFFile(Stone stone)
        {
            string filename = stone.FullFilePath+".pdf";

            Document document = this.CreateDocument();

            DefineStyles();
            PlaceImage(stone);

            PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true);

            // Set the MigraDoc document
            pdfRenderer.Document = document;

            // Create the PDF document
            pdfRenderer.RenderDocument();

            SaveFileDialog savedlg = new SaveFileDialog();
            savedlg.DefaultExt = ".pdf";

               // Save the PDF document...
            if (savedlg.ShowDialog() == true)
            {
                filename = savedlg.FileName;
                pdfRenderer.Save(filename);
                Process.Start(filename);
                return filename;
            }
            else
            {
                return "";
            }

                    // ...and start a viewer.
        }
Exemple #3
0
        private void PlaceImage(Stone stone)
        {
            Section section = this.document.AddSection();

            //Table mainTable  = section.AddTable();
            //mainTable.Style = "Table";
            //mainTable.Borders.Color = new Color(81, 125, 192);
            //mainTable.Borders.Width = 0.25;
            //mainTable.Format.SpaceAfter = "5mm";

            //Column column = mainTable.AddColumn(Unit.FromMillimeter(170));
            //column.Format.Alignment = ParagraphAlignment.Center;

            ////column = mainTable.AddColumn("7cm");
            ////column.Format.Alignment = ParagraphAlignment.Center;

            //Row row2 = mainTable.AddRow();
            //row2.Format.Alignment = ParagraphAlignment.Center;
            //row2.Format.Font.Bold = true;

            Image image =  section.AddImage(stone.FullFilePath);
            image.Width = Unit.FromMillimeter(170);
            image.LockAspectRatio = true;

            //write the properties table

            TextFrame frame = section.AddTextFrame();

            frame.Left = ShapePosition.Center;
            frame.Top = "1cm";

            this.infopartTable = frame.AddTable();

               // this.infopartTable.Format.SpaceBefore = "10mm";
            this.infopartTable.Style = "Table";
            this.infopartTable.Borders.Color = new Color(81, 125, 192);
            this.infopartTable.Borders.Width = 0.25;
            this.infopartTable.BottomPadding = "2mm";
            this.infopartTable.LeftPadding = "2mm";
            this.infopartTable.RightPadding = "2mm";
            this.infopartTable.TopPadding = "2mm";

            Column column2 = this.infopartTable.AddColumn("3cm");
            column2.Format.Alignment = ParagraphAlignment.Center;

            column2 = this.infopartTable.AddColumn("2cm");
            column2.Format.Alignment = ParagraphAlignment.Center;

            foreach (var infopart in stone.InfoList)
            {
                  Row row = this.infopartTable.AddRow();

                  row.Cells[0].AddParagraph(infopart.TitleForReport);
                  row.Cells[0].Format.Font.Bold = true;
                  row.Cells[0].Format.Alignment = ParagraphAlignment.Left;
                  row.Cells[0].VerticalAlignment = VerticalAlignment.Bottom;

                  row.Cells[1].AddParagraph(infopart.Value);
                  row.Cells[1].Format.Font.Bold = false;
                  row.Cells[1].Format.Alignment = ParagraphAlignment.Left;
                  row.Cells[1].VerticalAlignment = VerticalAlignment.Bottom;

            }
        }
Exemple #4
0
        private void LoadDetailsByStone(Stone stone)
        {
            foreach (StackPanel panel in this.InfoPartsInputsContainer.Children)
            {
                if (panel.Children.OfType<TextBox>().SingleOrDefault() != null)
                {
                    string tag = (string) panel.Children.OfType<TextBox>().SingleOrDefault().Tag;
                    var value = stone.InfoList.Where(m => m.Title == tag).SingleOrDefault();
                    if (value != null)
                    {
                        panel.Children.OfType<TextBox>().SingleOrDefault().Text = value.Value;
                    }
                }
                else if (panel.Children.OfType<ComboBox>().SingleOrDefault() != null)
                {
                    string tag = (string) panel.Children.OfType<ComboBox>().SingleOrDefault().Tag;
                    var value = stone.InfoList.Where(m => m.Title == tag).SingleOrDefault();

                    if (value != null)
                    {
                        ComboBox combo = panel.Children.OfType<ComboBox>().SingleOrDefault();

                        combo.SelectedItem =
                            combo.Items.OfType<ComboBoxItem>().Where(m => (string) m.Tag == value.Value).Single();
                        //  = combo.Items.Count - 1;
                        //  combo.Items.OfType<ComboBoxItem>().Where(m => m.Tag == value.Value).Single().IsSelected = true;
                        //  combo.SelectedIndex = combo.Items.IndexOf(combo.Items.OfType<ComboBoxItem>().Where(m => m.Tag == value.Value).Single());
                    }
                }

                // string tag = (string)panel.Children.OfType<TextBox>().SingleOrDefault().Tag;

                //  var value = CurrentStone.InfoList.Where(m=> m.Title == tag).SingleOrDefault() ;

                //  if (value != null)
                // {
                //     panel.Children.OfType<TextBox>().SingleOrDefault().Text = value.Value;
            //}

                EditImage.Visibility = Visibility.Visible;
            }
        }