Exemplo n.º 1
0
        private void OnExportClick(object sender, RoutedEventArgs e)
        {
            var dialog = new SaveFileDialog
            {
                DefaultExt = "pdf",
                Filter = "Diagram files|*.pdf|All Files (*.*)|*.*",
#if WPF
				FileName = "Diagram.pdf"
#else
                DefaultFileName = "Diagram.pdf"
#endif
            };
            if (dialog.ShowDialog() == true)
            {
                var enclosingBounds = this.diagram.CalculateEnclosingBounds();
                enclosingBounds = enclosingBounds.InflateRect(30);

                RadFixedDocument document = new RadFixedDocument();
                document.Pages.Add(ExportHelper.ExportDiagram(this.diagram, enclosingBounds));

                PdfFormatProvider provider = new PdfFormatProvider();
                using (var output = dialog.OpenFile())
                {
                    provider.Export(document, output);
                }
            }
        }
    }
Exemplo n.º 2
0
        private void UsingRadFixedDocumentEditor(RadFixedDocument document)
        {
            #region radpdfprocessing-editing-table_6
            Table table = new Table();

            Border border = new Border();
            table.Borders = new TableBorders(border);
            table.DefaultCellProperties.Borders = new TableCellBorders(border, border, border, border);

            table.BorderSpacing  = 5;
            table.BorderCollapse = BorderCollapse.Separate;

            TableRow row = table.Rows.AddTableRow();
            row.Cells.AddTableCell().Blocks.AddBlock().InsertText("First cell");
            row.Cells.AddTableCell().Blocks.AddBlock().InsertText("Second cell");
            #endregion

            #region radpdfprocessing-editing-table_7
            RadFixedDocumentEditor editor = new RadFixedDocumentEditor(document);
            editor.TableProperties.LayoutType = TableLayoutType.AutoFit;
            editor.InsertTable(table);
            #endregion

            #region radpdfprocessing-editing-table_8
            editor.TableProperties.LayoutType = TableLayoutType.FixedWidth;
            editor.InsertTable(table);
            #endregion
        }
Exemplo n.º 3
0
        private void OnExportClick(object sender, RoutedEventArgs e)
        {
            var dialog = new SaveFileDialog
            {
                DefaultExt = "pdf",
                Filter     = "Diagram files|*.pdf|All Files (*.*)|*.*",
#if WPF
                FileName = "Diagram.pdf"
#else
                DefaultFileName = "Diagram.pdf"
#endif
            };

            if (dialog.ShowDialog() == true)
            {
                var enclosingBounds = this.diagram.CalculateEnclosingBounds();
                enclosingBounds = enclosingBounds.InflateRect(30);

                RadFixedDocument document = new RadFixedDocument();
                document.Pages.Add(ExportHelper.ExportDiagram(this.diagram, enclosingBounds));

                PdfFormatProvider provider = new PdfFormatProvider();
                using (var output = dialog.OpenFile())
                {
                    provider.Export(document, output);
                }
            }
        }
    }
Exemplo n.º 4
0
 private void CreateAndAddPagesToFixedDocument(RadFixedDocument document)
 {
     #region radpdfprocessing-model-radfixeddocument_2
     RadFixedPage page = new RadFixedPage();
     document.Pages.Add(page);
     #endregion
 }
        public RadFixedDocument CreateDocument()
        {
            RadFixedDocument document = new RadFixedDocument();
            RadFixedPage page = document.Pages.AddPage();
            page.Size = new Size(600, 800);
            this.editor = new FixedContentEditor(page);
            this.editor.Position.Translate(40, 50);
            using (Stream stream = FileHelper.GetSampleResourceStream("banner.png"))
            {
                ImageSource imageSource = new ImageSource(stream, ImageQuality.High);
                editor.DrawImage(imageSource, new Size(530, 80));
            }

            editor.Position.Translate(ExampleDocumentSizes.DefaultLeftIndent, 160);
            double maxWidth = page.Size.Width - ExampleDocumentSizes.DefaultLeftIndent * 2;

            this.DrawDescription(maxWidth);

            using (editor.SaveProperties())
            {
                using (editor.SavePosition())
                {
                    this.DrawFunnelFigure();
                }
            }

            return document;
        }
Exemplo n.º 6
0
 private static void ImportDocument(string inputDocumentFile)
 {
     using (Stream stream = File.OpenRead(inputDocumentFile))
     {
         document = formatProvider.Import(stream);
     }
 }
        private RadFixedDocument CreateDocument()
        {
            RadFixedDocument document = new RadFixedDocument();
            RadFixedPage page = document.Pages.AddPage();
            page.Size = new Size(600, 750);
            FixedContentEditor editor = new FixedContentEditor(page);
            editor.Position.Translate(defaultLeftIndent, 50);
            using (Stream stream = FileHelper.GetSampleResourceStream("pdfProcessingSilverlight.jpg"))
            {
                editor.DrawImage(stream);
            }
            double currentTopOffset = 110;
            editor.Position.Translate(defaultLeftIndent, currentTopOffset);
            editor.TextProperties.FontSize = 14;
            double maxWidth = page.Size.Width - defaultLeftIndent * 2;

            this.DrawDescription(editor, maxWidth);

            currentTopOffset += defaultLineHeight * 4;
            editor.Position.Translate(defaultLeftIndent, currentTopOffset);
            using (editor.SaveProperties())
            {
                this.DrawFunnelFigure(editor);
            }

            editor.Position.Translate(defaultLeftIndent * 4, page.Size.Height - 100);
            using (Stream stream = FileHelper.GetSampleResourceStream("telerik.jpg"))
            {
                editor.DrawImage(stream);
            }

            this.DrawText(editor, maxWidth);

            return document;
        }
Exemplo n.º 8
0
        private void ExportPdf(object sender, RoutedEventArgs e)
        {
            //export the combined PDF
            SaveFileDialog dialog = new SaveFileDialog()
            {
                DefaultExt  = "pdf",
                Filter      = String.Format("{1} files (*.{0})|*.{0}|All files (*.*)|*.*", "pdf", "Pdf"),
                FilterIndex = 1
            };

            if (dialog.ShowDialog() == true)
            {
                //export the data from the two RadGridVies instances in separate documents
                RadFixedDocument playersDoc = this.playersGrid.ExportToRadFixedDocument();
                RadFixedDocument clubsDoc   = this.clubsGrid.ExportToRadFixedDocument();

                //merge the second document into the first one
                playersDoc.Merge(clubsDoc);

                using (Stream stream = dialog.OpenFile())
                {
                    new PdfFormatProvider().Export(playersDoc, stream);
                }
            }
        }
Exemplo n.º 9
0
        private static RadFixedDocument ImportDocument(string fileName)
        {
            PdfFormatProvider provider = new PdfFormatProvider();
            RadFixedDocument  document = provider.Import(File.ReadAllBytes(fileName));

            return(document);
        }
Exemplo n.º 10
0
        private static void Main(string[] args)
        {
            PdfFormatProvider provider = new PdfFormatProvider();

            RadFixedDocument document = provider.Import(File.ReadAllBytes(InputFileWithInteractiveForms));

            ModifyFormFieldValues(document);

            string modifiedFileName = "Modified.pdf";

            if (File.Exists(modifiedFileName))
            {
                File.Delete(modifiedFileName);
            }

            File.WriteAllBytes(modifiedFileName, provider.Export(document));

            ProcessStartInfo psi = new ProcessStartInfo()
            {
                FileName        = modifiedFileName,
                UseShellExecute = true
            };

            Process.Start(psi);
        }
        /// <summary>
        /// Creates a same RadFixedDocument using details text from uploaded content
        /// </summary>
        /// <param name="value">the content to use</param>
        /// <returns>FixedDocument that can be exported asa PDF file</returns>
        private static RadFixedDocument GenerateSampleDocument(MyPdfContent value)
        {
            double defaultLeftIndent = 50;
            double defaultLineHeight = 16;

            var document = new RadFixedDocument();
            var page     = document.Pages.AddPage();

            page.Size = PageSize;

            var editor = new FixedContentEditor(page);

            editor.Position.Translate(defaultLeftIndent, 50);

            double currentTopOffset = 110;

            editor.Position.Translate(defaultLeftIndent, currentTopOffset);
            double maxWidth = page.Size.Width - defaultLeftIndent * 2;

            DocumentHelpers.DrawDescription(editor, maxWidth);

            currentTopOffset += defaultLineHeight * 4;
            editor.Position.Translate(defaultLeftIndent, currentTopOffset);

            using (editor.SaveProperties())
            {
                DocumentHelpers.DrawFunnelFigure(editor);
            }

            // use the uploaded text
            DocumentHelpers.DrawText(editor, maxWidth, value);

            return(document);
        }
Exemplo n.º 12
0
        private byte[] CreateDocument()
        {
            RadFixedDocument document = new RadFixedDocument();

            byte[]           resourceBytes = ResourceHelper.GetResourceBytes("Resources/rgb.jpg");
            EncodedImageData rgbJpeg       = new EncodedImageData(resourceBytes, 8, 655, 983, ColorSpaceNames.DeviceRgb, new string[] { PdfFilterNames.DCTDecode });

            this.CreatePageWithImage(document, "JPEG", rgbJpeg);

            resourceBytes = ResourceHelper.GetResourceBytes("Resources/grayScale.jpg");
            EncodedImageData jpeg2000Gray = new EncodedImageData(resourceBytes, 8, 655, 983, ColorSpaceNames.DeviceGray, new string[] { PdfFilterNames.DCTDecode });

            this.CreatePageWithImage(document, "JPEG", jpeg2000Gray);

            resourceBytes = ResourceHelper.GetResourceBytes("Resources/rgb.jp2");
            EncodedImageData rgbJpc = new EncodedImageData(resourceBytes, 8, 655, 983, ColorSpaceNames.DeviceRgb, new string[] { PdfFilterNames.JPXDecode });

            this.CreatePageWithImage(document, "JPEG 2000", rgbJpc);

            resourceBytes = ResourceHelper.GetResourceBytes("Resources/grayScale.jp2");
            EncodedImageData grayScaleJpc = new EncodedImageData(resourceBytes, 8, 655, 983, ColorSpaceNames.DeviceGray, new string[] { PdfFilterNames.JPXDecode });

            this.CreatePageWithImage(document, "JPEG 2000", grayScaleJpc);

            if (File.Exists(TestFileName))
            {
                File.Delete(TestFileName);
            }

            byte[] documentBytes = new PdfFormatProvider().Export(document);

            return(documentBytes);
        }
        /// <summary>
        /// Creates a RadFixedDocument using an image from uploaded content
        /// </summary>
        /// <param name="value">the content to use</param>
        /// <returns>FixedDocument that can be exported asa PDF file</returns>
        private static RadFixedDocument GenerateImageDocument(MyPdfContent value)
        {
            // Load the image data into an ImageSource object
            Telerik.Windows.Documents.Fixed.Model.Resources.ImageSource imageSource;

            using (var imgStream = new MemoryStream(Convert.FromBase64String(value.ImageBase64)))
            {
                imageSource = new Telerik.Windows.Documents.Fixed.Model.Resources.ImageSource(imgStream);
            }

            // instantiate the document and add a page
            var document = new RadFixedDocument();
            var page     = document.Pages.AddPage();

            page.Size = PageSize;

            // instantiate an editor, this is what writes all the content to the page
            var editor = new FixedContentEditor(page);

            editor.GraphicProperties.StrokeThickness = 0;
            editor.GraphicProperties.IsStroked       = false;

            try
            {
                // use the uploaded value for background color
                var bgColor = (Color)ColorConverter.ConvertFromString(value.BackgroundColor);
                editor.GraphicProperties.FillColor = new RgbColor(bgColor.R, bgColor.G, bgColor.B);
            }
            catch
            {
                editor.GraphicProperties.FillColor = new RgbColor(255, 255, 255);
            }

            editor.DrawRectangle(new Rect(0, 0, PageSize.Width, PageSize.Height));
            editor.Position.Translate(Margins.Left, Margins.Top);

            // Description text
            var block = new Block();

            block.HorizontalAlignment     = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.HorizontalAlignment.Center;
            block.TextProperties.FontSize = 22;

            // use the uploaded content for the title
            block.InsertText(value.Title);

            var blockSize = block.Measure(RemainingPageSize);

            editor.DrawBlock(block, RemainingPageSize);

            editor.Position.Translate(Margins.Left, blockSize.Height + Margins.Top + 20);

            // NOTE - This is where the ImageSource is used and drawn onto the document
            var imageBlock = new Block();

            imageBlock.HorizontalAlignment = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.HorizontalAlignment.Center;
            imageBlock.InsertImage(imageSource);
            editor.DrawBlock(imageBlock, RemainingPageSize);

            return(document);
        }
        public DocumentGenerator(ImageQuality imageQuality)
        {
            this.imageQuality = imageQuality;
            this.document     = new RadFixedDocument();

            this.GenerateDocumentContent();
        }
Exemplo n.º 15
0
        private void CreatePageWithImage(RadFixedDocument document, string imageExtension, EncodedImageData imageData)
        {
            RadFixedPage page = document.Pages.AddPage();

            page.Size = PageSize;
            FixedContentEditor editor = new FixedContentEditor(page);

            editor.Position.Translate(Margins.Left, Margins.Top);

            Block block = new Block();

            block.HorizontalAlignment     = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.HorizontalAlignment.Center;
            block.TextProperties.FontSize = 22;
            block.InsertText(string.Format("This is {0} image in {1} color space encoded with {2} filter.", imageExtension, imageData.ColorSpace, imageData.Filters.FirstOrDefault() ?? "None"));
            Size blockSize = block.Measure(RemainingPageSize);

            editor.DrawBlock(block, RemainingPageSize);

            editor.Position.Translate(Margins.Left, blockSize.Height + Margins.Top + 50);

            Block imageBlock = new Block();

            imageBlock.HorizontalAlignment = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.HorizontalAlignment.Center;
            imageBlock.InsertImage(new ImageSource(imageData), new Size(imageData.Width, imageData.Height));
            editor.DrawBlock(imageBlock, RemainingPageSize);
        }
Exemplo n.º 16
0
        private byte[] CreateDocument()
        {
            RadFixedDocument document = new RadFixedDocument();

            byte[] resourceBytes = ResourceHelper.GetResourceBytes("Resources/rgb.jpg");
            EncodedImageData rgbJpeg = new EncodedImageData(resourceBytes, 8, 655, 983, ColorSpaceNames.DeviceRgb, new string[] { PdfFilterNames.DCTDecode });
            this.CreatePageWithImage(document, "JPEG", rgbJpeg);

            resourceBytes = ResourceHelper.GetResourceBytes("Resources/grayScale.jpg");
            EncodedImageData jpeg2000Gray = new EncodedImageData(resourceBytes, 8, 655, 983, ColorSpaceNames.DeviceGray, new string[] { PdfFilterNames.DCTDecode });
            this.CreatePageWithImage(document, "JPEG", jpeg2000Gray);

            resourceBytes = ResourceHelper.GetResourceBytes("Resources/rgb.jp2");
            EncodedImageData rgbJpc = new EncodedImageData(resourceBytes, 8, 655, 983, ColorSpaceNames.DeviceRgb, new string[] { PdfFilterNames.JPXDecode });
            this.CreatePageWithImage(document, "JPEG 2000", rgbJpc);

            resourceBytes = ResourceHelper.GetResourceBytes("Resources/grayScale.jp2");
            EncodedImageData grayScaleJpc = new EncodedImageData(resourceBytes, 8, 655, 983, ColorSpaceNames.DeviceGray, new string[] { PdfFilterNames.JPXDecode });
            this.CreatePageWithImage(document, "JPEG 2000", grayScaleJpc);

            if (File.Exists(TestFileName))
            {
                File.Delete(TestFileName);
            }

            byte[] documentBytes = new PdfFormatProvider().Export(document);

            return documentBytes;
        }
Exemplo n.º 17
0
        public RadFixedDocument CreateDocument()
        {
            RadFixedDocument document = new RadFixedDocument();
            RadFixedPage     page     = document.Pages.AddPage();

            page.Size   = new Size(600, 800);
            this.editor = new FixedContentEditor(page);
            this.editor.Position.Translate(40, 50);

            using (Stream stream = this.resourceService.GetResourceStream("banner.jpg"))
            {
                this.editor.DrawImage(stream, new Size(530, 80));
            }

            this.editor.Position.Translate(ExampleDocumentSizes.DefaultLeftIndent, 160);
            double maxWidth = page.Size.Width - ExampleDocumentSizes.DefaultLeftIndent * 2;

            this.DrawDescription(maxWidth);

            using (this.editor.SaveProperties())
            {
                using (this.editor.SavePosition())
                {
                    this.DrawFunnelFigure();
                }
            }

            return(document);
        }
Exemplo n.º 18
0
        public void Export(string filePath)
        {
            PdfFormatProvider formatProvider = new PdfFormatProvider();

            formatProvider.ExportSettings.ImageQuality = ImageQuality.High;

            string resultFile = System.IO.Path.Combine(filePath, this.defaultDocumentName);

            this.PrepareDirectory(filePath, resultFile);

            using (FileStream stream = File.OpenWrite(resultFile))
            {
                RadFixedDocument document = this.CreateDocument();
                formatProvider.Export(document, stream);
            }

            Console.WriteLine("The document is generated.");

            ProcessStartInfo psi = new ProcessStartInfo()
            {
                FileName        = resultFile,
                UseShellExecute = true
            };

            Process.Start(psi);
        }
Exemplo n.º 19
0
        public DocumentGenerator(ImageSource imageSource, ImageQuality imageQuality)
        {
            this.imageSource  = imageSource;
            this.imageQuality = imageQuality;
            this.document     = new RadFixedDocument();

            this.AddPageWithImage();
        }
Exemplo n.º 20
0
 private void CreateRadFixedPage()
 {
     #region radpdfprocessing-model-radfixedpage_0
     RadFixedDocument document = new RadFixedDocument();
     RadFixedPage     page     = new RadFixedPage();
     document.Pages.Add(page);
     #endregion
 }
Exemplo n.º 21
0
        private static RadFixedDocument CreateDocument()
        {
            RadFixedDocument document = new RadFixedDocument();

            CreateFields(document);
            DrawPageWithWidgets(document);

            return(document);
        }
Exemplo n.º 22
0
        private RadFixedDocument CreateDocument(System.Windows.Controls.Border element)
        {
            RadFixedDocument document = new RadFixedDocument();

            RadFixedPage page = this.CreatePage(element);
            document.Pages.Add(page);

            return document;
        }
Exemplo n.º 23
0
        private void SaveDocumentAsPdf(RadFixedDocument document, string fileName)
        {
            PdfFormatProvider provider = new PdfFormatProvider();

            using (Stream output = File.OpenWrite(fileName))
            {
                provider.Export(document, output);
            }
        }
Exemplo n.º 24
0
        public static void ExportToPagedFile(FrameworkElement element, Stream stream, bool lanscaped)
        {
            RadFixedDocument  document = PDFExportHelper.CreatePagedDocument(element, lanscaped);
            PdfFormatProvider provider = new PdfFormatProvider {
                ExportSettings = { ImageQuality = ImageQuality.High }
            };

            provider.Export(document, stream);
        }
Exemplo n.º 25
0
        private static void CreateFields(RadFixedDocument document)
        {
            CheckBoxField check = new CheckBoxField("checkBox");

            document.AcroForm.FormFields.Add(check);
            check.IsChecked = true;

            ComboBoxField combo = new ComboBoxField("combo");

            document.AcroForm.FormFields.Add(combo);
            combo.Options.Add(new ChoiceOption("Combo choice 1"));
            combo.Options.Add(new ChoiceOption("Combo choice 2"));
            combo.Options.Add(new ChoiceOption("Combo choice 3"));
            combo.Options.Add(new ChoiceOption("Combo choice 4"));
            combo.Options.Add(new ChoiceOption("Combo choice 5"));
            combo.Value = combo.Options[2];

            CombTextBoxField comb = new CombTextBoxField("comb");

            document.AcroForm.FormFields.Add(comb);
            comb.MaxLengthOfInputCharacters = 10;
            comb.Value = "0123456789";

            ListBoxField list = new ListBoxField("list");

            document.AcroForm.FormFields.Add(list);
            list.AllowMultiSelection = true;
            list.Options.Add(new ChoiceOption("List choice 1"));
            list.Options.Add(new ChoiceOption("List choice 2"));
            list.Options.Add(new ChoiceOption("List choice 3"));
            list.Options.Add(new ChoiceOption("List choice 4"));
            list.Options.Add(new ChoiceOption("List choice 5"));
            list.Options.Add(new ChoiceOption("List choice 6"));
            list.Options.Add(new ChoiceOption("List choice 7"));
            list.Value = new ChoiceOption[] { list.Options[0], list.Options[2] };

            PushButtonField push = new PushButtonField("push");

            document.AcroForm.FormFields.Add(push);

            RadioButtonField radio = new RadioButtonField("radio");

            document.AcroForm.FormFields.Add(radio);
            radio.Options.Add(new RadioOption("Radio option 1"));
            radio.Options.Add(new RadioOption("Radio option 2"));
            radio.Value = radio.Options[1];

            SignatureField signature = new SignatureField("signiture");

            document.AcroForm.FormFields.Add(signature);

            TextBoxField textBox = new TextBoxField("textBox");

            document.AcroForm.FormFields.Add(textBox);
            textBox.Value = "Sample text...";
        }
Exemplo n.º 26
0
        public MainViewModel()
        {
            this.document           = new RadFixedDocument();
            this.provider           = new PdfFormatProvider();
            this.saveFileCommand    = new DelegateCommand((parameter) => SaveFile());
            this.imageQualityValues = new ObservableCollection <ImageQuality>();
            this.InitializeImageQualityValues();

            this.GenerateDocumentContent();
        }
Exemplo n.º 27
0
        private RadFixedDocument CreateDocument(RadPivotGrid element)
        {
            RadFixedDocument document = new RadFixedDocument();

            RadFixedPage page = this.CreatePage(element);

            document.Pages.Add(page);

            return(document);
        }
Exemplo n.º 28
0
        public MainViewModel()
        {
            this.document = new RadFixedDocument();
            this.provider = new PdfFormatProvider();
            this.saveFileCommand = new DelegateCommand((parameter) => SaveFile());
            this.imageQualityValues = new ObservableCollection<ImageQuality>();
            this.InitializeImageQualityValues();

            this.GenerateDocumentContent();
        }
Exemplo n.º 29
0
        private void CreateRadFixedDocumentEditor(RadFixedDocument radFixedDocument, FontFamily fontFamily)
        {
            #region radpdfprocessing-editing-radfixeddocumenteditor_0
            RadFixedDocumentEditor editor = new RadFixedDocumentEditor(radFixedDocument);
            #endregion

            #region radpdfprocessing-editing-radfixeddocumenteditor_1
            editor.InsertSectionBreak();
            #endregion
        }
Exemplo n.º 30
0
        static void Main()
        {
            RadFixedDocument document = Program.ImportDocument("BlueTemplate.pdf");
            RadFixedPage     page     = document.Pages.First();

            Program.DeleteTextFragment(page, "This is the blue template!");
            Program.AddWatermarkText(page, "Watermark text!", 100);

            Program.ExportAndViewPdf(document, "testWatermarks.pdf");
        }
Exemplo n.º 31
0
        public static RadFixedDocument CreateDocument(FrameworkElement element)
        {
            RadFixedDocument document = new RadFixedDocument();

            RadFixedPage page = CreatePage(element);

            document.Pages.Add(page);

            return(document);
        }
        private RadFixedDocument CreateDocument(System.Windows.Controls.Border element)
        {
            RadFixedDocument document = new RadFixedDocument();

            RadFixedPage page = this.CreatePage(element);

            document.Pages.Add(page);

            return(document);
        }
Exemplo n.º 33
0
 private void Import()
 {
     #region radpdfprocessing-formats-and-conversion-pdf-pdfformatprovider_0
     PdfFormatProvider provider = new PdfFormatProvider();
     using (Stream input = File.OpenRead("Sample.pdf"))
     {
         RadFixedDocument document = provider.Import(input);
     }
     #endregion
 }
Exemplo n.º 34
0
 private void Export()
 {
     #region radpdfprocessing-formats-and-conversion-pdf-pdfformatprovider_1
     PdfFormatProvider provider = new PdfFormatProvider();
     using (Stream output = File.OpenWrite("sample.pdf"))
     {
         RadFixedDocument document = CreateRadFixedDocument();
         provider.Export(document, output);
     }
     #endregion
 }
Exemplo n.º 35
0
        private void OpenFile(Stream stream)
        {
            using (stream)
            {
                PdfFormatProvider pdfFormatProvider = new PdfFormatProvider();
                pdfFormatProvider.ImportSettings = PdfImportSettings.ReadOnDemand;
                RadFixedDocument document = pdfFormatProvider.Import(stream);

                this.pdfViewer.Document = document;
            }
        }
Exemplo n.º 36
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            RadFixedDocument document = new RadFixedDocument();
            FixedContentEditor editor = new FixedContentEditor(document.Pages.AddPage());
            editor.DrawText("Hello PdfProcessing!");

            PdfFormatProvider provider = new PdfFormatProvider();
            MemoryStream stream = new MemoryStream();
            provider.Export(document, stream);

            this.ViewModel.DocumentStream = stream;
        }
Exemplo n.º 37
0
        private async Task <RadFixedDocument> GenerateSampleDocument <T>(IQueryable <T> data, DataSourceRequest gridRequest)
        {
            var table = await CreateTable <T>(data, gridRequest);

            var document = new RadFixedDocument();

            using var editor = new RadFixedDocumentEditor(document);

            editor.InsertTable(table);

            return(await Task.FromResult(document));
        }
Exemplo n.º 38
0
        private void CreatePageWithImage(RadFixedDocument document, string imageExtension, EncodedImageData imageData)
        {
            RadFixedPage page = document.Pages.AddPage();
            page.Size = PageSize;
            FixedContentEditor editor = new FixedContentEditor(page);
            editor.Position.Translate(Margins.Left, Margins.Top);

            Block block = new Block();
            block.HorizontalAlignment = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.HorizontalAlignment.Center;
            block.TextProperties.FontSize = 22;
            block.InsertText(string.Format("This is {0} image in {1} color space encoded with {2} filter.", imageExtension, imageData.ColorSpace, imageData.Filters.FirstOrDefault() ?? "None"));
            Size blockSize = block.Measure(RemainingPageSize);
            editor.DrawBlock(block, RemainingPageSize);

            editor.Position.Translate(Margins.Left, blockSize.Height + Margins.Top + 50);

            Block imageBlock = new Block();
            imageBlock.HorizontalAlignment = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.HorizontalAlignment.Center;
            imageBlock.InsertImage(new ImageSource(imageData), new Size(imageData.Width, imageData.Height));
            editor.DrawBlock(imageBlock, RemainingPageSize);
        }
Exemplo n.º 39
0
        private byte[] CreateDocument()
        {
            RadFixedDocument document = new RadFixedDocument();

            byte[] resourceBytes = ResourceHelper.GetResourceBytes("Resources/rgb.jpg");
            EncodedImageData rgbJpeg = new EncodedImageData(resourceBytes, 8, 655, 983, ColorSpaceNames.DeviceRgb, new string[] { PdfFilterNames.DCTDecode });
            this.CreatePageWithImage(document, "JPEG", rgbJpeg);

            resourceBytes = ResourceHelper.GetResourceBytes("Resources/grayScale.jpg");
            EncodedImageData grayJpeg = new EncodedImageData(resourceBytes, 8, 655, 983, ColorSpaceNames.DeviceGray, new string[] { PdfFilterNames.DCTDecode });
            this.CreatePageWithImage(document, "JPEG", grayJpeg);

            // decode is used for inverting the colors of the cmyk image.
            // More information on the matter can be found here: http://graphicdesign.stackexchange.com/a/15906
            double[] decode = new double[] { 1, 0, 1, 0, 1, 0, 1, 0 };
            resourceBytes = ResourceHelper.GetResourceBytes("Resources/cmyk.jpg");
            EncodedImageData cmykJpeg = new EncodedImageData(resourceBytes, 8, 655, 983, ColorSpaceNames.DeviceCmyk, new string[] { PdfFilterNames.DCTDecode });
            this.CreatePageWithImage(document, "JPEG", cmykJpeg, decode);

            resourceBytes = ResourceHelper.GetResourceBytes("Resources/rgb.jp2");
            EncodedImageData rgbJpc = new EncodedImageData(resourceBytes, 8, 655, 983, ColorSpaceNames.DeviceRgb, new string[] { PdfFilterNames.JPXDecode });
            this.CreatePageWithImage(document, "JPEG 2000", rgbJpc);

            resourceBytes = ResourceHelper.GetResourceBytes("Resources/grayScale.jp2");
            EncodedImageData grayScaleJpc = new EncodedImageData(resourceBytes, 8, 655, 983, ColorSpaceNames.DeviceGray, new string[] { PdfFilterNames.JPXDecode });
            this.CreatePageWithImage(document, "JPEG 2000", grayScaleJpc);

            if (File.Exists(TestFileName))
            {
                File.Delete(TestFileName);
            }

            byte[] documentBytes = new PdfFormatProvider().Export(document);

            return documentBytes;
        }
        private RadFixedDocument CreateDocument()
        {
            RadFixedDocument document = new RadFixedDocument();
            RadFixedPage page = document.Pages.AddPage();
            page.Size = new Size(792, 1128);
            FixedContentEditor editor = new FixedContentEditor(page);

            this.DrawBarChartContent(editor);
            this.DrawTableReportContent(editor);

            return document;
        }