Hy,
I’m trying to add an Image that is a barcode (created using “Aspose.barcode”), to a pdf, everything works fine in local, the problem comes when I publish it on a Windows Container, the pdf is generated with the right size and all, but there isn’t the image in it, that’s the code:
using var generator = new BarcodeGenerator(EncodeTypes.Code128, idOrderEntry);
generator.Parameters.Barcode.CodeTextParameters.Location = CodeLocation.Below;
//
// Genero il barcode
// Documentazione riguardante la dimensione
// Customize Barcode Appearance in C#|Documentation
//
generator.Parameters.AutoSizeMode = AutoSizeMode.Interpolation;
generator.Parameters.ImageHeight.Millimeters = 28;
generator.Parameters.ImageWidth.Millimeters = 54;
generator.Parameters.Barcode.Padding.Top.Millimeters = 1;
generator.Parameters.Barcode.Padding.Left.Millimeters = 4;
generator.Parameters.Barcode.Padding.Right.Millimeters = 4;
using Bitmap res = generator.GenerateBarCodeImage();
using MemoryStream imageMs = new();
res.Save(imageMs, ImageFormat.Png);
_logger.LogDebug(“MemoryStream del barcode dell’etichetta, {EtichettaBytes} Bytes”, imageMs.Length.ToString());
// Genero il pdf e ci inserisco il barcode
Document pdfDoc = new Document();
pdfDoc.SetTitle(NOME_DATO_PERSISTENTE);
pdfDoc.Pages.Add();
// Per impostare altezza e larghezza della pagina pdf converto i mm(millimetri), in Points (unità di misura usata dalle pagine pdf)
// 1mm = 2,83464 Points
double heightPoints = 2.83464 * 28;
double widthtPoints = 2.83464 * 54;
pdfDoc.Pages.First().SetPageSize(widthtPoints, heightPoints);
PdfFileMend mender = new PdfFileMend();
mender.BindPdf(pdfDoc);
mender.AddImage(imageMs, 1, 0, 0, float.Parse(pdfDoc.Pages.First().PageInfo.Width.ToString()), float.Parse(pdfDoc.Pages.First().PageInfo.Height.ToString()));
// Creo un altro MemoryStream per salvarci il pdf
using MemoryStream pdfMs = new();
mender.Save(pdfMs);
I need the base64 only.