Below is to make image of QR.
Instead of this method, can we insert the QR code into PDF file directly without making image file?
Thank you,
HB
// ExStart:CreateQRbarcode
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
// Instantiate barcode object and set CodeText & Barcode Symbology
BarCodeBuilder barCodeBarCodeBuilder = new BarCodeBuilder("1234567890", EncodeTypes.QR);
barCodeBarCodeBuilder.Save(dataDir + "CreateQRbarcode_out.bmp", BarCodeImageFormat.Bmp);
// ExEnd:CreateQRbarcode
@hbhur102,
You can insert barcode image directly into PDF file without saving the newly created barcode on to disk. But creating barcode by using Aspose.BarCode APIs is a must. You need to first create the barcode using Aspose.BarCode and get the stream object of that newly created barcode. Now pass the stream object of barcode to add image method of Aspose.PDF API. Simple logic is given below for your reference.
CODE:
Aspose.BarCode.BarCodeBuilder builder = new Aspose.BarCode.BarCodeBuilder();
builder.CodeText = "9223372036854775804";
builder.EncodeType = Aspose.BarCode.Generation.EncodeTypes.Code93Extended;
// Creating memory stream and Saving barcode image to memory stream
System.IO.MemoryStream ms = new System.IO.MemoryStream();
builder.BarCodeImage.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
// Create Pdf document and Add a section to the Pdf document
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// Create an image object inheriting properties from the section
Aspose.Pdf.Generator.Image image1 = new Aspose.Pdf.Generator.Image(sec1);
// Set coordinates
int lowerLeftX = 100;
int lowerLeftY = 100;
int upperRightX = 200;
int upperRightY = 200;
Aspose.Pdf.Document objPDFdoc = new Aspose.Pdf.Document(@"sample.pdf");
Aspose.Pdf.Page page = objPDFdoc.Pages.Add();
page.AddImage(ms, new Aspose.Pdf.Rectangle(lowerLeftX, lowerLeftY, upperRightX, upperRightY));
objPDFdoc.Save(@"sample.pdf");
Please visit the links given below for details.
Add and Delete Images in PDF
Manipulate Images in PDF