Anlage des Repos
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
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 = '<rdf:Description xmlns:zf=\"urn:zugferd:pdfa:CrossIndustryDocument:invoice:2p0#\" rdf:about=\"\">\r\n'
|
||||
$zugferdMetadata += "<zf:ConformanceLevel>BASIC</zf:ConformanceLevel>\r\n"
|
||||
$zugferdMetadata += "<zf:DocumentFileName>zugferd-invoice.xml</zf:DocumentFileName>\r\n"
|
||||
$zugferdMetadata += "<zf:DocumentType>INVOICE</zf:DocumentType>\r\n"
|
||||
$zugferdMetadata += "<zf:Version>2p0</zf:Version>\r\n"
|
||||
$zugferdMetadata += "</rdf:Description>\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("<rdf:Description "), $zugferdMetadata)
|
||||
$gdPicturePDF.SetMetadata($currentMetadata)
|
||||
|
||||
$gdPicturePDF.SaveToFile($ZUGFeRDTargetFile)
|
||||
|
||||
write-host "test $($gdPicturePDF.GetStat())"
|
||||
|
||||
}
|
||||
|
||||
ELSE {
|
||||
Write-Host "Quelldatei(en) nicht vollständig bzw. auffindbar!"
|
||||
|
||||
}
|
||||
|
||||
#Remove-Variable * -ErrorAction SilentlyContinue
|
||||
$Error.Clear()
|
||||
|
||||
# Quellen:
|
||||
# https://www.gdpicture.com/blog/generate-zugferd-facturx-electronic-invoices-with-gdpicture/
|
||||
# https://www.gdpicture.com/forum/viewtopic.php?f=30&t=6436
|
||||
Reference in New Issue
Block a user