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 : Thursday, January 4, 2018 11:42:32 AM(UTC)
Nifty

Rank: Advanced Member

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

After we started using your component to process internal Photoshop files I realized I needed to use the TextCallback instead of StringCallback because sometimes there were different colors in the text layer.

Although returning "\0" worked for the StringCallback (my previous post), I can't seem to find a solution for the TextCallback.

Both of the following throw the same error:

Code:
Specified argument was out of the range of valid values.
Parameter name: width must be positive.


Code:
psdProcessor.TextCallback = (processor, textFrame, textString) => {
    var text = processor.ProcessText(textFrame);                
    text.String = "\0";
    return text;
};


Code:
psdProcessor.TextCallback = (processor, textFrame, textString) => {
    var text = processor.ProcessText(textFrame);                
    text.String = "";
    return text;
};


Not sure what to do here, or if there is a way for me to tell the processor to just not process the frame.

Might be related, I also get an exception (Same Error Message) if the string is too long:

Code:
psdProcessor.TextCallback = (processor, textFrame, textString) => {
    var text = processor.ProcessText(textFrame);                
    text.String = "ThisIsAReallyLongStringThatProducesAnError";
    return text;
};


I've attached the sample psd that I'm working with.

spoon.zip (306kb) downloaded 7 time(s).
Andrey Semenov  
#2 Posted : Monday, January 8, 2018 4:54:07 AM(UTC)
Andrey Semenov

Rank: Advanced Member

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

Was thanked: 12 time(s) in 12 post(s)
There is no direct way to not process the frame, but you can use transparent Brush for the text as workaround:

Code:
text.Brush = new SolidBrush(RgbColor.Transparent);


As for the long string, it is supposed to throw an exception if content goes out of the image, and you need to handle this exception somehow or avoid it (e.g. trim the string if it has bigger than 10 symbols length).

Regards,
Andrew
Nifty  
#3 Posted : Monday, January 8, 2018 9:36:21 AM(UTC)
Nifty

Rank: Advanced Member

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

I could not figure out how to calculate the number of symbols to trim, for different psd files, but I got my desired result by using the following (when strings are too long):

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

    var text = processor.ProcessText(textFrame);
    text.String = "ThisIsAReallyLongStringThatProducesAnError";

    var path = text as PathText;
    if(path != null) {
        path.AutoExtend = true;
        return path;
    }
    
    return text;
};


This will allow text that is too long to not throw an error, but just get cropped by the width of the image.

Now that is solved for me, but your solution of using a transparent Brush does not work, it just leaves an outline (and Drop Shadow) of the text (using the psd I attached to the issue). Here is the code I am using to try and make the text not render...if there is no text.

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

    // Simulate getting a string from the database
    var replaceThisString = string.Empty; 

    var text = processor.ProcessText(textFrame);

    // No text to render
    if (string.IsNullOrWhiteSpace(replaceThisString)) {
        text.Brush = new SolidBrush(RgbColor.Transparent);
        return text;
    }

    text.String = replaceThisString;

    var path = text as PathText;
    if (path != null) {
        path.AutoExtend = true;
        return path;
    }

    return text;
};


Do you have another suggestion? I did notice that your solution works if the "text" variable (after being processed by processor.ProcessText) is of type PlainText, but in this particular psd the text layer is of type PathText. Therefor I did try to return a PlainText object, but that doesn't work either.

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

    // Simulate getting a string from the database
    var replaceThisString = string.Empty;

    var text = processor.ProcessText(textFrame);

    // No text to render
    if (string.IsNullOrWhiteSpace(replaceThisString))
        return new PlainText("\0", text.Font);

    text.String = replaceThisString;

    var path = text as PathText;
    if (path != null) {
        path.AutoExtend = true;
        return path;
    }

    return text;
};


Please let me know what else I can try because right now psd's with PathText layers are throwing exceptions when there is no value in our database.

Thank You.
Andrey Semenov  
#4 Posted : Monday, January 8, 2018 10:52: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)
Thank you for sharing your solution with path AutoExtend.

As for empty string content, it is possible to output the text somewhere out of the image limits like below:

Code:
return new PlainText("any text", text.Font, new System.Drawing.PointF(-100, -100));


Regards,
Andrew
Nifty  
#5 Posted : Tuesday, January 9, 2018 2:02:37 PM(UTC)
Nifty

Rank: Advanced Member

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

Worked perfectly, thanks.

Side note: We love your product and we're always trying to squeeze everything we can out of it. I look forward to the update that you guys push, but I noticed the last two didn't have an associated "Whats New" or "Change Log". We could be the only ones, but that can be really valuable information.

What's New Page

Thanks for a great product.
Andrey Semenov  
#6 Posted : Thursday, January 11, 2018 9:44:37 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)
"What's New" page will be updated soon. Actually, the latest releases were focused on fixing bugs with no new features.

Regards,
Andrew
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.