VB.NET PDF: How to HTML5 PDF Viewer PDF Create PDF Export File & Page Process PDF Read PDF Write Form Process Document Protect Annotation & Drawing PDF Print WPF PDF Viewer Work with Other SDKs Barcode Read Barcode Create OCR Twain
Image: Copy, Paste, Cut Image in Page
  |  
Home ›› XDoc.PDF ›› VB.NET PDF: Copy, Paste, Cut Image in Page

VB.NET PDF - Copy, Paste, Cut PDF Image in VB.NET


VB.NET Tutorial for How to Cut or Copy an Image from One Page and Paste to Another in VB.NET




.NET framework PDF editor SDK control for image copying, pasting and cutting from adobe PDF file in VB.NET


Supported image formats, including Jpeg or Jpg, Png, Gif, Bmp, Tiff and other bitmap images


Help to copy, paste and cut vector image, graphic picture, digital photo, scanned signature, logo, etc


Support .NET WinForms, ASP.NET MVC in IIS, ASP.NET Ajax, Azure cloud service, DNN (DotNetNuke), SharePoint


High quality image can be saved after cutting, copying and pasting into PDF page


Empower to cut, copy and paste a single image, multiple images and whole PDF document images


Allow to copy an image from existing PDF file and paste it into another one


Guarantee high performance image processing by implementing coordinates to locate image position accurately


Copy, paste and cut PDF image while preview without adobe reader component installed


Image resize function allows VB.NET users to zoom and crop image


Free Visual Studio .NET PDF library, easy to be integrated in .NET WinForms and ASP.NET


Online source codes for quick evaluation in VB.NET class program


Besides image extracting, adding, and removing, RasterEdge XDoc.PDF for .NET also supports image copying, pasting, and cutting. VB programming features of this PDF image processing control are similar to C#, more details are listed below.




VB.NET DLLs: Copy, Paste, Cut Image in PDF Page



In order to run the sample code, the following steps would be necessary.


Add necessary references:


  RasterEdge.Imaging.Basic.dll


  RasterEdge.Imaging.Basic.Codec.dll


  RasterEdge.Imaging.Drawing.dll


  RasterEdge.Imaging.Font.dll


  RasterEdge.Imaging.Processing.dll


  RasterEdge.XDoc.Raster.dll


  RasterEdge.XDoc.Raster.Core.dll


  RasterEdge.XDoc.PDF.dll


Use corresponding namespaces;


  using RasterEdge.Imaging.Basic;


  using RasterEdge.XDoc.PDF;




VB.NET: Copy and Paste Image in PDF Page



This VB.NET example shows how to copy an image from one page of PDF document and paste it into another page.




' Define input and output documents.
Dim inputFilePath As String = Program.RootPath + "\\" + "2.pdf"
Dim outputFilePath As String = Program.RootPath + "\\" + "output.pdf"
Dim doc As PDFDocument = New PDFDocument(inputFilePath)

' Get the first page.
Dim pageIndex As Integer = 0
Dim page1 As PDFPage = doc.GetPage(pageIndex)

' Select image at the position (480F, 550F) in the page.
Dim cursorPos As PointF = New PointF(480.0F, 550.0F)
Dim image As PDFImage = PDFImageHandler.SelectImage(page1, cursorPos)

' Copy the image.
Dim anImage As Bitmap = image.Image.Clone()

' Get the second page.
Dim page2 As PDFPage = doc.GetPage(1)

' Set image position in the page: X = 100F, Y = 400F.
Dim position As PointF = New PointF(100.0F, 400.0F)

' Add image to the page.
PDFImageHandler.AddImage(page2, anImage, position)

' Output the new document.
doc.Save(outputFilePath)





VB.NET: Cut Image in PDF Page



PDF image cutting is similar to image deleting. So, below example explains how to cut image from PDF file page by using image deleting API.




Dim inputFilePath As String = Program.RootPath + "\\" + "3.pdf"
Dim outputFilePath As String = Program.RootPath + "\\" + "output.pdf"

' Open a PDF document.
Dim doc As PDFDocument = New PDFDocument(inputFilePath)

' Extract all images from the document.
Dim allImages = PDFImageHandler.ExtractImages(doc)

' Delete all images from the document.
For Each image As PDFImage In allImages
    PDFImageHandler.DeleteImage(doc, image)
Next

' Output the new PDF document.
doc.Save(outputFilePath)