pdfa conversion

This commit is contained in:
Jonathan Jenne 2023-12-14 10:46:10 +01:00
parent f50a19d537
commit 27a611e8dc

View File

@ -160,26 +160,36 @@ Namespace Jobs
Using oFinalStream As New MemoryStream()
Using oDocumentPDF As New GdPicturePDF()
Using oReportPDF As New GdPicturePDF()
Dim oStatus As GdPictureStatus = GdPictureStatus.OK
' Load the source file into memory
oDocumentPDF.LoadFromStream(oDocumentStream, True)
If oDocumentPDF.GetStat() Then
Throw New MergeDocumentException($"Document could not be loaded: {oDocumentPDF.GetStat}")
oStatus = oDocumentPDF.GetStat()
If oStatus <> GdPictureStatus.OK Then
Throw New MergeDocumentException($"Document could not be loaded: {oStatus}")
End If
' Load the report file into memory
oReportPDF.LoadFromStream(oReportStream, True)
If oDocumentPDF.GetStat() Then
Throw New MergeDocumentException($"Report could not be loaded: {oDocumentPDF.GetStat}")
oStatus = oReportPDF.GetStat()
If oStatus <> GdPictureStatus.OK Then
Throw New MergeDocumentException($"Report could not be loaded: {oStatus}")
End If
' Merge the documents
Dim oMergedPDF = oDocumentPDF.Merge2Documents(oDocumentPDF, oReportPDF)
If oDocumentPDF.GetStat() Then
Throw New MergeDocumentException($"Documents could not be merged: {oDocumentPDF.GetStat}")
oStatus = oMergedPDF.GetStat()
If oStatus <> GdPictureStatus.OK Then
Throw New MergeDocumentException($"Documents could not be merged: {oStatus}")
End If
oMergedPDF.SaveToStream(oFinalStream)
' Convert to PDF/A
oMergedPDF.ConvertToPDFA(oFinalStream, PdfConversionConformance.PDF_A_1b, True, True)
oStatus = oDocumentPDF.GetStat()
If oStatus <> GdPictureStatus.OK Then
Throw New MergeDocumentException($"Document could not be converted to PDF/A: {oStatus}")
End If
Return oFinalStream.ToArray()
End Using