1

I am using ExifToolVersion : 9.13 to read out metainformations of a pdf-file to formfields, where users can edit the values. With a second perl-script I write these changed values back to the file.

That works fine with the exception, that subject-values appear in keyword-tags and keyword-values in subject-tags, although I write the new values explizite to each tag.

$exifTool->SetNewValue($tag[$i], \@keywords, Replace => 1);   
$exifTool->SetNewValue($tag[$i], $file_beschreibung, Replace => 1);   

$exifTool->SetNewValue($data[$i]=>\@keywords, Group0 => 'PDF');
$exifTool->SetNewValue($data[$i]=>$file_beschreibung, Group0 => 'PDF');

I tried to write an empty value to the XMP tags, but that doesn't work

$exifTool->SetNewValue($data[$i]=>$leer, Group0 => 'XMP');

Is there a way to to avoid the concatenation of both values?

Cœur
  • 37,241
  • 25
  • 195
  • 267
ast
  • 11
  • 2
  • Word of advice: don't mix German and English variable names. The next guy is going to hate you for that. Especially if they outsource your job to some other country. ;) Also, is `$leer` empty, as in an empty string `q{}`, or `undef`? – simbabque Sep 04 '17 at 12:53
  • *"I am using ExifToolVersion : 9.13"* Do you mean `Image::ExifTool` 9.13? – Borodin Sep 04 '17 at 17:13
  • Are you really using `$tag[$i]` for both the keywords and the file description? With `Replace` set to 1 that will discard all the keyword values and use just the file description. You shouldn't be using `Replace` at all: it applies to values previously set by `SetNewValue`, not the value in the file. I would expect them to be written to two *different* tags. `Group0` isn't a valid parameter for `SetNewValue`; you probably mean `Group => 'PDF'`. Have you called `WriteInfo` after setting the values? You should check the returned values of `SetNewValue`: a success flag and an error message. – Borodin Sep 04 '17 at 17:40
  • Please show more of your code; the whole of the `$i` loop at least. – Borodin Sep 04 '17 at 17:41
  • I have a Loop over all tags i want to edit: `code` my @data = ("Author","Keywords","ModifyDate","Rights","Title","Subject"); my $elemente = @data; my @groups = $exifTool->GetGroups($family); for ($family=0; $family<=3; $family++) { foreach my $group (@groups) { – ast Sep 05 '17 at 08:27

1 Answers1

0

I now found, that I have to clear all XMP-Tags

my @data = ("Author","Keywords","ModifyDate","Rights","Title","Subject"); 
my $elemente = @data;

for ($i=0; $i<$elemente; $i++)
{
    if ($i==1)
 {
    if (my $tagname =~ m/^XMP-.*:$data[$i]/)
    {
    $exifTool->SetNewValue($tagname=>'', Group => 'XMP');
    }
    $exifTool->SetNewValue($data[$i]=>\@keywords, Group => 'PDF');
 }
 if ($i==5)
 {
    my $tagname = "XMP-dc:".$data[$i];
    $exifTool->SetNewValue($tagname=>'', Group => 'XMP');
    $exifTool->SetNewValue($data[$i]=>$file_beschreibung, Group => 'PDF'); 
 }
}

This works fine. Thank you for helping!

ast
  • 11
  • 2