Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

Image hex-code generator Ver.1 on 2 computers (Mac) doesn't give the same result

Community Expert ,
Dec 20, 2021 Dec 20, 2021

Hi,
I've been using the iconToHex.pdf utility for a long time (I guess some of you know it) and I meet a problem working on 2 different Mac.

On the first one it's working very well but not on the second one with the same file and same imported image.

On this second Mac, the generated code is made with more than twice the number of characters.

For example, for a 20x20 px image, the correct file generated on the first Mac is 3200 characters and 7680 characters on the other Mac.

Does anybody already heard of that? I seach on the web without finding any answer!

Could that come from an Acrobat setting?

Do you know an other utility I could test?

Thanks in advance.

 

TOPICS
General troubleshooting , JavaScript , PDF forms
889
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 20, 2021 Dec 20, 2021

Do both computer have the same hardware and software specs? Do both computers have the same version  update of Adobe Acrobat ?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 20, 2021 Dec 20, 2021

I don't know the specifics for the Mac, but on the PC there was a major change (in a DC verision update) in how images are imported to a button field, i.e. the imported images are automatically scaled, which reduces the number of pixels.  This is probably what you are seeing. 

The solution is to do the hex conversion outside of Acrobat. I wrote a simple HTML page using the Canvas object to do it. 

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 20, 2021 Dec 20, 2021

Then again, a 20x20 pixel image has 400 pixels. Hex images in Acrobat are in ARGB format. That's 1, 2 digit hex number per pixel, or 8 digits which = 3200 characters.  

 7680 characters means you have 960 pixels. The the image is scaled up. Check the size parameters for the converted icon. 

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 20, 2021 Dec 20, 2021

Both Mac are runing under Big Sur with the same Acrobat version, and the problem was already the same with the previous OS before updating.

Here the ratio of the number of characters is x2.4, but with a 60x60 px image the ratio is x2.133 (28800 and 61440 characters), so the scale is not the same...

These calculations are done by both Mac from a single same file including the same image.

Capture d’écran 2021-12-20 à 23.43.38.pngexpand image

The script is:

 

var myIcon=getField("Button1").buttonGetIcon();
var w=getField("iconWidth").value;
var h=getField("iconHeight").value;
var mult;
if (w>=h) mult=w;
else mult=h;
var size=(w*h*8)+(mult*32);
var streamIcon=util.iconStreamFromIcon(myIcon);
this.createDataObject("heximg.txt", "");
var oFile=this.getDataObjectContents("heximg.txt");
oFile=util.streamFromString(streamIcon.read(size), "utf-8");
this.setDataObjectContents("heximg.txt", oFile);

 

I don't understand neither the mult variable nor the *32, and I guess in (w*h*8) 8 is corresponding to 8 octets for 1 bit.

I don't understand how a single script doesn't give the same results on both computers, unless that comes from a special Acobat setting.

@thom, about your htlm page, is it free?

Thanks

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 20, 2021 Dec 20, 2021

The web page is not public. Right now its pretty primitive.  The plan is to make it a tool available to PDFScripting.com members.  But if you join the site I'll happily email provide it too you. 

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 21, 2021 Dec 21, 2021
LATEST

I would have liked to consult your site for a long time! We must find a lot of Acobat JavaScript solutions!
Unfortunately I am not a professional, and the subscription is a bit expensive for me (but I understand it's your job).
For my problem, I will continue to use my 2 Macs until finding a solution.
Thank you for your answer.

@+

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines