Using VB.NET PDF SDK
VB.NET PDF Library: how to add, remove, update PDF page background using vb.net
VB.NET Demo Code to add, remove, update PDF page background using vb.net
VB.NET: apply page background settings to a PDF document object
Dim inputFilePath As String = "C:\1.pdf"
Dim outputFilePath As String = "C:\1_backgd.pdf"
' open a PDF file
Dim doc As PDFDocument = New PDFDocument(inputFilePath)
Dim resBackground As PDFBackgroudRes = New PDFBackgroundFillColorRes(Color.Yellow)
' define a page background setting
Dim background1 As PDFPageBackground = New PDFPageBackground(resBackground)
background1.Opacity = 0.2F
' define page range all odd pages
Dim pageRange1 As PageRangeOptions = New PageRangeOptions()
pageRange1.AllPages = True
pageRange1.Subset = PageRangeSubset.Odd
' apply page background settings to all odd pages
PDFPageFieldHandler.ApplyBackground(doc, background1, pageRange1)
' define a page background setting
Dim background2 As PDFPageBackground = New PDFPageBackground(resBackground)
background2.Opacity = 0.2F
' define page range all even pages
Dim pageRange2 As PageRangeOptions = New PageRangeOptions()
pageRange2.AllPages = True
pageRange2.Subset = PageRangeSubset.Even
' apply page background settings to all even pages
PDFPageFieldHandler.ApplyBackground(doc, background2, pageRange2)
doc.Save(outputFilePath)
VB.NET remove all page background settings in a PDF document object
Dim inputFilePath As String = "C:\1_backgd.pdf"
Dim outputFilePath As String = "C:\output.pdf"
Dim doc As PDFDocument = New PDFDocument(inputFilePath)
PDFPageFieldHandler.RemoveBackgrounds(doc)
doc.Save(outputFilePath)
VB.NET retrieve all page background settings from a PDF file
Dim inputFilePath As String = "C:\1_backgd.pdf"
Dim doc As PDFDocument = New PDFDocument(inputFilePath)
' get all Background settings in the document
Dim info As PDFPageBackgroundInfo = PDFPageFieldHandler.RetreiveBackgrounds(doc)
' get default setting for Background And Page Range
Dim defaultSetting As PDFPageBackground = info.GetDefaultSetting()
Dim defaultPageRange As PageRangeOptions = info.GetDefaultPageRangeSettings()