XDoc.PDF
Features
Tech Specs
How-to VB.NET
Pricing
How to Start Convert PDF Work with PDF Modules PDF Document PDF Pages Text Image Graph & Path Annotation, Markup & Drawing Redaction Security Digital Signature Forms Watermark Bookmark Link File Attachment File Metadata Printing Work with Other SDKs Barcode read Barcode create OCR Twain

Using VB.NET PDF SDK
VB.NET PDF Library: how to crop pdf pages using visual basic .net


VB.NET Demo Code to crop pdf pages using vb.net














VB.NET retrieve box boundary settings in a PDF page


Dim inputFilePath As String = "C:\1.pdf"

' Open file And get the target page
Dim doc As PDFDocument = New PDFDocument(inputFilePath)
Dim page As PDFPage = doc.GetPage(0)

' Get media box of the target page.
Dim bbox As Single() = page.GetPageBoundary(PDFPageBoundaryType.MediaBox)
Console.WriteLine("Media Box: llx={0}, lly={1}, urx={2}, ury={3}", bbox(0), bbox(1), bbox(2), bbox(3))
' Get crop box of the target page.
bbox = page.GetPageBoundary(PDFPageBoundaryType.CropBox)
If bbox IsNot Nothing Then
    Console.WriteLine("Crop Box: llx={0}, lly={1}, urx={2}, ury={3}", bbox(0), bbox(1), bbox(2), bbox(3))
Else
    Console.WriteLine("No Crop Box")
End If
' Get bleed box of the target page.
bbox = page.GetPageBoundary(PDFPageBoundaryType.BleedBox)
If bbox IsNot Nothing Then
    Console.WriteLine("Bleed Box: llx={0}, lly={1}, urx={2}, ury={3}", bbox(0), bbox(1), bbox(2), bbox(3))
Else
    Console.WriteLine("No Bleed Box")
End If
' Get trim box of the target page.
bbox = page.GetPageBoundary(PDFPageBoundaryType.TrimBox)
If bbox IsNot Nothing Then
    Console.WriteLine("Trim Box: llx={0}, lly={1}, urx={2}, ury={3}", bbox(0), bbox(1), bbox(2), bbox(3))
Else
    Console.WriteLine("No Trim Box")
End If
' Get art box of the target page.
bbox = page.GetPageBoundary(PDFPageBoundaryType.ArtBox)
If bbox IsNot Nothing Then
    Console.WriteLine("Art Box: llx={0}, lly={1}, urx={2}, ury={3}", bbox(0), bbox(1), bbox(2), bbox(3))
Else
    Console.WriteLine("No Art Box")
End If




VB.NET update box boundary settings in a PDF page


Dim inputFilePath As String = "C:\1.pdf"
Dim outputFilePath As String = "C:\output.pdf"

' Open file And get the target page
Dim doc As PDFDocument = New PDFDocument(inputFilePath)
Dim page As PDFPage = doc.GetPage(0)

Dim bbox As Single() = page.GetPageBoundary(PDFPageBoundaryType.MediaBox)
' Add (Or update) bleed box.
page.SetPageBoundary(PDFPageBoundaryType.BleedBox, bbox(0) + 20, bbox(1) + 20, bbox(2) - 50, bbox(3) - 60)
' Add (Or update) trim box.
page.SetPageBoundary(PDFPageBoundaryType.TrimBox, bbox(0) + 60, bbox(1) + 40, bbox(2) - 100, bbox(3) - 160)
' Add (Or update) art box.
page.SetPageBoundary(PDFPageBoundaryType.ArtBox, bbox(0) + 90, bbox(1) + 50, bbox(2) - 150, bbox(3) - 260)

' Save file
doc.Save(outputFilePath)