
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
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

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
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

thanks Tanya that worked perfectly
I was able to insert the stream from the wrapped barcode into a table as well.