Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

At all dpi's I get different results

Open
#471 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
15/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
csharp

Research direction

Start with the reporter's snippet: RenderPageToImage(CurrentPage, Dpi) produces the bitmap, which is passed to BarcodeReader.DecodeMultiple with AutoRotate, TryInverted, TryHarder and a long PossibleFormats list. Reproduce by rendering one PDF page at 72, 96, 150, 200, 300 and 600 dpi and comparing decode results, then check whether the library's binarizer or the format list causes the variation. The issue is open-ended, so done means either a documented approach that finds the barcode across dpi values or a clear explanation of why it cannot be done.

Written by the indexing model from the issue text.

Description

I tried to get the barcode from this page
Screenshot 2022-12-12 143259
I tried to get it with this code:

            Image currentPageImage = RenderPageToImage(CurrentPage, Dpi);

            BarcodeReader barcodeReader = new BarcodeReader()
            {
                AutoRotate = true,
                Options = new ZXing.Common.DecodingOptions()
                {
                    TryInverted = true,
                    PureBarcode = false,
                    TryHarder = true,
                    PossibleFormats = new List<BarcodeFormat>() { BarcodeFormat.AZTEC, BarcodeFormat.CODABAR, BarcodeFormat.CODE_39, BarcodeFormat.CODE_93, BarcodeFormat.CODE_128, BarcodeFormat.DATA_MATRIX, BarcodeFormat.EAN_8, BarcodeFormat.EAN_13, BarcodeFormat.ITF, BarcodeFormat.MAXICODE, BarcodeFormat.PDF_417, BarcodeFormat.QR_CODE, BarcodeFormat.RSS_14, BarcodeFormat.RSS_EXPANDED, BarcodeFormat.UPC_A, BarcodeFormat.UPC_E, BarcodeFormat.All_1D, BarcodeFormat.UPC_EAN_EXTENSION, BarcodeFormat.MSI, BarcodeFormat.PLESSEY, BarcodeFormat.IMB, BarcodeFormat.PHARMA_CODE }
                }
            };
            Result[] results = barcodeReader.DecodeMultiple((Bitmap)currentPageImage);
            Result = string.Empty;
            if (results != null)
            {
                foreach (Result result in results)
                {
                    Result += result.Text + Environment.NewLine;
                }
            }

If I now use 72 dpi (standard PDF dpi) I get no results.
If I use 96 dpi (standard WPF dpi) I get = [95001, 6, 3]
150 dpi = [6, 9, 11117131, 7, 3, 8000, 4]
200 dpi = [14, 00800000000, 3, 6, 000, 00000000, 7, 35, 9, 4]
300 dpi = [6, 4, 3]
600 dpi = [6, 3, 8, 5, 7, 4]

So my question would be: "How can I get this barcode if I do NOT know in which codec it was printed?"
We get different PDF documents and have to scan them for all barcodes.
How could I achieve that or is it even possible with this library?

Dominant language
C#
Stars
3.1k
Forks
704
Avg merge
13d 17h
Merged PRs (30d)
2

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from micjahn/ZXing.Net

All issues in micjahn/ZXing.Net

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.