Crystal Report Barcode 128 converter - c#

i need to print a Barcode128 in Crystal Report, with a c# windows form.
The input string is like this:
123456-abcdef-abc
I use barcode.dll to build the formatted 128barcode:
string encodedText = BarCode.BarcodeConverter128.StringToBarcode("123456-abcdef-abc");
string path = #"D:\Projects\mypath\myreport.rpt";
ReportDocument cryRpt = new ReportDocument();
cryRpt.Load(path);
cryRpt.SetParameterValue("#inputString", encodedText);
crystalReportViewer1.ReportSource = cryRpt;
crystalReportViewer1.Refresh();
in crystalReportViewer1, the textbox font is "Code 128"
it shows a barcode, but it is not readable from any barcode reader.
What's wrong?
Here is the barcode generated:
Image updated! the same issue.
Thanks in advance for any help.

Here is an image demonstrating how a Crystal Report UFL renders the barcode without any font dependencies. The UFL generates the image on the fly and directs an image object Graphic Location expression to the resulting image file.
Barcode Image Generated as Image via CUT Light UFL

You have what I call a "blur code". The software in Crystal Reports, is attempting to make your image look smoother using anti-aliasing. Another concern I have is that even if the image were sharpened, it would not scan due to the bars and spaces being the wrong width.
Here is an image zoomed in on your barcode and a clear image of your string represented in Code 128B overlain. The bars and spaces do not line up. In other words, even if the symbol in your attached image were clearer, you may even have an unreadable barcode. What I suspect is that your barcode may only be showing the right half of the entire barcode and the left half is being cut off by some bounding box that is not wide enough. Your barcode.dll may also be using Code 128C on the first 6 characters to save two characters in the width of the barcode because even if you scale the top barcode to line up character-wise, the checksum character does not seem to match.
I don't know much about Microsoft technologies, so I can't help you with that, except to say that you may want to try making the font something ridiculously huge and scaling the page to see if that fixes the anti-aliasing issue.
I'm hoping you can flip a switch in Crystal Reports that will get it to stop auto-anti-aliasing, then fix the bounding box issue.

Related

Rdlc report vertical barcodes

I have a problem in rdlc report in Visual Studio 2019 printing barcodes (2of5 or 3of9). In horizontal mode they are all OK, but in vertical property (WritingMode), the barcode does not show all bars correctly.
In design mode on screen, with a static barcode, all looks OK. But when is printed in PDF or on paper the barcodes have different struct. I try set DpiX and DpiY in DeviceInfo string to 1200 but nothing change. Is this an exist any bug? Any help?
Sample of barcodes:
sample2
From my experience, when something does not visualize on rdlc, it's usually a matter of size of the control placed on the report.
If the barcode you're trying to print is too big for the control size you set, then it will be removed by rdlc.
Try to test this by putting the barcode control in an empty area of the report and making it quite big and see if the barcode appears.
The elements you provided at the moment are insufficient to understand what actually is happening.

What type of image filtering/processing do mobile PDF scanners use to convert a captured image into a monochrome/black and white image?

I am trying to implement my own monochrome/black and white filter in C# to scan text documents. My approach is to apply a threshold filter on the captured image. However, I often run into the problem that the varying brightness on the image causes a ''shadowing effect'' on the processed image. Refer to the link below (it is pretty blurry but it should suffice). The image to the far left is the original image. When I apply my threshold filter, I get the same result as the image in the middle; some of the text becomes unreadable because the brightness of the image varies, so some portions become really black or really white. However, with the right filter, you can obtain the processed image to the right where everything looks crystal clear.
https://www.google.dk/search?q=monochrome+image+processing&espv=2&biw=1706&bih=859&source=lnms&tbm=isch&sa=X&ved=0ahUKEwir8vXlhIzPAhUFiywKHeSBC1wQ_AUIBigB#imgrc=4UTzoIpyqTkwrM%3A
I would like to know what the process is to obtain the image to the far right. Another example can be seen in the image below. It shows a sample mobile PDF scanner in use. Scanning the image results in a very nice black and white image, where the text can be easily read and no ''shadowing'' occurs on the image. Does anyone know what this process is or what it is called? It is very often used in mobile PDF scanning applications. Thank you in advance.
EDIT: The filter is called ''Adaptive Thresholding''. You can use the BradleyLocalThresholding class to implement the filter, or you can write it yourself (which is what I did). Please refer to my response to the comment by Yves Daoust down below.
You need two ingredients.
One is "background reconstruction", i.e. retrieving the intensity of the white sheet "under the characters", for instance by morphological opening.
The other is "shading correction", i.e. compensating the unevenness of the background illumination by comparing to the reconstructed background, for instance by subtraction.
This will "flatten" the image, making it perfectly amenable to global thresholding.
A simple method is to convert the image to grayscale and then convert it to B/W using an error diffusion algorithm such as Floyd–Steinberg dithering.

PDF doesn't wrap text lines automatically & respect line position

I'm trying to generate a PDF via code because not all actual PDF .NET libraries support the new Windows Runtime for Windows/Windows Phone 8.1.
The PDF is saved correctly, with only a bug of stream position count that I can fix easily, but, as you can see, the text doesn't wrap if line is too long.
I tried with PDF NewLine char (\n), but C# automatically convert it in the input string
Also, I can't understand the position of lines or objects to put into the document, because I follow this guide online that talk about a reversing axis disposition (x for height and y for width), but seems I didn't catch the right methodology (I put in my code a constant left position, at 40, and a variable top descreasing value (from 600, I'm not manage now the multipage if the value is less than 0).
This is the code of PDF generated:
http://pastebin.com/ZkZmbJdM
(Sorry if I use Pastebin, but using this editor Code function the code seems to be unformatted for special characters used for it)
Where am I doing wrong?
PDF is a graphical format trying to make you think it's a document format. But nope, it's just like drawing with GDI+ for instance. This is the reason why it can achieve the same rendered output across many platforms/programs/etc as opposed to text flow formats like doc/docx. And also, this is why it can really render anything.
So, as opposed to document formats, it is the responsibility of the program that generates the PDF to get the layout right. Think of it just as if you'd draw with GDI+.
In documents like docx or html, it's the rendering program that has to do the layout work. With such document, you just write text and the viewer will take care of laying it out.
Your PDF library certainly has the necessary code to measure the text length. Maybe even it has some code to provide some layout capabilities. You'll have to use these functions to do the layout.

Print coordinates in VB.NET or C#

I have to print invoices from my software. I created the layout with Adobe Illustrator and saved it as a PNG image. My original idea was printing the layout as a background and then print the actual data taken from the database. I printed my layout inside my function and then I measured the various boxes of the layout for correctly placing my text. The problem is that my text is not printed in the correct position that I've found. I tried to change the margins to 0 but it seems to have no effect. I want this: if I choose to print my text line at x=10 mm and y=20mm the text must be phisically printed in this position without scaling/translating, also my background image.
Can you help me?
Try using (e.g.) e.Graphics.PageUnit = GraphicsUnit.Milimeter, and then simply specify the desired values using the Graphics.DrawString Method

Replace text in PDF

I'm trying to replace a section of a PDF with different text. From research on all major PDF libraries for .NET, it seems this is complicated and not a trivial task. I think it may be easier to convert the PDF to an image, replace the text (always in the same place), then convert it back to a PDF (or leave it as an image if converting back isn't possible). Is it possible to extract an image from a PDF page with .NET?
If your text is in a known location, you can simply cover it with a rectangle filled with the background color, and then draw your text over top.
Note that the text will still be there, it simply won't be visible. Someone selecting text will still pick up the old stuff. If that's acceptable, it's quite trivial.
If the PDF was created from image, you can import it into Photoshop to edit it as an graphic. Or you can use screenshot program like "Snagit" to capture pdf page as image and use snagit's editor to erase old text and replace new one.
But this method may bring you problem is that the new added text may not the same font as text around it. Personally, I use pdf editor to replace text in pdf since the added text will be automatically fit with the original font and size.

Categories