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 Library
How to format PDF Document in VB.NET


VB.NET Demo Code to format Adobe PDF Document














VB.NET PDF Document Window and Page Display Properties




asp.net pdf viewer user control, pdf preview in asp.net c#, asp.net core open excel file, asp.net open word document on client, asp.net pdf writer, asp.net mvc generate pdf from view, asp.net show image from url.







VB.NET: Retrieve viewer preferences


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

' Opne file
Dim doc As PDFDocument = New PDFDocument(inputFilePath)
' Get viewer preferences from the document.
Dim vp As PDFViewerPreferences = doc.GetViewerPreferences()
If vp IsNot Nothing Then
    Console.WriteLine("Hide Toolbar:              {0}", vp.HideToolbar)
    Console.WriteLine("Hide Menubar:              {0}", vp.HideMenubar)
    Console.WriteLine("Hide Window UI:            {0}", vp.HideWindowUI)
    Console.WriteLine("Fit Window:                {0}", vp.FitWindow)
    Console.WriteLine("Center Window:             {0}", vp.CenterWindow)
    Console.WriteLine("Display Doc Title:         {0}", vp.DisplayDocTitle)
    Console.WriteLine("Non Full Screen Page Mode: {0}", vp.NonFullScreenPageMode)
    Dim direction As String = "L2R"
    If vp.IsDirectionR2L Then
        direction = "R2L"
    End If
    Console.WriteLine("Direction:                 {0}", direction)
    Console.WriteLine("View Area:                 {0}", vp.ViewArea)
    Console.WriteLine("View Clip:                 {0}", vp.ViewClip)
    Console.WriteLine("Print Area:                {0}", vp.PrintArea)
    Console.WriteLine("Print Clip:                {0}", vp.PrintClip)
    Console.WriteLine("Use Current Print Scaling: {0}", vp.UsePrintScaling)
    Console.WriteLine("Duplex:                    {0}", vp.Duplex)
    Console.WriteLine("Checkbox in the print dialog associated with input paper tray is checked: {0}", vp.PickTrayByPDFSize)
    Console.WriteLine("Print Page Range:          {0}", vp.GetPrintPageRangeString())
    Console.WriteLine("Number of Copies:          {0}", vp.NumCopies)
Else
    Console.WriteLine("No ViewerPreferences entry in the document.")
End If




VB.NET update viewer preferences


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

' Open file
Dim doc As PDFDocument = New PDFDocument(inputFilePath)

' Initial a New viewer preferences with default settings.
Dim vp As PDFViewerPreferences = New PDFViewerPreferences()
' Hide toolbar when the document Is open.
vp.HideToolbar = True
' Hide menubar when the document Is open.
vp.HideMenubar = True
' Set default print area to MediaBox.
vp.PrintArea = PDFPageBoundaryType.MediaBox
' Set the default print copies to 3 in the print dialog.
vp.NumCopies = 3
' Update the Viewer Preferences
doc.SetViewerPreferences(vp)

' Save file
doc.Save(outputFilePath)




VB.NET remove viewer preferences


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

' Open file
Dim doc As PDFDocument = New PDFDocument(inputFilePath)
' Remove Viewer Preferences in the document. 
doc.SetViewerPreferences(Nothing)
' Save file
doc.Save(outputFilePath)




VB.NET retrieve page layout setting


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

' Open file
Dim doc As PDFDocument = New PDFDocument(inputFilePath)
' Get page layout setting
Dim pageLayout As PDFPageLayout = doc.GetPageLayout()
' Valid Values:
' SinglePage, OneColumn, TwoColumnLeft, TwoColumnRight, TwoPageLeft, TwoPageRight
Console.WriteLine("Page Layout: {0}", pageLayout.ToString())




VB.NET update page layout setting


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

' Open file
Dim doc As PDFDocument = New PDFDocument(inputFilePath)
' Display pages in 2 columns with odd numbered pages on the left.
doc.SetPageLayout(PDFPageLayout.TwoColumnLeft)
' Save file
doc.Save(outputFilePath)




VB.NET retrieve page mode setting


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

' Open file
Dim doc As PDFDocument = New PDFDocument(inputFilePath)
' Get page mode setting
Dim pageMode As PDFPageMode = doc.GetPageMode()
' Valid Values:
' UseNone, UseOutlines, UseThumbs, FullScreen, UseOC, UseAttachments
Console.WriteLine("Page Mode: {0}", pageMode.ToString())




VB.NET update page mode setting


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

' Open file
Dim doc As PDFDocument = New PDFDocument(inputFilePath)
' Show page in Full-screen mode.
doc.SetPageMode(PDFPageMode.FullScreen)
' Save file
doc.Save(outputFilePath)






Zoom Factor of PDF Document using vb.net








VB.NET Retrieve open action setting


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

' Open file
Dim doc As PDFDocument = New PDFDocument(inputFilePath)

' Get Open Action from the document, the return Is a PDF destination.
Dim op As PDFDestination = doc.GetOpenActionDestination()
If op IsNot Nothing Then
    Console.WriteLine("Mode: {0}; Page Index: {1}", op.Mode, op.PageIdx)
Else
    Console.WriteLine("No OpenAction")
End If




VB.NET update open action setting


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

' Open file
Dim doc As PDFDocument = New PDFDocument(inputFilePath)
' Create a /FitB destination for the Open Action, which would show the 2nd page when open the document.
Dim op As PDFDestination = PDFDestination.CreateFitB(1)
' Update open action setting
doc.SetOpenActionDestination(op)
' Save file
doc.Save(outputFilePath)


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

' Open file
Dim doc As PDFDocument = New PDFDocument(inputFilePath)
' Create a /XYZ destination for the Open Action with zoom Is 200% And top-left point Is [0,0].
Dim pageIndex As Integer = 1
Dim startPoint As PointF = New PointF(0, 0)
Dim zoom As Double = 2.0
Dim op As PDFDestination = PDFDestination.CreateXYZ(pageIndex, startPoint.X, startPoint.Y, zoom)
' Update open action setting
doc.SetOpenActionDestination(op)
' Save file
doc.Save(outputFilePath)