Barcode into multipage tiff

Hello, I'm trying insert a barcode into multipage tiff in C# I found this:

http://www.aspose.com/demos/.net-components/aspose.barcode/csharp/barcode-generator/insert-in-multi-page-tiff.aspx

but I dont want for web (no ASP).

How I can do?


Thank you .

Hi Yolanda,


Thanks for your interest in our Aspose.BarCode for .NET product. You can generate the barcode by setting the codetext and selecting the symbology type and then you can insert it into a multi-page TIFF image. For each generated barcode, a new page in multi-page TIFF image will be created. Please follow up the code snippet below:

string[] lstCodeText = new
string[] { “code-1”,
“code-2”, “code-3”,
“code-last” };<o:p></o:p>

Symbology symbology = Symbology.Code128;

// generate separate barcode image as stream

// and save image stream in the array

ArrayList inputImages = new ArrayList();

foreach (string item in lstCodeText)

{

// get the codetext from array

string strCodetext = item;

MemoryStream image = new MemoryStream();

// generate the barcode

BarCodeBuilder builder = new BarCodeBuilder(strCodetext, symbology);

builder.Save(image, ImageFormat.Tiff);

inputImages.Add(image);

}

CreateMultipageTIF(inputImages,"c:\\test\\name.tiff");

private static void CreateMultipageTIF(ArrayList InputImages, string Filename)

{

// set the image codec

ImageCodecInfo info = null;

foreach (ImageCodecInfo ice in ImageCodecInfo.GetImageEncoders())

{

if (ice.MimeType == "image/tiff")

{

info = ice;

break;

}

}

EncoderParameters ep = new EncoderParameters(2);

bool firstPage = true;

System.Drawing.Image img = null;

// create a image instance from the 1st image

for (int nLoopfile = 0; nLoopfile < InputImages.Count; nLoopfile++)

{

//get image from src file

System.Drawing.Image img_src = System.Drawing.Image.FromStream((Stream)InputImages[nLoopfile]);

Guid guid = img_src.FrameDimensionsList[0];

System.Drawing.Imaging.FrameDimension dimension = new System.Drawing.Imaging.FrameDimension(guid);

//get the frames from src file

for (int nLoopFrame = 0; nLoopFrame < img_src.GetFrameCount(dimension); nLoopFrame++)

{

img_src.SelectActiveFrame(dimension, nLoopFrame);

ep.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Compression, Convert.ToInt32(EncoderValue.CompressionLZW));

// if first page, then create the initial image

if (firstPage)

{

img = img_src;

ep.Param[1] = new EncoderParameter(System.Drawing.Imaging.Encoder.SaveFlag, Convert.ToInt32(EncoderValue.MultiFrame));

img.Save(Filename, info, ep);

firstPage = false;

continue;

}

// add image to the next frame

ep.Param[1] = new EncoderParameter(System.Drawing.Imaging.Encoder.SaveFlag, Convert.ToInt32(EncoderValue.FrameDimensionPage));

img.SaveAdd(img_src, ep);

}

}

ep.Param[1] = new EncoderParameter(System.Drawing.Imaging.Encoder.SaveFlag, Convert.ToInt32(EncoderValue.Flush));

img.SaveAdd(ep);

}

For other details, please visit our documentation link below:
https://docs.aspose.com/barcode/net/developer-guide/

In case of further assistance & comments, please let me know.

Thanks for the answer but, this code creates a multipage tiff with barcode ... ¿How do I add these images to multipage tiff?

Thanks you again.

Hi Yolanda,


Thanks for the details. I’m afraid. There is no direct way to add image to multipage tiff image file by using Aspose.BarCode product. Besides, you can achieve this by using Aspose.Imaging for .net where you can concatenate multiple TIFF images. Please visit documentation link below:
http://www.aspose.com/docs/display/imagingnet/Concatenate+multiple+TIFF+images

If you are interesting to know more about Aspose.Imaging product then I can move this thread to Aspose.Imaging forum where one of our support team members will assist you.