Class BarcodeGenerator
Namespace: Aspose.BarCode.Generation
Assembly: Aspose.BarCode.dll (25.1.0)
BarcodeGenerator ליצירת תמונות ברקוד בצד השרת.
סימבולוגיות נתמכות: 1D: Codabar, Code11, Code128, Code39, Code39FullASCII Code93, EAN13, EAN8, Interleaved2of5, MSI, Standard2of5, UPCA, UPCE, ISBN, GS1Code128, Postnet, Planet EAN14, SCC14, SSCC18, ITF14, SingaporePost ... 2D: Aztec, DataMatrix, PDf417, QR code ...
[XmlSerialization(Name = "Aspose.BarCode.Generator")]
public sealed class BarcodeGenerator : IDisposable
ירושה
מיישם
חברים ירושים
object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
דוגמאות
דוגמה זו מראה כיצד ליצור ולשמור תמונת ברקוד.
using(var generator = new BarcodeGenerator(EncodeTypes.Code128))
{
generator.CodeText = "123ABC";
generator.Save("code128.png");
}
בונים
BarcodeGenerator(BaseEncodeType)
יוצר מופע של BarcodeGenerator.
public BarcodeGenerator(BaseEncodeType type)
פרמטרים
type
BaseEncodeType
סוג סימבולוגיית ברקוד. השתמש במחלקת Aspose.BarCode.Generation.EncodeTypes כדי להגדיר סימבולוגיה.
BarcodeGenerator(BaseEncodeType, string)
יוצר מופע של BarcodeGenerator.
public BarcodeGenerator(BaseEncodeType type, string codeText)
פרמטרים
type
BaseEncodeType
סוג סימבולוגיית ברקוד. השתמש במחלקת Aspose.BarCode.Generation.EncodeTypes כדי להגדיר סימבולוגיה.
codeText
string
טקסט שיש לקודד.
מאפיינים
BarcodeType
סוג סימבולוגיית ברקוד.
[XmlSerialization(Type = XmlSerializationType.Element)]
public BaseEncodeType BarcodeType { get; set; }
ערך המאפיין
CodeText
טקסט שיש לקודד.
[XmlSerialization(Type = XmlSerializationType.Element)]
public string CodeText { get; set; }
ערך המאפיין
Parameters
פרמטרי יצירה.
[XmlSerialization(Type = XmlSerializationType.Element)]
public BaseGenerationParameters Parameters { get; }
ערך המאפיין
שיטות
Dispose()
public void Dispose()
ExportToXml(string)
מייצא את מאפייני הברקוד לקובץ xml המוגדר
public bool ExportToXml(string xmlFile)
פרמטרים
xmlFile
string
השם עבור הקובץ
מחזיר
אם הייצוא הושלם בהצלחה או לא.
מחזיר True במקרה של הצלחה; False אחרת
ExportToXml(Stream)
מייצא את מאפייני הברקוד לזרם xml המוגדר
public bool ExportToXml(Stream xml)
פרמטרים
xml
Stream
הזרם xml
מחזיר
אם הייצוא הושלם בהצלחה או לא.
מחזיר True במקרה של הצלחה; False אחרת
GenerateBarCodeImage()
מייצר את תמונת הברקוד תחת ההגדרות הנוכחיות.
public Bitmap GenerateBarCodeImage()
מחזיר
Bitmap
תמונת ברקוד. ראה System.Drawing.Bitmap.
דוגמאות
דוגמה זו מראה כיצד ליצור ולשמור תמונת ברקוד.
using(var generator = new BarcodeGenerator(EncodeTypes.Code128))
{
Bitmap barcode = generator.GenerateBarCodeImage();
barcode.Save("test.png");
}
ImportFromXml(string)
מייבא את מאפייני הברקוד מקובץ xml המוגדר ויוצר מופע BarcodeGenerator.
public static BarcodeGenerator ImportFromXml(string xmlFile)
פרמטרים
xmlFile
string
השם עבור הקובץ
מחזיר
מופע של BarcodeGenerator
ImportFromXml(Stream)
מייבא את מאפייני הברקוד מזרם xml המוגדר ויוצר מופע BarcodeGenerator.
public static BarcodeGenerator ImportFromXml(Stream xml)
פרמטרים
xml
Stream
הזרם xml
מחזיר
מופע של BarcodeGenerator
Save(Stream, BarCodeImageFormat)
שמור תמונת ברקוד לזרם בפורמט ספציפי.
public void Save(Stream stream, BarCodeImageFormat format)
פרמטרים
stream
Stream
זרם System.IO.Output.
format
BarCodeImageFormat
מפרט את פורמט הקובץ של התמונה המוצאת.
Save(string, BarCodeImageFormat)
שמור תמונת ברקוד לקובץ ספציפי בפורמט ספציפי.
public void Save(string filename, BarCodeImageFormat format)
פרמטרים
filename
string
נתיב לשמירה.
format
BarCodeImageFormat
מפרט את פורמט הקובץ של התמונה המוצאת.
Save(string)
שמור תמונת ברקוד לקובץ ספציפי.
public void Save(string filename)
פרמטרים
filename
string
נתיב לשמירה.
SetCodeText(byte[])
הגדר טקסט קוד כסדרת בתים.
public void SetCodeText(byte[] codeBytes)
פרמטרים
codeBytes
byte[]
בתים של טקסט קוד
SetCodeText(string, Encoding)
מקודד טקסט קוד עם סימן סדר הבתים (BOM), תוך שימוש בקידוד המוגדר: כמו UTF8, UTF16, UTF32 וכו’.
ברקודים חד-ממדיים צריכים להשתמש ב-Encoding.ASCII או ISO/IEC 8859-1 - Encoding.GetEncoding(28591). ברקודים דו-ממדיים צריכים להשתמש ב-Encoding.UTF8.
public void SetCodeText(string codeText, Encoding encoding)
פרמטרים
codeText
string
מחרוזת CodeText
encoding
Encoding
קידוד המיושם
דוגמאות
דוגמה זו מראה כיצד להשתמש ב-SetCodeText עם ברקודים חד-ממדיים ודואי-ממדיים
//מקודד טקסט קוד של ברקודים חד-ממדיים עם קידוד ASCII של 7 סיביות, סימן סדר הבתים (BOM) אינו נוכח
using (BarcodeGenerator gen = new BarcodeGenerator(EncodeTypes.Code128))
{
gen.SetCodeText("123ABCD", Encoding.ASCII);
gen.Save("barcode.png", BarCodeImageFormat.Png);
}
//מקודד טקסט קוד של ברקודים חד-ממדיים עם קידוד ISO/IEC 8859-1 של 8 סיביות, סימן סדר הבתים (BOM) אינו נוכח
using (BarcodeGenerator gen = new BarcodeGenerator(EncodeTypes.Code128))
{
gen.SetCodeText("123ABCD", Encoding.GetEncoding(28591));
gen.Save("barcode.png", BarCodeImageFormat.Png);
}
//מקודד טקסט קוד של ברקודים דו-ממדיים עם קידוד UTF8 עם סימן סדר הבתים (BOM)
using (BarcodeGenerator gen = new BarcodeGenerator(EncodeTypes.Code128))
{
gen.SetCodeText("123ABCD", Encoding.UTF8);
gen.Save("barcode.png", BarCodeImageFormat.Png);
}
SetCodeText(string, Encoding, bool)
מקודד טקסט קוד עם הוספת סימן סדר הבתים (BOM) אופציונלי, תוך שימוש בקידוד המוגדר: כמו UTF8, UTF16, UTF32 וכו’.
ברקודים חד-ממדיים צריכים להשתמש ב-Encoding.ASCII או ISO/IEC 8859-1 - Encoding.GetEncoding(28591). ברקודים דו-ממדיים צריכים להשתמש ב-Encoding.UTF8.
public void SetCodeText(string codeText, Encoding encoding, bool insertBOM)
פרמטרים
codeText
string
מחרוזת CodeText
encoding
Encoding
קידוד המיושם
insertBOM
bool
דגל המצביע על הוספה של סימן סדר הבתים (BOM) של הקידוד. במקרה שבו הקידוד דורש הוספת סימן סדר הבתים (BOM): כמו UTF8,
UTF16, UTF32 וכו’ ודגל זה מוגדר ל-true, ה-BOM מתווסף, במקרה שבו הדגל מוגדר ל-false, הוספת ה-BOM מתעלמת.
דוגמאות
דוגמה זו מראה כיצד להשתמש ב-SetCodeText עם ברקודים חד-ממדיים ודואי-ממדיים
//מקודד טקסט קוד של ברקודים חד-ממדיים עם קידוד ASCII של 7 סיביות, סימן סדר הבתים (BOM) אינו נוכח
using (BarcodeGenerator gen = new BarcodeGenerator(EncodeTypes.Code128))
{
gen.SetCodeText("123ABCD", Encoding.ASCII, true);
gen.Save("barcode.png", BarCodeImageFormat.Png);
}
//מקודד טקסט קוד של ברקודים חד-ממדיים עם קידוד ISO/IEC 8859-1 של 8 סיביות, סימן סדר הבתים (BOM) אינו נוכח
using (BarcodeGenerator gen = new BarcodeGenerator(EncodeTypes.Code128))
{
gen.SetCodeText("123ABCD", Encoding.GetEncoding(28591), true);
gen.Save("barcode.png", BarCodeImageFormat.Png);
}
//מקודד טקסט קוד של ברקודים דו-ממדיים עם קידוד UTF8 עם סימן סדר הבתים (BOM)
using (BarcodeGenerator gen = new BarcodeGenerator(EncodeTypes.Code128))
{
gen.SetCodeText("123ABCD", Encoding.UTF8, true);
gen.Save("barcode.png", BarCodeImageFormat.Png);
}
//מקודד טקסט קוד של ברקודים דו-ממדיים עם קידוד UTF8 ללא סימן סדר הבתים (BOM)
using (BarcodeGenerator gen = new BarcodeGenerator(EncodeTypes.Code128))
{
gen.SetCodeText("123ABCD", Encoding.UTF8, false);
gen.Save("barcode.png", BarCodeImageFormat.Png);
}