Delphi - Display Label Fields in Preview

Label printing integration (NiceWatch middleware and ActiveX programming interface)

Moderators: Georges, milos, NiceLabel Support Team

Post Reply
AndrewTH
Newcomer
Posts: 4
Joined: Fri Aug 12, 2011 3:45 am

Delphi - Display Label Fields in Preview

Post by AndrewTH » Fri Aug 12, 2011 3:49 am

Hi,

I'm currently working in Delphi and Nicelabel. I have created the previews properly using LabelOpenEX.
I was wondering if its possible to in those previews, display the label field that I've set when creating the NiceLabel.

For instance I would like to show the description of an item from the database in the appropriate field in the preview, before I print.

I've looked through the NiceLabel programming documentation and have come up short.
Any help would be greatly appreciated.

Kind Regards,

Andrew.

Miso
NiceLabel
NiceLabel
Posts: 332
Joined: Tue Oct 24, 2006 6:12 pm
Location: Kranj, Slovenia
Contact:

Re: Delphi - Display Label Fields in Preview

Post by Miso » Fri Aug 12, 2011 9:47 am

Hello Andrew,

Please explain your process a bit more. Do you pull the data from the database in your Delphi application or do you let NiceLabel do database access for you? I am almost certain that what you need is possible as preview is intended just for that - to get the picture of the label with the exact data that will be printed.

Give us a bit more details, maybe a sample of the Delphi code and the label that you are using and I am certain we can help you.

Regards,

Miso

AndrewTH
Newcomer
Posts: 4
Joined: Fri Aug 12, 2011 3:45 am

Re: Delphi - Display Label Fields in Preview

Post by AndrewTH » Fri Aug 12, 2011 1:26 pm

Hi Miso,

I am pulling information out of a current database we have. That is not the problem, and I can use the data freely... except when trying NiceLabel.

<code>
LabelInterfaceLarge := Nice.LabelOpenEx(SelectedPath + '\' + FileName);
Description := LabelInterfaceLarge.Variables.FindByName('Description');
Description.SetValue('ThisIsADescription');
LabelInterfaceLarge.GetLabelPreview('C:\EDIT\PrintSignage\Template Previews\Large\' + FileName + '.bmp', I_Label.Width, I_Label.Height);
</code>

The opening of the label, and getting the preview is fine. I'm just not able to get the 'Variables' and 'SetValue' commands to work. I'm not sure if they're even being used correctly.

Hopefully this helps with diagnosing what I'm doing wrong.

Kind Regards,

Andrew.

Miso
NiceLabel
NiceLabel
Posts: 332
Joined: Tue Oct 24, 2006 6:12 pm
Location: Kranj, Slovenia
Contact:

Re: Delphi - Display Label Fields in Preview

Post by Miso » Fri Aug 12, 2011 1:47 pm

Hello Andrew,

The provided code looks OK. Is it possible that you are setting invalid value to the variable in NiceLabel (for example 'ThisIsADescription' text might be too long for variable named Description)? To see if any such error occurred you can check this two properties:
- LabelInterfaceLarge.Application.ErrorMessage
- LabelInterfaceLarge.Application.DetailedMessage

Hope this helps
Regards,
Miso

AndrewTH
Newcomer
Posts: 4
Joined: Fri Aug 12, 2011 3:45 am

Re: Delphi - Display Label Fields in Preview

Post by AndrewTH » Fri Aug 12, 2011 3:35 pm

Hi Miso,

Thankyou I'll give them a try in the morning.
Is there anything else I need to do to make the variable appear on the label preview?

As you can see I currently open the file, set the variable and create the preview. Is there maybe another step I'm missing? I know for printing you have to "addStickerInfo". I was thinking maybe I was missing something.

I'll update with how I go tomorrow.

Kind Regards,

Andrew.

Miso
NiceLabel
NiceLabel
Posts: 332
Joined: Tue Oct 24, 2006 6:12 pm
Location: Kranj, Slovenia
Contact:

Re: Delphi - Display Label Fields in Preview

Post by Miso » Tue Aug 16, 2011 8:05 am

Hello Andrew,

Well the only thing you need to do is to place an object (Text, etc.) connected to the variable on the label during label design in NiceLabel. But I suppose you've done that.

Regards,
Miso

AndrewTH
Newcomer
Posts: 4
Joined: Fri Aug 12, 2011 3:45 am

Re: Delphi - Display Label Fields in Preview

Post by AndrewTH » Tue Aug 16, 2011 2:04 pm

Hi Miso,

Sorry for the late reply. Thankyou for your assistance, it now works.
The issue I had was I was attempting to use the code in the wrong place, one of those morning realisations where you just go "ohhhhhhh I'm an idiot".

I've encountered an issue now though, my previews are colour... but when printing the label files it defaults to black and white (from a cooer printer).
When opening the labels in NiceLabel, it seems that the "Print Options" have set the label to black and white.
I'm unsure why this is happening, are you able to shed any light on this?

Kind Regards,

Andrew.

User avatar
jurk
Addict
Addict
Posts: 175
Joined: Wed Sep 27, 2006 1:10 pm
Location: Sencur, Slovenija
Contact:

Re: Delphi - Display Label Fields in Preview

Post by jurk » Tue Aug 16, 2011 3:33 pm

Hello Adnrew,

What you are experiancing is actually a feature in NiceLabel. If you get the preview image via ActiveX you will get the image in full colors as this image renders on Screen DC. However if you select print privew in NiceLabel it will render the image on Printer DC rather than Screen DC so the preview is actually WYSWYG. It is printer driver dependant. If you do a print preview on a color printer you will get color preview. In case you select a monochrome printer the preview will be black and white as printer can only print black and white.

Hope this helps 8)
NiceLabel Development

Post Reply