-
Notifications
You must be signed in to change notification settings - Fork 41
Added new kb article add-barcode-to-pdf-telerik #440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dessyordanova
merged 3 commits into
master
from
new-kb-add-barcode-to-pdf-telerik-a0d9d6ea723f4386b2ea87cd3eb19a21
Jul 10, 2024
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| --- | ||
| title: Adding a Barcode to a PDF Document using PdfProcessing and the WinForms BarcodeView | ||
| description: Learn how to generate a barcode and incorporate it into a PDF document using Telerik products. | ||
| type: how-to | ||
| page_title: How to Add a Barcode to a PDF with PdfProcessing and the WinForms BarcodeView | ||
| slug: add-barcode-to-pdf-telerik | ||
| tags: radpdfprocessing, document processing, barcode, pdf, telerik reporting, winforms, barcodeview | ||
| res_type: kb | ||
| ticketid: 1657503 | ||
| --- | ||
|
|
||
| ## Environment | ||
|
|
||
| | Version | Product | Author | | ||
| | --- | --- | ---- | | ||
| | 2024.2.426| RadPdfProcessing |[Desislava Yordanova](https://www.telerik.com/blogs/author/desislava-yordanova)| | ||
|
|
||
| ## Description | ||
|
|
||
| Learn how to generate a PDF document and add a barcode to it. | ||
|
|
||
|  | ||
|
|
||
| ## Solution | ||
|
|
||
| To add a barcode to a PDF document, consider using the [WinForms BarcodeView]({%slug barcodeview-overview%}): | ||
|
|
||
| 1\. First, [generate an image of the barcode]({%slug barcodeview-export-to-image%}). | ||
|
|
||
| 2\. Then, add the [image to the PDF document]({%slug pdf-from-images-with-radfixeddocumenteditor%}). Here is a sample code snippet: | ||
|
|
||
| ```csharp | ||
| Telerik.WinControls.UI.Barcode.QRCode qrCode1 = new Telerik.WinControls.UI.Barcode.QRCode(); | ||
| RadBarcodeView radBarcodeView = new RadBarcodeView(); | ||
| radBarcodeView.BindingContext = new BindingContext(); | ||
| qrCode1.Version = 1; | ||
| radBarcodeView.Symbology = qrCode1; | ||
| radBarcodeView.Text = "radBarcodeView1"; | ||
| radBarcodeView.Value = "1234567"; | ||
| radBarcodeView.Invalidate(); | ||
| System.Drawing.Image img = radBarcodeView.ExportToImage(200, 200); | ||
| string imageFilePath = "barcodeImage.png"; | ||
| img.Save(imageFilePath, System.Drawing.Imaging.ImageFormat.Png); | ||
|
|
||
| RadFixedDocument fixedDocument = new RadFixedDocument(); | ||
| RadFixedDocumentEditor documentEditor = new RadFixedDocumentEditor(fixedDocument); | ||
| FileStream fileStream = new FileStream(imageFilePath, FileMode.Open); | ||
| Telerik.Windows.Documents.Fixed.Model.Resources.ImageSource _imageSource = new Telerik.Windows.Documents.Fixed.Model.Resources.ImageSource(fileStream); | ||
| documentEditor.InsertImageInline(_imageSource); | ||
| documentEditor.InsertLineBreak(); | ||
| documentEditor.Dispose(); | ||
| PdfFormatProvider provider = new PdfFormatProvider(); | ||
| string outputFilePath = "output.pdf"; | ||
| File.Delete(outputFilePath); | ||
| using (Stream output = File.OpenWrite(outputFilePath)) | ||
| { | ||
| provider.Export(fixedDocument, output); | ||
| } | ||
| Process.Start(new ProcessStartInfo() { FileName = outputFilePath, UseShellExecute = true }); | ||
| ``` | ||
|
|
||
| ## Notes | ||
|
|
||
| - The WinForms BarcodeView method is suitable for applications where a barcode image can be generated and saved before adding it to the PDF: [Generating a Bar Code Image outside WinForms]({%slug barcodeview-generating-image-console-app%}). | ||
|
|
||
| ## See Also | ||
|
|
||
| - [RadPdfProcessing Documentation]({%slug radpdfprocessing-overview%}) | ||
| - [WinForms BarcodeView]({%slug barcodeview-overview%}) | ||
| - [Exporting BarcodeView to Image]({%slug barcodeview-export-to-image%}) | ||
| - [Generating a Barcode Image outside WinForms]({%slug barcodeview-generating-image-console-app%}) | ||
|
|
||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.