zugpferd prüfungstool
This commit is contained in:
@@ -3,9 +3,12 @@ Imports System.Drawing
|
||||
Imports System.Drawing.Printing
|
||||
Imports System.IO
|
||||
Imports System.Net
|
||||
Imports System.Text
|
||||
Imports System.Text.RegularExpressions
|
||||
Imports System.Windows.Forms
|
||||
Imports DocumentFormat.OpenXml
|
||||
Imports iTextSharp.text.pdf
|
||||
Imports Org.apache.pdfbox.pdmodel.graphics.color
|
||||
Imports Spire.Pdf
|
||||
Imports Spire.Pdf.Attachments
|
||||
Imports Spire.Pdf.Print
|
||||
@@ -1393,10 +1396,10 @@ Public Class cFormularManager
|
||||
|
||||
For Each pdfPath As String In PDFFile
|
||||
|
||||
Using doc As New Spire.Pdf.PdfDocument(pdfPath)
|
||||
Using doc As New Spire.Pdf.PdfDocument(pdfPath)
|
||||
|
||||
If doc.Pages.Count = 0 Then Continue For
|
||||
Dim size = doc.Pages(0).Size
|
||||
If doc.Pages.Count = 0 Then Continue For
|
||||
Dim size = doc.Pages(0).Size
|
||||
If size.Width <= 10 OrElse size.Height <= 10 Then Continue For 'zu kleine Seiten überspringen
|
||||
' --- Druckeinstellungen ---
|
||||
doc.PrintSettings.PrinterName = printerName
|
||||
@@ -1405,9 +1408,9 @@ Public Class cFormularManager
|
||||
doc.PrintSettings.SelectSinglePageLayout(PdfSinglePageScalingMode.FitSize, True)
|
||||
doc.Print()
|
||||
|
||||
End Using
|
||||
End Using
|
||||
|
||||
Next
|
||||
Next
|
||||
|
||||
Catch ex As Exception
|
||||
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
||||
@@ -2437,6 +2440,112 @@ Public Class DATENVERVER_OPTIONS
|
||||
End Function
|
||||
|
||||
|
||||
Public Shared Function addZugferdXML(File As String, attPath As String) As String
|
||||
Dim tempFile As String = File & ".tmp"
|
||||
|
||||
Using reader As New PdfReader(File)
|
||||
Using fs As New FileStream(tempFile, FileMode.Create)
|
||||
Using stamper As New PdfStamper(reader, fs)
|
||||
|
||||
Dim xmlBytes = System.IO.File.ReadAllBytes(attPath)
|
||||
|
||||
Dim fileName As String = "factur-x.xml"
|
||||
|
||||
Dim fspec = PdfFileSpecification.FileEmbedded(
|
||||
stamper.Writer,
|
||||
fileName,
|
||||
fileName,
|
||||
xmlBytes,
|
||||
"application/xml",
|
||||
Nothing,
|
||||
0
|
||||
)
|
||||
|
||||
fspec.Put(PdfName.AFRELATIONSHIP, New PdfName("Alternative"))
|
||||
|
||||
stamper.Writer.AddFileAttachment("ZUGFeRD", fspec)
|
||||
|
||||
Dim af As New PdfArray()
|
||||
af.Add(fspec.Reference)
|
||||
stamper.Writer.ExtraCatalog.Put(PdfName.AFRELATIONSHIP, af)
|
||||
|
||||
|
||||
SetZugferdXmp(stamper, fileName)
|
||||
|
||||
End Using
|
||||
End Using
|
||||
End Using
|
||||
|
||||
System.IO.File.Delete(File)
|
||||
System.IO.File.Move(tempFile, File)
|
||||
|
||||
Return File
|
||||
End Function
|
||||
|
||||
|
||||
Public Shared Function ConvertToPdfA3(inputPdf As String) As String
|
||||
|
||||
Dim tempFile As String = inputPdf & ".tmp"
|
||||
|
||||
Dim reader As New PdfReader(inputPdf)
|
||||
|
||||
Using fs As New FileStream(tempFile, FileMode.Create, FileAccess.Write)
|
||||
Using stamper As New PdfStamper(reader, fs)
|
||||
|
||||
' ✔ DAS ist in iTextSharp 5 der einzig relevante PDF/A-Baustein
|
||||
Dim iccPath As String =
|
||||
"C:\Windows\System32\spool\drivers\color\sRGB Color Space Profile.icm"
|
||||
|
||||
Dim icc = ICC_Profile.GetInstance(File.ReadAllBytes(iccPath))
|
||||
|
||||
stamper.Writer.SetOutputIntents(
|
||||
"Custom",
|
||||
"",
|
||||
"http://www.color.org",
|
||||
"sRGB IEC61966-2.1",
|
||||
icc
|
||||
)
|
||||
|
||||
stamper.Writer.PDFXConformance = PdfWriter.PDFX32002
|
||||
|
||||
End Using
|
||||
End Using
|
||||
|
||||
reader.Close()
|
||||
|
||||
If File.Exists(inputPdf) Then File.Delete(inputPdf)
|
||||
File.Move(tempFile, inputPdf)
|
||||
|
||||
Return inputPdf
|
||||
|
||||
End Function
|
||||
|
||||
|
||||
Private Shared Sub SetZugferdXmp(stamper As PdfStamper, xmlFileName As String)
|
||||
|
||||
Dim xmp As String =
|
||||
"<?xpacket begin="""" id=""W5M0MpCehiHzreSzNTczkc9d""?>" &
|
||||
"<x:xmpmeta xmlns:x=""adobe:ns:meta/"">" &
|
||||
"<rdf:RDF xmlns:rdf=""http://www.w3.org/1999/02/22-rdf-syntax-ns#"" " &
|
||||
"xmlns:pdfaid=""http://www.aiim.org/pdfa/ns/id/"" " &
|
||||
"xmlns:zf=""urn:factur-x:pdfa:CrossIndustryDocument:invoice:2#"" >" &
|
||||
"<rdf:Description rdf:about="""">" &
|
||||
"<pdfaid:part>3</pdfaid:part>" &
|
||||
"<pdfaid:conformance>B</pdfaid:conformance>" &
|
||||
"<zf:DocumentType>INVOICE</zf:DocumentType>" &
|
||||
"<zf:DocumentFileName>" & xmlFileName & "</zf:DocumentFileName>" &
|
||||
"<zf:Version>2.1</zf:Version>" &
|
||||
"<zf:ConformanceLevel>EN 16931</zf:ConformanceLevel>" &
|
||||
"</rdf:Description>" &
|
||||
"</rdf:RDF>" &
|
||||
"</x:xmpmeta>" &
|
||||
"<?xpacket end=""w""?>"
|
||||
|
||||
stamper.XmpMetadata = Encoding.UTF8.GetBytes(xmp)
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
Public Shared Function addAttachementToPDF(File As String, attPath As String, Optional renameFile As String = "") As String
|
||||
Try
|
||||
|
||||
@@ -2496,9 +2605,9 @@ Public Class barcodeToPdf
|
||||
Public width As Integer
|
||||
Public height As Integer
|
||||
Public onpage = 1
|
||||
Public rotate As Drawing.RotateFlipType = RotateFlipType.RotateNoneFlipNone
|
||||
Public rotate As System.Drawing.RotateFlipType = RotateFlipType.RotateNoneFlipNone
|
||||
|
||||
Sub New(image As Image, x As Integer, y As Integer, width As Integer, height As Integer, onpage As Integer, rotate As Drawing.RotateFlipType)
|
||||
Sub New(image As Image, x As Integer, y As Integer, width As Integer, height As Integer, onpage As Integer, rotate As System.Drawing.RotateFlipType)
|
||||
Me.image = image
|
||||
Me.x = x
|
||||
Me.y = y
|
||||
|
||||
Reference in New Issue
Block a user