You are viewing limited content. For full access, please sign in.

Question

Question

Add text box location not consistent

asked on February 17, 2021

Hello all,

I have a workflow that will add text boxes to a document in the repository. I have a simple POC that I'm working on and the goal is to place these "Reviewers" on the document. I use a For Each Values loop to place each one. I also created a token for the Y coordinates that I increase after each box so that they will all be lined up. 

Simple right. Except the text boxes are not lined up. The X value is static. The calculation for the Y values works because you can see them spaced out vertically exactly as I would expect. I just don't know why changing the Y values seems to make the placement shift so much horizontally. 

 

 

Any idea why I see this behavior? What am I missing? 

0 0

Replies

replied on February 17, 2021 Show version history

Are you sure the horizontal placement is shifting?  They look centered to me.

I'm not 100% certain, I don't have a lot of experience with that activity, but I believe the positioning is based on the center of the text box, not the top-left corner.

1 0
replied on February 18, 2021

I would love to get input from LF on this. I constantly rely on their guides and white pages for information. This is from the Admin guide. 

I know that the custom location is based on the top left of the page, but the first note suggests that the upper-left coordinate is what is used to determine if a text box has the same location. Why would the note say that you use the upper left coordinates if the text box is placed using the center location. If the custom coordinates are truly the center of the text box and not the upper left, then this is a huge miscommunication in the guide. I would suggest that they update the Admin guide to match the actual behavior and explain this situation more clearly. 

I also have beef with the blank space in the boxes. I'm using a trim function with my tokens. Why would the boxes have that blank space at the end of my string??? 

1 0
replied on February 18, 2021

I've been playing around with it and I'm seeing the same behavior you have indicated.  It definitely appears to use the center of the text box, not the top-left.  I don't see anywhere to change this setting.

From a development perspective, I've always worked from a top-left position, so this isn't intuitive to me at all.  Unfortunately, it does seem to be their intended functionality - this is quite frustrating.

0 0
replied on February 18, 2021

I know this is not exactly what you want, but here's a workaround, that allows you to add textboxes to your document using an SDK Script activity and some tokens.  You can modify the token values and run the same script again to add more textboxes.

This gives you a little more direct control over the different specifics of the textbox and does appear to be using top-left positioning instead of center positioning - so it's a little more intuitive.

Here's the tokens that are needed:

And here's the script to include in the SDK Script activity (this assumes Workflow version 10.4, you need to edit line 15 if you are on a different version).

namespace WorkflowActivity.Scripting.SDKScript
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Data.SqlClient;
    using System.Text;
    using Laserfiche.RepositoryAccess;
    using Laserfiche.RepositoryAccess.Common;

    /// <summary>
    /// Provides one or more methods that can be run when the workflow scripting activity is performed.
    /// </summary>
    public class Script1 : RAScriptClass104
    {
        /// <summary>
        /// This method is run when the activity is performed.
        /// </summary>
        protected override void Execute()
        {

            //Make sure that we are working with a document...
            if(this.BoundEntryInfo.EntryType == EntryType.Document)
            {

                //Retrieve all Token values from the Workflow
                int pToken = Convert.ToInt32(this.GetTokenValue("Textbox Page Number"));
                int xToken = Convert.ToInt32(this.GetTokenValue("Textbox X Position"));
                int yToken = Convert.ToInt32(this.GetTokenValue("Textbox Y Position"));
                int wToken = Convert.ToInt32(this.GetTokenValue("Textbox Width"));
                int hToken = Convert.ToInt32(this.GetTokenValue("Textbox Height"));
                int fToken = Convert.ToInt32(this.GetTokenValue("Textbox Font Size"));
                string tToken = this.GetTokenValue("Textbox Text").ToString();
                string cToken = this.GetTokenValue("Textbox Comment").ToString();

                //Get a reference to page 1 of the entry...
                DocumentInfo di = Document.GetDocumentInfo(this.BoundEntryId, this.RASession);
                PageInfo pi = di.GetPageInfo(pToken);

                //Create a new TextBoxAnnotation...
                TextBoxAnnotation textBox = new TextBoxAnnotation();

                //Set the coordinates and other properties from the token values...
                LfPoint textBoxPosition = new LfPoint(xToken, yToken);
                LfSize textBoxSize = new LfSize(wToken, hToken);
                textBox.Coordinates = new LfRectangle(textBoxPosition, textBoxSize);
                textBox.TextSize = fToken;
                textBox.BorderColor = LfColor.TRANSPARENT;
                textBox.FillColor = LfColor.TRANSPARENT;
                textBox.Text = tToken;
                textBox.Comment = cToken;

                //Add the annotation to the page...
                pi.AddAnnotation(textBox);

            }

        }
    }
}

 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.