Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > FusionPro® VDP Creator

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old July 21st, 2022, 09:04 AM
dml1280 dml1280 is offline
Junior Community Member
 
Join Date: Apr 2016
Posts: 24
Default Use color change for inline graphic

Is there a color change rule to change the color of an inline graphic? Or it only works on a pdf brought in with a graphic box?

This is the code I am using for the inline graphic...
Code:
// Rule converted from XML Template "Inline Graphic Rule: Community Name":
// Begin XML Template selections //
var FieldName = "Social Media Icons"; // "Choose the field containing the graphic name:" (Required): FieldList
var Format = "pdf"; // "Choose the type of graphic:" (Required): PickList ["jpg" (JPG or JPEG), "tif" (TIF or TIFF), "png" (PNG), "pdf" (PDF), "gif" (GIF), "eps" (EPS)]
var SearchPath = ""; // "Enter a search path:": FolderPath
var DefaultGraphic = "Social Media - White .1875"; // "Choose a default graphic:": ResourceList (Graphic)
var SkipIfNoValue = false; // "Skip if the field value is empty": CheckBox
var Width = HundredthsOfPointsFromText("0 in"); // "Override graphic width (zero to use existing width):": Space
var Height = HundredthsOfPointsFromText(".16 in"); // "Override graphic height (zero to use existing height):": Space
// End XML Template selections //

var fieldVal = Field(FieldName);

if (!fieldVal && SkipIfNoValue)
    return "";

var path = CombinePath(SearchPath, fieldVal);

var Pic = NullResource();

for (var pass = 1; ; pass++)
{
    switch (pass)
    {
        case 1:
            var validExtensions = [".png", ".pdf", ".gif", ".eps", ".tif", ".tiff", ".jpg", ".jpeg"];
            if (validExtensions.indexOf(GetFileExtension(path).toLowerCase()) >= 0)
                Pic = CreateResource(path, "graphic", true);
            break;

        case 2:
            Pic = CreateResource(ReplaceFileExtension(path, Format.toLowerCase()), "graphic", true);
            break;

        case 3:
            var altExtensions = { JPG: "jpeg", TIF: "tiff" };
            Pic = CreateResource(ReplaceFileExtension(path, altExtensions[Format.toUpperCase()]), "graphic", true);
            break;

        case 4:
            //Print("Graphic not found: " + fieldVal);
            if (!DefaultGraphic)
                return "";
            //else
            Pic = Resource(DefaultGraphic);

        default:
            return ""; // should never get here
    }

    Pic.width = Width;
    Pic.height = Height;
    
    if (Pic.exists)
        return Pic;
}

return ""; // should never get here
Thanks.
Reply With Quote
  #2  
Old July 21st, 2022, 11:21 AM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,647
Default Re: Use color change for inline graphic

You can change the color of a resource, and use it inline, but it works only for PDF resources, not for any other graphic format.

If it's a PDF, you can just add a line like so before you return the resource:
Code:
// Change all colors to Blue.
Pic.ChangeColor("ALL", "0,0,255", 10);
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #3  
Old July 21st, 2022, 12:08 PM
dml1280 dml1280 is offline
Junior Community Member
 
Join Date: Apr 2016
Posts: 24
Default Re: Use color change for inline graphic

I added it here

Code:
    }

    Pic.width = Width;
    Pic.height = Height;
    Pic.ChangeColor("ALL", "0, 0, 0, 60", 10); // Change all colors.
    
    if (Pic.exists)
        return Pic;
But it had no effect.

Also, is there a way to add a little padding above the inline image so it lines up better with the text?



Thank you so much for your help.
Reply With Quote
  #4  
Old July 21st, 2022, 03:48 PM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,647
Default Re: Use color change for inline graphic

Quote:
Originally Posted by dml1280 View Post
I added it here

Code:
    }

    Pic.width = Width;
    Pic.height = Height;
    Pic.ChangeColor("ALL", "0, 0, 0, 60", 10); // Change all colors.
    
    if (Pic.exists)
        return Pic;
But it had no effect.
Well, it's hard to know what you're expecting, let alone why that's not the result you're getting, without more information, especially without the files.

Note that this doesn't necessarily work with every PDF; it depends on how the objects are shown in the PDF file. If the PDF is merely a wrapper for a raster image, it's probably not going to work. If it's vector art, that's more likely to work.

I would try just using the default "Change Color In PDF Resource Rule" Form Rule and see if that works.

If you want to attach the graphic here, I can take a look at it.
Quote:
Originally Posted by dml1280 View Post
Also, is there a way to add a little padding above the inline image so it lines up better with the text?
There are a few things you can do. You could subscript the inline graphic. You could adjust the height of the graphic. Depending on how you're trying to lay things out, you could just make this a separate frame, not inline at all. You could also use a table, and set margins separately for cells for the graphic and the other text. That's just a few of many possibilities.
Quote:
Originally Posted by dml1280 View Post
Thank you so much for your help.
Sure! Thanks for an interesting question.
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 11:04 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.