This project has moved and is read-only. For the latest updates, please go here.

Is there a way to do align left for BarcodeWriter?

Apr 17, 2015 at 4:29 PM
Edited Apr 17, 2015 at 5:36 PM
I had successfully create a barcode image then I noticed there's some whitespace gap at the left and right side. So, is there a way to align left the encoded barcode data so there's no whitespaces on the left?

boxWidthX and boxHeightY is measured in points (PDF's point). I simply convert it to actual measurement as pixels in 300 dpi for the PDF size.

So, how do I set the ZXing.NET BarcodeWriter to 300 dpi instead of 96 dpi?
                       var barcodeWriter = new BarcodeWriter
                        {
                            //Encoder... ,
                            Format = BarcodeFormat.CODE_39,
                            Options = { Width = (int)((boxWidthX / 72) * 300), Height = (int)((boxHeightY / 72) * 300), PureBarcode = true },  /* PureBarcode - hide the visible 'vin' underneath barcode... */
                            //Renderer = new BitmapRender { TextFont = new Font("Arial", 9, FontStyle.Regular); }  //Helvetica...
                            Renderer = new ZXing.Rendering.BitmapRenderer { Background = dotnetDrawing::Color.Blue }
                        };

                        using (var barcodeVin = barcodeWriter.Write(parmBookValues.Vin.Trim()))
                        {
                            using (var newMemoryStream = new dotnetIO::MemoryStream())
                            {
                                var foo = barcodeVin.Width;

                                barcodeVin.Save(newMemoryStream, System.Drawing.Imaging.ImageFormat.Jpeg);
                                newMemoryStream.Position = 0;

                                //Get Image...
                                var image = pdfclownEntities::Image.Get(newMemoryStream);

                                primitiveComposer.ShowXObject(
                                    image.ToXObject(parmDocument),
                                    new dotnetDrawing::PointF(
                                        boxAdjustedPositionX,
                                        boxAdjustedPositionY
                                    ),
                                    new dotnetDrawing::SizeF(
                                        boxWidthX,
                                        boxHeightY
                                    ),
                                    XAlignmentEnum.Left,
                                    YAlignmentEnum.Top,
                                    0
                                );
                            }
                        }
Edit: Never mind. I found out that I only need to set the Margin to 0 in "Render" array.
Marked as answer by fletchsod11 on 4/17/2015 at 9:36 AM