Hi Support,
I am try to generate barcode with some url, when i declare variable i am getting error as below in screenshot
My barcode dll version is 17.5.0.0
image.png (127.5 KB)
image.png (13.2 KB)
Pls reply asap
Thanks and Regards
Aravind
Hi Support,
I am try to generate barcode with some url, when i declare variable i am getting error as below in screenshot
My barcode dll version is 17.5.0.0
image.png (127.5 KB)
image.png (13.2 KB)
Pls reply asap
Thanks and Regards
Aravind
Thanks for the screenshots.
I checked, in newer versions BarcodeGenerator class is there in Aspose.BarCode.Generation namespace. Since you are using an older version (Aspose.BarCode for .NET 17.5.0.0), so might have to use older classes/types, accordingly, e.g., BarCodeBuilder. Please note, BarCodeBuilder has been changed/replaced to BarcodeGenerator in newer versions.
Let us know if you still find any issue.
Thanks for reply, it will working after if i change BarCodeBuilder class.
Now i have two requirements.
Regards
Aravind
To place a custom caption on the right side of the barcode (e.g., QR), you can instead use a workaround, i.e., generate the QR code without the caption by Aspose.BarCode, then overlay the caption text programmatically on the image in the desired position.
//Create instance of BarcodeGenerator
Aspose.BarCode.Generation.BarcodeGenerator generator = new Aspose.BarCode.Generation.BarcodeGenerator(Aspose.BarCode.Generation.EncodeTypes.QR, "Sample QR Code");
//Customize the QR barcode size and dimensions
generator.Parameters.Barcode.XDimension.Pixels = 5;
//Save the barcode without the caption
string barcodePath = "e:\\test2\\QRCodeWithoutCaption.png";
generator.Save(barcodePath, Aspose.BarCode.Generation.BarCodeImageFormat.Png);
//Load the generated barcode image
using (System.Drawing.Bitmap barcodeImage = new System.Drawing.Bitmap(barcodePath))
{
//Create a new image with extra space for the caption
int captionWidth = 100; // Adjust width for the caption area
int newWidth = barcodeImage.Width + captionWidth;
int newHeight = barcodeImage.Height;
using (System.Drawing.Bitmap finalImage = new System.Drawing.Bitmap(newWidth, newHeight))
using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(finalImage))
{
// Fill background with white
g.Clear(System.Drawing.Color.White);
// Draw the barcode on the left
g.DrawImage(barcodeImage, 0, 0);
// Set up font and brush for the caption
System.Drawing.Font captionFont = new System.Drawing.Font("Arial", 12, System.Drawing.FontStyle.Regular);
System.Drawing.Brush captionBrush = System.Drawing.Brushes.Black;
// Define the caption text and its position
string captionText = "Caption1";
System.Drawing.SizeF captionSize = g.MeasureString(captionText, captionFont);
float captionX = barcodeImage.Width + 10; // Offset from the barcode
float captionY = (newHeight - captionSize.Height) / 2; // Center vertically
// Draw the caption
g.DrawString(captionText, captionFont, captionBrush, new System.Drawing.PointF(captionX, captionY));
// Save the final image
finalImage.Save("e:\\test2\\QRCodeWithRightCaption1.png");
}
}
Once you generate the barcode image by Aspose.BarCode, you may use Aspose.PDF APIs to add/insert the barcode image to an existing PDF file. See the document for your reference.
https://docs.aspose.com/pdf/net/add-image-to-existing-pdf-file/
Hi , Thanks for reply, i am using following code in vb and notice barcode value appear in bottom of the barcode.
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim generator As BarCodeBuilder = New BarCodeBuilder("Sample QR Code", EncodeTypes.QR)
' generator.Parameters.Barcode.XDimension.Pixels = 5
Dim barcodePath As String = "E:\OutPutFolder\QRCodeWithoutCaption.png"
generator.Save(barcodePath, Aspose.BarCode.BarCodeImageFormat.Png)
Using barcodeImage As System.Drawing.Bitmap = New System.Drawing.Bitmap(barcodePath)
Dim captionWidth As Integer = 100
Dim newWidth As Integer = barcodeImage.Width + captionWidth
Dim newHeight As Integer = barcodeImage.Height
Using finalImage As System.Drawing.Bitmap = New System.Drawing.Bitmap(newWidth, newHeight)
Using g As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(finalImage)
g.Clear(System.Drawing.Color.White)
g.DrawImage(barcodeImage, 0, 0)
Dim captionFont As System.Drawing.Font = New System.Drawing.Font("Arial", 12, System.Drawing.FontStyle.Regular)
Dim captionBrush As System.Drawing.Brush = System.Drawing.Brushes.Black
Dim captionText As String = "Caption1"
Dim captionSize As System.Drawing.SizeF = g.MeasureString(captionText, captionFont)
Dim captionX As Single = barcodeImage.Width + 10
Dim captionY As Single = (newHeight - captionSize.Height) / 2
g.DrawString(captionText, captionFont, captionBrush, New System.Drawing.PointF(captionX, captionY))
finalImage.Save("E:\OutPutFolder\QRCodeWithRightCaption1.png")
End Using
End Using
End Using
End Sub
Note: I don’t want even default barcode value , bcz we need to customize words in that place , that’s y i go with caption.
And i am using BarCodeBuilder, bcz my Aspose ver is 17.5
image.png (23.4 KB)
image.png (35.0 KB)
Pls reply asap
Regards
Aravind
I am sorry but we cannot provide support for Aspose.BarCode for .NET v17.5 while using BarCodeBuilder class. I think you need to hide code text but I cannot help much using older APIs. If you use newer API (BarcodeGenerator) using newer versions, it is very easy to do it using the line of code.
barcodeGenerator.Parameters.Barcode.CodeTextParameters.Location = CodeLocation.None
But I am not sure if relevant API or relevant attribute was there for the task in the older version that you are using. Could you please check if CodeTextVisible or something similar Boolean property is there for BarCodeBuilder class, so you may set it “False” for your needs?