This is a migrated thread and some comments may be shown as answers.

Barcode and RadFixedPage

1 Answer 136 Views
BarCode
This is a migrated thread and some comments may be shown as answers.
Grigor
Top achievements
Rank 1
Grigor asked on 11 Sep 2015, 08:50 AM

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. 

 

Thanks.

1 Answer, 1 is accepted

Sort by
0
Peshito
Telerik team
answered on 15 Sep 2015, 12:56 PM
Hello Grigor,

Below is an example of a RadBarcode128 being exported in a document created by RadPdfProcessing.
<Grid>
    <StackPanel>
        <Grid x:Name="barcode" Width="445" Height="120" Background="White">
            <telerik:RadBarcode128 Text="Code 128"/>
        </Grid>           
        <Button x:Name="button" Click="ExportBarcode" Content="ExportImage" />
    </StackPanel>
</Grid>
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));
 
        Process.Start(Directory.GetCurrentDirectory());
    }
}
Note that the image is being added with high quality:
editor.DrawImage(new ImageSource(imageStream, ImageQuality.High));

Hope this helps.

Regards,
Peshito
Telerik
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
Tags
BarCode
Asked by
Grigor
Top achievements
Rank 1
Answers by
Peshito
Telerik team
Share this question
or