Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
Nifty  
#1 Posted : Tuesday, December 26, 2017 12:49:36 PM(UTC)
Nifty

Rank: Advanced Member

Groups: Member
Joined: 10/12/2015(UTC)
Posts: 44

While we are processing psd files there are situations when we need to provide an empty string for the text value.

Code:
psdProcessor.StringCallback = (processor, textFrame) => {

	if(textFrame.Text == "PET NAME")
		return GetPetNameFromDatabase();

	return textFrame.Text;
};


For instance, we have one text layer that provides a Name, and another with their Pet Name. If they don't have a Pet Name I'm returning string.Empty, but that throws an ArgumentNullException.

Code:
Message: Value cannot be null. Parameter name: text

Aurigma.GraphicsMill.AdvancedDrawing.Graphics.DrawText(Text text):21
Aurigma.GraphicsMill.Templates.PsdProcessor.RenderText(PsdTextFrame frame):673
Aurigma.GraphicsMill.Templates.PsdProcessor.RenderFrame(PsdFrame frame):23
Aurigma.GraphicsMill.Templates.PsdProcessor.CreateContainer(PsdFrame frame):46
Aurigma.GraphicsMill.Templates.PsdProcessor.CreateContainer(Stream psdStream):103
Aurigma.GraphicsMill.Templates.PsdProcessor.Render(Stream psdStream, Stream outStream, WriterSettings writerSettings):42



How can we return an empty string or flag the layer to not be rendered? Unfortunately this is crucial to our processing/logic.
Andrey Semenov  
#2 Posted : Tuesday, December 26, 2017 8:54:26 PM(UTC)
Andrey Semenov

Rank: Advanced Member

Groups: Member
Joined: 7/4/2017(UTC)
Posts: 43

Was thanked: 12 time(s) in 12 post(s)
Hi,

Try to return "\0" (which is the Unicode null character) value instead of string.Empty.

Regards,
Andrew

Edited by user Tuesday, December 26, 2017 8:55:29 PM(UTC)  | Reason: Not specified

thanks 1 user thanked Andrey Semenov for this useful post.
JoshSmith on 6/5/2023(UTC)
Nifty  
#3 Posted : Wednesday, December 27, 2017 8:26:05 AM(UTC)
Nifty

Rank: Advanced Member

Groups: Member
Joined: 10/12/2015(UTC)
Posts: 44

That worked perfect. Thank you.
Users browsing this topic
Forum Jump  
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.