Suche // Search:

28.10.2009

Bildgröße vor Import prüfen
//
Check image size before import

XFA-Formualre ermöglichen das Importieren von Bildern.
Eine sehr hilfreiche Funktion, die aber auch dazu führt, dass die Dateien sehr groß werden können, weil es keine Beschränkung bei der Dateigröße für den Import gibt.
Aber, um das zu beheben, brauchen Sie nur ein kleines JavaScript im Validierungs-Event des Bildfelds.


XFA-Form allow to import images into image fields.
This is great function but it also can cause an very great file size, as there is no limitation of the images file size.
To handle this you can use JavaScript.

A small script in the validation event of the image field is all you need.

if(ImageField1.resolveNode("value.#image").value.length > 1048576)
{
if(xfa.host.messageBox("Selected Image is to large","",0,0)==1)
{
ImageField1.rawValue = null;
}
}



In der ersten Zeile wird die Dateigröße des zu importierenden Bildes überprüft.
Dies geschieht in Bytes.
In diesem Beispiel 1048567 Bytes (also 1MB)
Ist das Bild größer wird eine Meldung in einer MessageBox angezeigt.
Diese Meldung können Sie nur mit "OK" bestätigen, wodurch das Bildfeld gleichzeitig wieder bereinigt wird.
Einfach und praktisch, denke ich.

The first if expression checks the size of the currently imported image in bytes.
In the case 1048576 bytes (= 1MB).
Is the image larger than this value a message appears.
If you confirm this message with "ok", which is the only option you have, the image field is cleared.

Quite simple but effective.

Beispiel/Example:
https://acrobat.com/#d=GGyBtcXpp4eJ18h1KhsgRw

Zeilenumbrüche in Textfeldern von XFA-Formularen erzeugen
//
Create Line Breaks in Text Fields of XFA-Forms

Ein Zeilenumbruch ist schon praktisch und einfach gemacht.
Einfach? Ok, solange Sie den Text selbst in das Feld eintippen schon.

Was aber, wenn Sie einem Textfeld einen Standardtext verpassen.
Sie können diesen nur in ein einzeiliges Feld eingeben, das Zeilenumbrüche einfach ignoriert.
Damit Sie den Standardtext dennoch mit Zeilenumbrüchen versehen können, müssen Sie die XML-Quelle anpassen.
Der Code den Sie dafür brauchen sieht wie folgt aus:


A Line break is a very useful thing in a text field and simple to create.
Simply? Well, simply as long you write the text by yourself it is.

What if you need a large text in a text field?
Of course you can type in a default value, but only into one line that does not recognize any line break.
For a line break in your default text you have to manipulate the XML-source.
The code there for is :




Suchen Sie in der XML-Quelle die Zeile, die den Standardtext enthält und fügen Sie dann den Code überall dort ein, wo Sie einen Zeilenumbruch haben möchten.


Search the line in the XML-source, that contains you default text and paste the code above everywhere into the default text where you need a line break.

<text> the music was &#xD;new black polished chrome &#xD; and came over the summer&#xD; ...

Ihr Standardtext wird dann so dargestellt:



So your default text then looks like:



the music was
new black polished chrome
and came over the summer
like liquid night.

Beispiel/Example:
https://acrobat.com/#d=DYI*KarIrLEmeMstN5YIGw