Barcode and RadFixedPage

2 posts, 0 answers
  1. Grigor
    Grigor avatar
    1 posts
    Member since:
    Jan 2014

    Posted 11 Sep 2015 Link to this post

    How to draw RadBarcode128 (Telerik.Windows.Controls) in RadFixedPage (Telerik.Windows.Documents.Fixed.Model).

    I have tried to export image  from Barcode as a FrameworkElement (BitMapImage) and draw this image into the RadFixedPage, but the quality of the image was very low. 



  2. Peshito
    Peshito avatar
    580 posts

    Posted 15 Sep 2015 Link to this post

    Hello Grigor,

    Below is an example of a RadBarcode128 being exported in a document created by RadPdfProcessing.
            <Grid x:Name="barcode" Width="445" Height="120" Background="White">
                <telerik:RadBarcode128 Text="Code 128"/>
            <Button x:Name="button" Click="ExportBarcode" Content="ExportImage" />
    private void ExportBarcode(object sender, RoutedEventArgs e)
        using (MemoryStream imageStream = new MemoryStream())
            Telerik.Windows.Media.Imaging.ExportExtensions.ExportToImage(barcode, imageStream, new PngBitmapEncoder());
            RadFixedDocument document = new RadFixedDocument();
            RadFixedPage page = document.Pages.AddPage();
            FixedContentEditor editor = new FixedContentEditor(page);
            editor.DrawImage(new ImageSource(imageStream, ImageQuality.High));
            PdfFormatProvider provider = new PdfFormatProvider();
            File.WriteAllBytes(@"barcode.png", imageStream.ToArray());
            File.WriteAllBytes(@"barcode.pdf", provider.Export(document));
    Note that the image is being added with high quality:
    editor.DrawImage(new ImageSource(imageStream, ImageQuality.High));

    Hope this helps.

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top