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

raddocument and barcode control

4 Answers 352 Views
PdfProcessing
This is a migrated thread and some comments may be shown as answers.
David Ocasio
Top achievements
Rank 2
Iron
Veteran
Iron
David Ocasio asked on 25 Sep 2015, 07:41 PM

I currently have the need to print a large amount of data from a silverlight app.  The customer is using a third party pdf printer driver . unfortunately the amount of data is overwhelming that driver.

My first thought to combat this is to create my own pdf file as opposed to using the printer subsystem.

The only truly graphic element in the printout is barcodes. I use your barcode control. The rest is text/columnar data.

So the question :

Can I add your barcode control to the raddocument within a table/cell value so that it will render properly to the pdf file. If so how would I go about doing that.

 Any Help would be appreciated

thanks

David Charles Ocasio

4 Answers, 1 is accepted

Sort by
0
Tanya
Telerik team
answered on 28 Sep 2015, 01:12 PM
Hi David,

You could create images from the RadBarcode control and insert them at the desired position in the RadDocument. Please, refer to the Export Support article about information on how to export a control to an image. Then, this image could be inserted in any place of the document using the API of RadDocumentEditor. The snippet below demonstrates how this could be achieved:
MemoryStream stream = new MemoryStream();
ExportExtensions.ExportToImage(this.radBarcode, stream, new PngBitmapEncoder());
 
TableCell cell = this.radRichTextBox.Document.EnumerateChildrenOfType<TableCell>().First();
this.radRichTextBox.Document.CaretPosition.MoveToStartOfDocumentElement(cell);
             
RadDocumentEditor editor = new RadDocumentEditor(this.radRichTextBox.Document);
editor.InsertImage(stream, "png");

Hope this helps.

Regards,
Tanya
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
0
David Ocasio
Top achievements
Rank 2
Iron
Veteran
Iron
answered on 28 Sep 2015, 11:15 PM

I am trying to take what you sent and use the radfixeddocument as opposed to the raddocument.

I eventually want to have in render in a table but I have simplified the code in a effort to verify that it renders at all.

What I get is a dark block. The barcode control (testbarcode) I placed on the page to verify that sizes and other visual stuff were taken care of. I eventually want to make that in code.

So what am I doing wrong.

Thanks

David Charles Ocasio.

 

Dim dialog As New SaveFileDialog()
dialog.DefaultExt = "*.pdf"
dialog.Filter = "Adobe PDF Document (*.pdf)|*.pdf"
 
If dialog.ShowDialog() = True Then
 
 
    Dim document As New RadFixedDocument
    Dim page = document.Pages.AddPage()
 
    Dim memoryStream As Stream = New MemoryStream
    Telerik.Windows.Media.Imaging.ExportExtensions.ExportToImage(TestBarcode, memoryStream, New PngBitmapEncoder)
 
    Dim editor As New FixedContentEditor(page)
    editor.DrawImage(memoryStream)
 
    Dim provider As New PdfFormatProvider
    Using output As Stream = dialog.OpenFile()
        provider.Export(document, output)
    End Using
 
End If

0
Accepted
Tanya
Telerik team
answered on 29 Sep 2015, 11:19 AM
Hi David,

The image, taken from the RadBarcode doesn't have any background color and the transparent images are not supported in RadPdfProcessing. We have this feature request already logged in our backlog and you could vote for it and subscribe to the related public item in order to receive notifications about status changes on it.

In order to properly show the image in the document, you could set the Background property of a panel and wrap the RadBarcode in it:
<Grid Grid.Row="1" Name="barcodeWrapper" Background="White" >
    <telerik:RadBarcode128 Name="radBarcode1" Text="code 12827111"/>
</Grid>

Then this panel could be passed to the ExportImage() method.

Please, note that to ensure that everything will work as expected and the ExportImage() will be able to get the image, the barcode should be in the Visual Tree.

As you mentioned that you plan to insert the image in a table, you may find helpful to check the corresponding articles in our documentation.

Regards,
Tanya
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
0
David Ocasio
Top achievements
Rank 2
Iron
Veteran
Iron
answered on 29 Sep 2015, 02:07 PM

thanks Tanya that worked perfectly

I was able to insert the stream from the wrapped barcode into a table as well.

Tags
PdfProcessing
Asked by
David Ocasio
Top achievements
Rank 2
Iron
Veteran
Iron
Answers by
Tanya
Telerik team
David Ocasio
Top achievements
Rank 2
Iron
Veteran
Iron
Share this question
or