cls # Stand: MK // 11.10.2021 Set-Variable -Scope Global -Name ScriptName -Value (($MyInvocation.MyCommand.Name) -split "\.")[0].ToString() Set-Variable -Scope Global -Name ScriptPath -Value (Split-Path ($MyInvocation.MyCommand.Path)) ######################################################################### ############################# KONFIGURATION ############################# $PDFSourceFile = "$ScriptPath\DigitalData-G-ARE-20224030-aveco.pdf" $XMLSourceFile = "$ScriptPath\ZUGFeRD-invoice.xml" $ZUGFeRDTargetFile = "auto" ######################################################################### IF (Test-Path -PathType Leaf "$ScriptPath\GdPicture.NET.14.dll") { Add-Type -Path "$ScriptPath\GdPicture.NET.14.dll" -ErrorAction Stop -Verbose write-host "Die DLL wurde geladen: $ScriptPath\GdPicture.NET.14.dll" } ELSE { write-host "Die DLL konnte nicht geladen werden: $ScriptPath\GdPicture.NET.14.dll" } $GdPictureImaging = [GdPicture14.GdPictureImaging]::new() $gdPicturePDF = [GdPicture14.GdPicturePDF]::new() $LicenseManager = [GdPicture14.LicenseManager]::new() $LicenseManager.RegisterKEY("21182889975216572111813147150675976632") IF ((Test-Path -PathType Leaf $PDFSourceFile) -and (Test-Path -PathType Leaf $XMLSourceFile)) { IF (($ZUGFeRDTargetFile -eq $NULL) -or ($ZUGFeRDTargetFile -eq "") -or ($ZUGFeRDTargetFile -eq "auto")) { $PDFSourceFilename = (Get-Item -Path $PDFSourceFile).name $PDFSourceFilename = $PDFSourceFilename.Replace(((Get-Item -Path $PDFSourceFile).extension),"") $ZUGFeRDTargetFile = "$ScriptPath\$($PDFSourceFilename)_pdfa3b$((Get-Item -Path $PDFSourceFile).extension)" } Write-Host "Quelldateien wurden gefunden, fahre fort ..." $gdPicturePDF.LoadFromFile($PDFSourceFile, $false) # Embedding xml part. $gdPicturePDF.EmbedFile($XMLSourceFile, "Rechnungsdaten im ZUGFeRD-XML-Format") # Saving as PDF/A-3b. #$gdPicturePDF.ConvertToPDFA($ZUGFeRDTargetFile, "PdfConversionConformance.PDF_A_3b", $true, $true) $gdPicturePDF.ConvertToPDFA($ZUGFeRDTargetFile, [GdPicture14.PdfConversionConformance]::PDF_A_3b, $true, $true) $gdPicturePDF.CloseDocument() $gdPicturePDF.LoadFromFile($ZUGFeRDTargetFile, $true) # Modifying the metadata. [string]$currentMetadata = $gdPicturePDF.GetMetadata() # Add basic ZUGFeRD schema properties. [string]$zugferdMetadata = '\r\n' $zugferdMetadata += "BASIC\r\n" $zugferdMetadata += "zugferd-invoice.xml\r\n" $zugferdMetadata += "INVOICE\r\n" $zugferdMetadata += "2p0\r\n" $zugferdMetadata += "\r\n" # Add PDF/A extension schema description for the ZUGFeRD schema. # Here you should add the proper metadata according to the ZUGFeRD specification. # Example: https:#www.pdflib.com/fileadmin/pdf-knowledge-base/zugferd/ZUGFeRD2_extension_schema.xmp $currentMetadata = $currentMetadata.Insert($currentMetadata.IndexOf("