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>
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.
Copy link to clipboard
Copied
What properties does you use at the image field?
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.
Copy link to clipboard
Copied
I mean this:
Copy link to clipboard
Copied
I´m using this
Copy link to clipboard
Copied
What does you use at Options?
Copy link to clipboard
Copied
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.