Planet PDF Forum Planet PDF Forum
  New Posts New Posts RSS Feed - How to change all text to black by JavaScript
  FAQ FAQ  Forum Search   Register Register  Login Login

Hi, welcome to the Foxit Planet PDF Forum. If you have PDF or Adobe Acrobat questions then the right place to ask them is here, in this forum.

How to change all text to black by JavaScript

 Post Reply Post Reply
Author
oald View Drop Down
Member
Member


Joined: 16 Sep 2011
Points: 42
Post Options Post Options   Quote oald Quote  Post ReplyReply Direct Link To This Post Topic: How to change all text to black by JavaScript
    Posted: 18 Sep 2011 at 4:15pm
Dears,
 
I'm using Acrobat Professional 8 and want to have a script to change all text to black, I search in Google and find that there is similar question asked in acrobatusers.com but it is for printing, I wonder is there a way to just change all text to black? Your help is really appreciated!
 
codes provided:
 
var pp = this.getPrintParams();
pp.colorOverride = pp.constants.colorOverrides.mono;
this.print(pp);
 
I also read the JS API Reference and find there is an object colorConvertPage, but I cannot understand the example given:
 
Example
Get a colorConvertAction object, set it up to convert everything to RGB. (Note that we do not convert any alternate spaces, hence the “space type” match is for anything but alternate spaces.)

// Get a color convert action
var toRGB = this.getColorConvertAction();
// Set up the action for a conversion to RGB
toRGB.matchAttributesAny = -1;
toRGB.matchSpaceTypeAny = ~toRGB.constants.spaceFlags.AlternateSpace;
toRGB.matchIntent = toRGB.constants.renderingIntents.Any;
toRGB.convertProfile = "Apple RGB";
toRGB.convertIntent = toRGB.constants.renderingIntents.Document;
toRGB.embed = true;
toRGB.preserveBlack = false;
toRGB.useBlackPointCompensation = true;
toRGB.action = toRGB.constants.actions.Convert;
// Convert the first page of the document
var result = this.colorConvertPage(0,[toRGB],[]);
 


Edited by Rowan - 18 Sep 2011 at 5:06pm
Back to Top
try67 View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Points: 634
Post Options Post Options   Quote try67 Quote  Post ReplyReply Direct Link To This Post Posted: 18 Sep 2011 at 4:29pm
No. JavaScript can't change the properties of text in a PDF, unless this text is in a text field.
- Acrobat Expert - Contact me personally at try6767@gmail.com
Check out my custom-made scripts website: http://try67.blogspot.com
Back to Top
prodok View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Location: Switzerland
Points: 3340
Post Options Post Options   Quote prodok Quote  Post ReplyReply Direct Link To This Post Posted: 18 Sep 2011 at 7:21pm
However, but I am not sure whether it has been already implemented in the Acrobat version you are running, you can use the Preflight functionality to do quite a bit of changes. I think changing color is possible (because changing from RGB to CMYK is a very common Preflight fixing task).

You would do this manually, but if you have to do this task frequently, you can set up a batch sequence.

Hope this can help.

Max Wyss.

Back to Top
oald View Drop Down
Member
Member


Joined: 16 Sep 2011
Points: 42
Post Options Post Options   Quote oald Quote  Post ReplyReply Direct Link To This Post Posted: 25 Sep 2011 at 3:01pm
Hi Try67,
 
Thanks so much for your prompt reply! Then I wonder how I can make it, can we make it by developing a plug-in?
Back to Top
try67 View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Points: 634
Post Options Post Options   Quote try67 Quote  Post ReplyReply Direct Link To This Post Posted: 25 Sep 2011 at 3:09pm
Actually, it might be possible with colorConvertPage, but I have not used it so I can't help you out with it, I'm afraid.
- Acrobat Expert - Contact me personally at try6767@gmail.com
Check out my custom-made scripts website: http://try67.blogspot.com
Back to Top
oald View Drop Down
Member
Member


Joined: 16 Sep 2011
Points: 42
Post Options Post Options   Quote oald Quote  Post ReplyReply Direct Link To This Post Posted: 25 Sep 2011 at 3:59pm

Hi try67,

Thanks for your follow up! Just now I tried the way suggested by prodok, there is the function "Convert to grayscale" in Preflight:

 
I have a try and find that colors such as red, green and purple will be converted to gray rather than black, I wonder if I can edit preflight profile to change all text to black?
 
Before:
 
After:
 
Your help and instructions are really appreciated!
 
 


Edited by oald - 25 Sep 2011 at 4:05pm
Back to Top
oald View Drop Down
Member
Member


Joined: 16 Sep 2011
Points: 42
Post Options Post Options   Quote oald Quote  Post ReplyReply Direct Link To This Post Posted: 20 Oct 2011 at 9:19am

Today I read Thom Parker's article "What's New with Acrobat 8 JavaScript?"  (http://acrobatusers.com/tutorials/whats-new-acrobat-8-javascript) and there is a paragraph about the method colorConvertPage:

"Acrobat 8.0 has three new power features, page content color conversion, booklet printing and the Net Object. A power feature is one that does a lot with very little code and the first one on the list is a good example. The Doc Object has a new function called colorConvertPage(). This amazing function converts the colorspaces for every element drawn on a PDF page; images, text and paths.  For example, say you need to convert to CMYK before sending your document out for printing. With this function you can convert not just to CMYK, but to any of several color profiles available on your system. Acrobat ships with several well-known, industry-wide color profiles. Of course, colorspace conversion can be done with the Preflight Tool and the Touchup Object Tool, but this capability allows color-space conversion to be part of an automation or workflow script."

Is is possible to convert the color space to Gray ('G") and set the color for all text to color.black (["G",0])?

 
 
My Product Information:
Acrobat Pro 8.1.6, Windows
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.10
Copyright ©2001-2017 Web Wiz Ltd.

This page was generated in 0.031 seconds.