pdfa conversion
This commit is contained in:
parent
f50a19d537
commit
27a611e8dc
@ -160,26 +160,36 @@ Namespace Jobs
|
|||||||
Using oFinalStream As New MemoryStream()
|
Using oFinalStream As New MemoryStream()
|
||||||
Using oDocumentPDF As New GdPicturePDF()
|
Using oDocumentPDF As New GdPicturePDF()
|
||||||
Using oReportPDF As New GdPicturePDF()
|
Using oReportPDF As New GdPicturePDF()
|
||||||
|
Dim oStatus As GdPictureStatus = GdPictureStatus.OK
|
||||||
|
|
||||||
' Load the source file into memory
|
' Load the source file into memory
|
||||||
oDocumentPDF.LoadFromStream(oDocumentStream, True)
|
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
|
End If
|
||||||
|
|
||||||
' Load the report file into memory
|
' Load the report file into memory
|
||||||
oReportPDF.LoadFromStream(oReportStream, True)
|
oReportPDF.LoadFromStream(oReportStream, True)
|
||||||
If oDocumentPDF.GetStat() Then
|
oStatus = oReportPDF.GetStat()
|
||||||
Throw New MergeDocumentException($"Report could not be loaded: {oDocumentPDF.GetStat}")
|
If oStatus <> GdPictureStatus.OK Then
|
||||||
|
Throw New MergeDocumentException($"Report could not be loaded: {oStatus}")
|
||||||
End If
|
End If
|
||||||
|
|
||||||
' Merge the documents
|
' Merge the documents
|
||||||
Dim oMergedPDF = oDocumentPDF.Merge2Documents(oDocumentPDF, oReportPDF)
|
Dim oMergedPDF = oDocumentPDF.Merge2Documents(oDocumentPDF, oReportPDF)
|
||||||
If oDocumentPDF.GetStat() Then
|
oStatus = oMergedPDF.GetStat()
|
||||||
Throw New MergeDocumentException($"Documents could not be merged: {oDocumentPDF.GetStat}")
|
If oStatus <> GdPictureStatus.OK Then
|
||||||
|
Throw New MergeDocumentException($"Documents could not be merged: {oStatus}")
|
||||||
End If
|
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()
|
Return oFinalStream.ToArray()
|
||||||
End Using
|
End Using
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user