Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Thursday, May 14, 2015 12:54:27 PM(UTC)

TNoyce  
TNoyce

Groups: Registered
Posts: 11


I am using Leadtools Image Pro 17 with VS 2010.

I'm using the SpecialEffects.DrawRotated3DText to render 2D text with rotation (style Normal) to both the screen (Using the RasterImageViewer's graphics object (e.CreateGraphics()) and the printer's graphic object from the standard .NET printer objects.

I have a truetype barcode font which appears to display correctly on the screen, but appears to be getting smudged in some areas when it prints. Divisions which are visible between the black lines of barcode on the screen coerce into black blocks on the printer in some cases. This results in a barcode that is unusable.

It 'feels' to me like a resolution or DPI mis-match between the DrawRotated3DText and the e.Graphics context it is rendering to.

The printer uses media that is 3.375" x 2.145", and reports as 300DPI for both directions when I look at the information returned by the PageSettings object.

Printing the same data to a standard 8 1/2" x 11" sheet of paper results in both excellent text and barcodes. However, this is likely due to the fact that the fonts are proportionally increased in size so that they are in the same relative location, and occupy the same relative space they would if printed on the smaller page.

I create a Leadtools RasterImage which has the same properties as the printer's printing area:
DPIx and DPIy are both 300 in this case.

w & h are the size in pixels reported by the printer of the media.

RasterDefaults.XResolution = DPIx;
RasterDefaults.YResolution = DPIy;
LEAD1.Image = new RasterImage(RasterMemoryFlags.Conventional, w, h, 24, RasterByteOrder.Rgb, RasterViewPerspective.TopLeft, null, System.IntPtr.Zero,0);
badgeSideBitmap = new Bitmap(RasterImageConverter.ConvertToImage(LEAD1.Image, ConvertToImageOptions.None));
badgeSideBitmap.SetResolution((float)DPIx, (float)DPIy);
Graphics g = Graphics.FromImage(badgeSideBitmap);
g.Clear(Color.White);
LEAD1.Image = RasterImageConverter.ConvertFromImage(badgeSideBitmap, ConvertFromImageOptions.None);
g.Dispose();

I think I had to go through the bitmap -> rasterimage logic so I could clear the image to white initially. If there's a cleaner way to do this, I'd appreciate the tip.

I grab the image from the RasterImageviewer, because I want to use standard GDI+ methods to draw on it

RasterImageGdiPlusGraphicsContainer ric = new RasterImageGdiPlusGraphicsContainer(LEAD1.Image);
Graphics g = ric.Graphics;

Maybe, I shouldn't use a smoothing mode for text?
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

This call, results in lousy barcodes. Normal text print just fine.
Rotation is 0, Style is Normal, alignment is normally center/center.
All the color values are set to black.

fntDraw renders at 18 points. I am using the free Elfring 39 (3 of 9) fonts for the barcodes.

_processor.DrawRotated3dText(
g,
_textOptions.Text,
new Rectangle((int)this.Left, (int)this.Top, (int)this.Width, (int)this.Height),
(int)this.Rotation * 10,
_textOptions.Style,
_textOptions.Alignment,
0,
0,
_textOptions.TextColor,
_textOptions.TextColor,
_textOptions.TextColor,
fntDraw,null);


This results in better barcodes, but lousy text:

Rectangle txtRect = new Rectangle((int)this.Left, (int)this.Top, (int)this.Width, (int)this.Height);
g.TextRenderingHint = TextRenderingHint.SingleBitPerPixel;

if (this.Rotation != 0)
{
g.TranslateTransform(txtRect.X + txtRect.Width / 2, txtRect.Y + txtRect.Height / 2); // we define the center of rotation in the center of the container rectangle
g.RotateTransform((float)this.Rotation); // this doesn't change

var newRectangle = new Rectangle(-txtRect.Height / 2, -txtRect.Width / 2, txtRect.Height, txtRect.Width); // notice that width is switched with height

g.DrawString(_textOptions.Text, fntDraw, new SolidBrush(Color.Black), newRectangle, new StringFormat
{
LineAlignment = StringAlignment.Near,
Alignment = StringAlignment.Near,
Trimming = StringTrimming.None
});

g.ResetTransform();
}
else
{
g.DrawString(_textOptions.Text, fntDraw, new SolidBrush(Color.Black), txtRect, new StringFormat
{
LineAlignment = StringAlignment.Center,
Alignment = StringAlignment.Center,
Trimming = StringTrimming.None
});
}

Both font and barcode look good if I use the exact same fonts in Wordpad.

What am I missing?

 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Sunday, May 17, 2015 6:06:54 AM(UTC)

mohamed  
mohamed

Groups: Registered, Tech Support
Posts: 179


I am not sure what the problem is. It might be related to DPI or printer properties, so please try the following:
1. Create new empty project.
2. Add your code to that project and display the brcode on screen to verify the code works.
3. For testing purposes, install the LEADTOOLS ePrint Printer (evaluation edition if you don't own the product). This way, we can test here using the exact same printer driver if we need to.
4. Print the same barcode to the "LEADTOOLS ePrint Workstation" printer. You can use the printing preferences to define custom paper and use DPI similar to your physical printer.

If the ePrint Workstation is getting incorrect display similar to the problem with the paper printer, please send an email to support@leadtools.com and include the project you created in the above steps with the build number (File properties version info) of Leadtools.dll.
Also, include your toolkit serial number (do NOT post it here) and a link to this forum post.
Finally, include the font files you're using to render the barcodes.

Please put all attachments in a ZIP or RAR file when you send them.
Mohamed Abedallah
Developer Support Engineer
LEAD Technologies, Inc.

LEAD Logo
 
#3 Posted : Tuesday, May 19, 2015 5:38:38 AM(UTC)

TNoyce  
TNoyce

Groups: Registered
Posts: 11


Thanks for replying.

It doesn't seem to matter whether I use the RasterPrinter, or 'draw' my graphics directly to the printer's graphics object.

Just to confirm, where would I find the serial number?
 
#4 Posted : Tuesday, May 19, 2015 10:08:31 AM(UTC)

TNoyce  
TNoyce

Groups: Registered
Posts: 11


When I use the print preview dialog, I definitely see the distortion there.

Just so you know what I'm referring to, let me post some screen shots.

WordPad.jpg - screen shot of font rendering in WordPad

WordPadPreview.jpg - screen shot of print preview in Wordpad.

Physical printout matches preview to a 'T'.

Screen1.jpg - Screen shot of the same two fonts rendered to rasterImage control.

PPrevGDIPlus.jpg - Screen shot of print preview, using standard DrawString to the printer's Graphics object.

PPrevLP.JPG - Screen shot of print preview, using Draw3DText to the leadtools rasterImageViewer graphic object, printed directly to the RasterImageViewer.



File Attachment(s):
Samples.zip (26kb) downloaded 36 time(s).
 
#5 Posted : Wednesday, May 20, 2015 6:28:16 AM(UTC)

mohamed  
mohamed

Groups: Registered, Tech Support
Posts: 179


The low-quality images only show one thing: they are being generated or printed at a low resolution. If you'd like us to investigate and try to solve the problem, we'll need the project that shows this and the fonts used with it.
About the serial number, if you don't have the original details (invoice or email from our sales team), send a list of your email addresses to support@leadtools.com and we'll search our database. If you email us, include the details and project needed to reproduce the problem.
Mohamed Abedallah
Developer Support Engineer
LEAD Technologies, Inc.

LEAD Logo
 
#6 Posted : Wednesday, May 20, 2015 6:46:42 AM(UTC)

TNoyce  
TNoyce

Groups: Registered
Posts: 11


Do you have any idea what I can do to render the data at higher resolution?

 
#7 Posted : Thursday, May 21, 2015 5:24:11 AM(UTC)

mohamed  
mohamed

Groups: Registered, Tech Support
Posts: 179


Not without seeing the problem here.
Mohamed Abedallah
Developer Support Engineer
LEAD Technologies, Inc.

LEAD Logo
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.142 seconds.