Adobe Acrobat Pro DC - zoomen/verschieben von eingefügtem Bild in Bildfeld - JavaScript

New Here ,
Jun 30, 2022 Jun 30, 2022

Copy link to clipboard

Copied

Hallo,

gibt es die Möglichkeit ein Bild, das in einer fertigen PDF in einem Bildfeld eingefügt wird zu zoomen und verschieben?
Könnte man mit einem JavaScript die Funktion anpassen?
Code Beispiele (siehe unten) für Webbrowser habe ich im Internet gefunden aber ich bekomme sie in Adobe nicht zum laufen, da fehlt mir die Erfahrung.

Benötigt wird die Funktion, da eingefügte Bilder auf die jeweils längere Seite skaliert werden, dadurch können diese teils zu klein sein und der Inhalt wird nichtmehr erkannt.

 

Über Tipps wäre ich sehr dankbar!

 

Vielen Dank!

 

<style>
.active {
 cursor: move;
}

input[type="range"]#zoomer {
 width: 450px;
 vertical-align: middle;
}

div.scroll {
 width: 500px;
 height: 400px;
 overflow: hidden;
}

img#img {
 width: 500px;
 height: 400px;
 pointer-events: none;
 user-select: none;
}
</style>

<p>
  <label>Zoom: <input type="range" id="zoomer" value="1" min="1" max="2.5" step="0.01"></label>
</p>

<div class="scroll">
 <img src="m.jpg" id="img" alt="">
</div>

<script>
document.getElementById("zoomer").addEventListener("input", e => {
 var z = e.target.value;
 var img = document.getElementById("img");
 img.style.transform = " scale(" + z + ", " + z + ")";
 img.style.width = (z * 100) + "%";
 img.style.height = (z * 100 ) + "%";
});

const slider = document.querySelector(".scroll");
let isDown = false;
let startX;
let startY;
let scrolllLeft;
let scrolllTop;

slider.addEventListener("pointerdown", e => {
 if (document.getElementById("zoomer").value > 1) {
  isDown = true;
  slider.classList.add("active");
  startX = e.pageX - slider.offsetLeft;
  scrolllLeft = slider.scrollLeft;
  startY = e.pageY - slider.offsetTop;
  scrolllTop = slider.scrollTop;
 }
});

slider.addEventListener("pointerleave", () => {
 isDown = false;
 slider.classList.remove("active");
});

slider.addEventListener("pointerup", () => {
 isDown = false;
 slider.classList.remove("active");
});

slider.addEventListener("pointermove", e => {
 if (!isDown) return;
 e.preventDefault();
 var x = e.pageX - slider.offsetLeft;
 slider.scrollLeft = scrolllLeft - (x - startX);
 var y = e.pageY - slider.offsetTop;
 slider.scrollTop = scrolllTop - (y - startY);
});
</script>

 

TOPICS
How to , JavaScript , PDF forms

Views

79

Likes

Translate

Translate

Report

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

correct answers 1 Correct answer

Adobe Community Professional , Jul 04, 2022 Jul 04, 2022

The code you found is irrelevant to a script running in a PDF file.

You can't use a script to change the location of an image within an image field. You can only do that manually, through the Properties dialog.

What can be done with a script is to set the Scaling options of the field, through the following properties:

buttonFitBounds

buttonScaleHow

buttonScaleWhen

See the Acrobat JS API Reference for details on how to use them correctly.

Likes

Translate

Translate
Adobe Community Professional ,
Jun 30, 2022 Jun 30, 2022

Copy link to clipboard

Copied

What properties does you use at the image field?

Likes

Translate

Translate

Report

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
New Here ,
Jun 30, 2022 Jun 30, 2022

Copy link to clipboard

Copied

Run JavaScript, if mouse button released.

 

event.target.buttonImportIcon();

 

You can choose and insert the image, but you can´t transform it.

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Jul 01, 2022 Jul 01, 2022

Copy link to clipboard

Copied

I mean this:

Bild1.jpg

Likes

Translate

Translate

Report

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
New Here ,
Jul 03, 2022 Jul 03, 2022

Copy link to clipboard

Copied

I´m using this 

Gian213_1-1656915258753.png

 

 

Gian213_0-1656915201182.png

 

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Jul 04, 2022 Jul 04, 2022

Copy link to clipboard

Copied

What does you use at Options?

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Jul 04, 2022 Jul 04, 2022

Copy link to clipboard

Copied

LATEST

The code you found is irrelevant to a script running in a PDF file.

You can't use a script to change the location of an image within an image field. You can only do that manually, through the Properties dialog.

What can be done with a script is to set the Scaling options of the field, through the following properties:

buttonFitBounds

buttonScaleHow

buttonScaleWhen

See the Acrobat JS API Reference for details on how to use them correctly.

Likes

Translate

Translate

Report

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