Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,41 +1,44 @@
// Title: Code39 Barcode with Increased XDimension
// Description: Demonstrates how to adjust the XDimension property to widen bars in a Code39 barcode, making it less dense for print media.
// Title: Increase XDimension for Code39 barcode to reduce visual density
// Description: Demonstrates how to adjust the XDimension property of a Code39 barcode using Aspose.BarCode to make bars wider, which is useful for print media where lower density is desired.
// Category-Description: This example belongs to the Aspose.BarCode generation category, illustrating barcode parameter customization. It showcases the BarcodeGenerator class, EncodeTypes enumeration, and barcode parameter settings such as XDimension, BarHeight, BarColor, and BackColor. Developers often need to tweak these settings to meet printing, scanning, and branding requirements.
// Prompt: Adjust XDimension to increase bar width for a Code39 barcode, reducing visual density for print media.
// Tags: code39, barcode, xdimension, print, aspose.barcode, generation
// Tags: code39, xdimension, barcode, generation, png, aspose.barcode, aspose.drawing

using System;
using Aspose.BarCode;
using Aspose.BarCode.Generation;
using Aspose.Drawing;

/// <summary>
/// Generates a Code39 barcode with a larger XDimension to reduce visual density,
/// suitable for printing on media where wider bars are preferred.
/// Generates a Code39 barcode with an increased XDimension to produce wider bars,
/// reducing visual density for better print media readability.
/// </summary>
class Program
{
/// <summary>
/// Entry point of the example. Creates a Code39 barcode, adjusts its XDimension,
/// and saves the result as a PNG image.
/// Entry point of the example. Creates a barcode, adjusts its dimensions,
/// and saves it as a PNG image.
/// </summary>
static void Main()
{
// Initialize a Code39 barcode generator with sample text.
using (var generator = new BarcodeGenerator(EncodeTypes.Code39, "CODE39-EXAMPLE"))
// Initialize a Code39 barcode generator with the sample text "CODE39"
using (var generator = new BarcodeGenerator(EncodeTypes.Code39, "CODE39"))
{
// Disable auto-size mode so that manual XDimension settings take effect.
generator.Parameters.AutoSizeMode = AutoSizeMode.None;

// Increase the XDimension to make each bar wider (e.g., 2 points).
// Increase XDimension (bar width) to 2 points for lower density
generator.Parameters.Barcode.XDimension.Point = 2f;

// Optionally set a reasonable bar height for printing (e.g., 40 points).
// Set a reasonable bar height (40 points) suitable for printing
generator.Parameters.Barcode.BarHeight.Point = 40f;

// Save the generated barcode image to a PNG file.
// Define foreground (bars) and background colors
generator.Parameters.Barcode.BarColor = Color.Black;
generator.Parameters.BackColor = Color.White;

// Save the generated barcode as a PNG file
generator.Save("code39.png");
}

// Inform the user that the barcode has been generated.
// Output a simple confirmation message
Console.WriteLine("Code39 barcode generated with increased XDimension.");
}
}
Original file line number Diff line number Diff line change
@@ -1,30 +1,38 @@
// Title: QR Code Rotation Example
// Description: Demonstrates applying a 45-degree rotation to a QR code and saving it as a JPEG image.
// Title: QR Code Generation with 45‑Degree Rotation
// Description: Demonstrates applying a 45‑degree rotation to a QR code and saving it as a JPEG image.
// Category-Description: This example belongs to the Aspose.BarCode generation category, showcasing how to configure barcode parameters such as rotation using the BarcodeGenerator class. Typical use cases include customizing barcode appearance for branding or layout requirements. Developers often need to adjust rotation, size, and format when integrating barcodes into graphics or documents.
// Prompt: Apply a 45‑degree RotationAngle to a QR code and save the result as a JPEG image.
// Tags: qr, rotation, jpeg, aspose.barcode, barcodegeneration
// Tags: qr code, rotation, jpeg, generation, aspose.barcode

using System;
using Aspose.BarCode;
using Aspose.BarCode.Generation;
using Aspose.BarCode.BarCodeRecognition;

/// <summary>
/// Entry point for the QR code rotation demonstration.
/// Generates a QR code, applies a 45‑degree rotation, and saves it as a JPEG image.
/// </summary>
class Program
{
/// <summary>
/// Generates a QR code, rotates it 45 degrees, and saves it as a JPEG file.
/// Entry point of the example. Creates a QR code, rotates it, and writes the output file.
/// </summary>
static void Main()
{
// Initialize the QR code generator with the desired text.
using (var generator = new BarcodeGenerator(EncodeTypes.QR, "Hello Aspose"))
// Initialize a QR code generator within a using block to ensure proper disposal
using (var generator = new BarcodeGenerator(EncodeTypes.QR))
{
// Set the rotation angle to 45 degrees.
// Set the text that the QR code will encode
generator.CodeText = "Hello World";

// Apply a 45‑degree rotation to the generated barcode image
generator.Parameters.RotationAngle = 45f;

// Persist the rotated QR code image as a JPEG file.
generator.Save("qr_rotated.jpg");
// Save the rotated QR code as a JPEG file
generator.Save("qr45.jpg");
}

// Inform the user that the operation completed successfully
Console.WriteLine("QR code generated with 45° rotation and saved as qr45.jpg");
}
}
Original file line number Diff line number Diff line change
@@ -1,57 +1,67 @@
// Title: MaxiCode barcode with custom padding and rotation
// Description: Demonstrates generating a MaxiCode barcode, applying uniform padding and rotating it to fit within a 300x300 point canvas.
// Title: MaxiCode Barcode with Custom Padding and Rotation on Fixed Canvas
// Description: Demonstrates how to generate a MaxiCode barcode, apply custom padding and rotate it to fit within a predefined canvas size.
// Category-Description: This example belongs to the Aspose.BarCode complex barcode generation category, illustrating the use of ComplexBarcodeGenerator, MaxiCodeCodetextMode2, and image parameter settings. It shows typical tasks such as setting canvas dimensions, padding, rotation, and colors for MaxiCode symbols. Developers creating shipping labels or logistics solutions often need to fit MaxiCode barcodes into fixed-size graphics.
// Prompt: Combine custom padding and rotation settings to fit a MaxiCode barcode within a predefined canvas size.
// Tags: maxicode, padding, rotation, canvas, aspose.barcode, csharp
// Tags: maxicode, padding, rotation, png, complexbarcode, generator, image-parameters

using System;
using System.IO;
using Aspose.BarCode;
using Aspose.BarCode.Generation;
using Aspose.BarCode.ComplexBarcode;
using Aspose.Drawing.Imaging;

/// <summary>
/// Example program that generates a MaxiCode barcode with custom padding and rotation.
/// Generates a MaxiCode barcode, applies custom padding and rotation, and saves it to a PNG file.
/// </summary>
class Program
{
/// <summary>
/// Entry point. Creates a MaxiCode barcode, sets canvas size, padding, rotation, and saves the image.
/// Entry point of the example. Configures barcode parameters, generates the image, and writes the output path.
/// </summary>
static void Main()
{
// Define sample MaxiCode data (Mode 2) with postal code, country code, service category, and a secondary message.
var maxiCode = new MaxiCodeCodetextMode2
// Define output file name and desired canvas size (points)
string outputPath = "maxicode.png";
float canvasWidth = 300f;
float canvasHeight = 300f;

// Prepare MaxiCode codetext using Mode 2 (includes postal code, country, service category, and a second message)
var maxiCodeCodetext = new MaxiCodeCodetextMode2
{
PostalCode = "524032140",
CountryCode = 56,
ServiceCategory = 999,
SecondMessage = new MaxiCodeStandardSecondMessage { Message = "Sample MaxiCode" }
};

// Initialize a ComplexBarcodeGenerator using the MaxiCode codetext.
using (var generator = new ComplexBarcodeGenerator(maxiCode))
// Initialize the complex barcode generator with the prepared codetext
using (var generator = new ComplexBarcodeGenerator(maxiCodeCodetext))
{
// Set AutoSizeMode to Interpolation so ImageWidth/ImageHeight control the final size.
generator.Parameters.AutoSizeMode = AutoSizeMode.Interpolation;
// Set the target canvas dimensions
generator.Parameters.ImageWidth.Point = canvasWidth;
generator.Parameters.ImageHeight.Point = canvasHeight;

// Define the target canvas size (300x300 points).
generator.Parameters.ImageWidth.Point = 300f;
generator.Parameters.ImageHeight.Point = 300f;
// Use interpolation auto‑size mode so the specified width/height control the final image size
generator.Parameters.AutoSizeMode = AutoSizeMode.Interpolation;

// Apply uniform padding of 10 points on all sides.
// Apply uniform padding of 10 points on all sides
generator.Parameters.Barcode.Padding.Left.Point = 10f;
generator.Parameters.Barcode.Padding.Top.Point = 10f;
generator.Parameters.Barcode.Padding.Right.Point = 10f;
generator.Parameters.Barcode.Padding.Bottom.Point = 10f;

// Rotate the barcode 90 degrees clockwise.
// Rotate the barcode 90 degrees clockwise
generator.Parameters.RotationAngle = 90f;

// Save the generated barcode image to a PNG file.
generator.Save("MaxiCode.png");
// Optional visual settings: white background and black bars
generator.Parameters.BackColor = Aspose.Drawing.Color.White;
generator.Parameters.Barcode.BarColor = Aspose.Drawing.Color.Black;

// Save the generated barcode image as PNG
generator.Save(outputPath, BarCodeImageFormat.Png);
}

// Inform the user that the barcode has been generated.
Console.WriteLine("MaxiCode barcode generated successfully.");
// Inform the user where the file was saved
Console.WriteLine($"MaxiCode barcode saved to '{Path.GetFullPath(outputPath)}'.");
}
}
Original file line number Diff line number Diff line change
@@ -1,45 +1,48 @@
// Title: High‑Resolution QR Code Barcode Generation with Interpolation Auto‑Size
// Title: Generate High‑Resolution PNG Barcode with Interpolation AutoSizeMode
// Description: Demonstrates configuring AutoSizeMode to Interpolation, setting image dimensions, and saving a high‑resolution PNG barcode using Aspose.BarCode.
// Category-Description: This example belongs to the Aspose.BarCode barcode generation category, showcasing how to use the BarcodeGenerator class with EncodeTypes, AutoSizeMode, and resolution settings. Typical use cases include creating printable barcodes for inventory, shipping, or product labeling where high‑resolution output is required. Developers often need to control image size, DPI, and rendering mode to meet quality standards.
// Prompt: Configure AutoSizeMode to Interpolation, set ImageWidth and ImageHeight, and generate a high‑resolution PNG barcode.
// Tags: qr, barcode, autosizemode, interpolation, highresolution, png, aspose.barcode, csharp
// Tags: code128, generation, png, autosizemode, resolution, aspose.barcode, barcodegenerator

using System;
using System.IO;
using Aspose.BarCode;
using Aspose.BarCode.Generation;
using Aspose.Drawing;

/// <summary>
/// Example program that generates a high‑resolution QR code barcode.
/// Example program that generates a high‑resolution PNG barcode using Aspose.BarCode.
/// </summary>
class Program
{
/// <summary>
/// Entry point. Configures the barcode generator and saves a PNG image.
/// Entry point. Configures barcode parameters, generates the image, and saves it to disk.
/// </summary>
static void Main()
{
// Initialize a barcode generator for a QR code with the desired text
using (var generator = new BarcodeGenerator(EncodeTypes.QR, "https://example.com"))
// Define the output file path in the current working directory.
string outputPath = Path.Combine(Directory.GetCurrentDirectory(), "high_res_barcode.png");

// Create a BarcodeGenerator for Code128 symbology with sample text.
using (BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.Code128, "1234567890"))
{
// Set the output resolution to 300 DPI for high‑quality rendering
// Set the desired resolution (e.g., 300 DPI) for high‑quality output.
generator.Parameters.Resolution = 300f;

// Enable Interpolation auto‑size mode to improve scaling quality
// Enable interpolation auto‑size mode and specify canvas dimensions in points.
generator.Parameters.AutoSizeMode = AutoSizeMode.Interpolation;
generator.Parameters.ImageWidth.Point = 600f; // Width in points.
generator.Parameters.ImageHeight.Point = 300f; // Height in points.

// Define the canvas size in points (1 point = 1/72 inch)
generator.Parameters.ImageWidth.Point = 600f; // Width: 600 points
generator.Parameters.ImageHeight.Point = 600f; // Height: 600 points

// Optional: specify foreground (barcode) and background colors
// Optional: define barcode and background colors.
generator.Parameters.Barcode.BarColor = Aspose.Drawing.Color.Black;
generator.Parameters.BackColor = Aspose.Drawing.Color.White;

// Save the generated barcode as a high‑resolution PNG file
generator.Save("high_res_barcode.png");
// Save the generated barcode as a PNG image to the specified path.
generator.Save(outputPath);
}

// Inform the user that the barcode has been created
Console.WriteLine("Barcode generated successfully.");
// Inform the user where the barcode image has been saved.
Console.WriteLine($"Barcode image saved to: {outputPath}");
}
}
Loading
Loading