This method is suitable for bitmap based PDF Documents.
Advantages:
- Can convert any existing PDF to PDF/A compliant.
- For bitmap-based PDF, each original bitmap is kept "as is".
- Generated PDF size can be highly reduced if JBIG2 compression is used (for bitmap based PDF only).
Inconvenient:
- For vector content based PDF the quality is reduced and the file size will be probably dramatically higher.
- All layers of the PDF will be merged.
- Hidden text will be dropped.
Code: Select all
Const DPI_RENDERING As Single = 200.0F
Const RENDER_FORMS As Boolean = True
Dim srcPDF As New GdPicturePDF
Dim dstPDF As New GdPicturePDF
Dim oGdPictureImaging As New GdPictureImaging
If srcPDF.LoadFromFile("c:\test.pdf", False) = GdPictureStatus.OK Then
dstPDF.NewPDF(True)
For i As Integer = 1 To srcPDF.GetPageCount()
srcPDF.SelectPage(i)
Dim imageID As Integer = srcPDF.RenderPageToGdPictureImageEx(DPI_RENDERING, RENDER_FORMS)
If imageID <> 0 Then
dstPDF.AddImageFromGdPictureImage(imageID, False, True)
oGdPictureImaging.ReleaseGdPictureImage(imageID)
Else
MsgBox("error, can not render page: " + i.ToString() + ". Status: " + srcPDF.GetStat().ToString)
End If
Next
dstPDF.SaveToFile("c:\newpdf.pdf")
dstPDF.CloseDocument()
srcPDF.CloseDocument()
End If