PdfPageBase Class
The abstract base class for all pages, Provides methods and properties to create PDF pages and its elements
Inherited Members
Namespace: Syncfusion.Pdf
Assembly: Syncfusion.Pdf.Base.dll
Syntax
public abstract class PdfPageBase : IPdfWrapper
Properties
Annotations
Gets the collection of the page's annotations (Read only).
Declaration
public PdfLoadedAnnotationCollection Annotations { get; }
Property Value
Type | Description |
---|---|
PdfLoadedAnnotationCollection | The PdfLoadedAnnotationCollection that represents the page's annotations |
Examples
//Load the document
PdfLoadedDocument lDoc = new PdfLoadedDocument("inputAnnotation.pdf");
//get the first page from the document
PdfLoadedPage page = lDoc.Pages[0] as PdfLoadedPage;
//Get the annotation collection
PdfLoadedAnnotationCollection annotations = page.Annotations;
//Save the document
lDoc.Save("sample.pdf");
lDoc.Close(true);
'Load the document
Dim lDoc As New PdfLoadedDocument("inputAnnotation.pdf")
'Get the first page from the document
Dim page As PdfLoadedPage = TryCast(lDoc.Pages(0), PdfLoadedPage)
'Get the annotation collections
Dim annotations As PdfLoadedAnnotationCollection = page.Annotations
'Save the document
lDoc.Save("sample.pdf")
lDoc.Close(True)
See Also
DefaultLayer
Gets the default layer of the page (Read only).
Declaration
public PdfPageLayer DefaultLayer { get; }
Property Value
Type | Description |
---|---|
PdfPageLayer | The PdfPageLayer of the Page |
Examples
//Create new document.
PdfDocument document = new PdfDocument();
//Set page size.
document.PageSettings = new PdfPageSettings(new SizeF(350, 300));
//Add new page.
PdfPage page = document.Pages.Add();
//Create new instance for PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 16);
//Draw the text.
page.Graphics.DrawString("Layers", font, PdfBrushes.DarkBlue, new PointF(150, 10));
//Add the first layer
page.Layers.Add();
//Get default layer graphics.
PdfGraphics graphics = page.DefaultLayer.Graphics;
graphics.TranslateTransform(100, 60);
//Create new instance for PDF pen.
PdfPen pen = new PdfPen(Color.Red, 50);
RectangleF rect = new RectangleF(0, 0, 50, 50);
//Draw arc.
graphics.DrawArc(pen, rect, 360, 360);
pen = new PdfPen(Color.Blue, 30);
graphics.DrawArc(pen, 0, 0, 50, 50, 360, 360);
pen = new PdfPen(Color.Yellow, 20);
graphics.DrawArc(pen, rect, 360, 360);
pen = new PdfPen(Color.Green, 10);
graphics.DrawArc(pen, 0, 0, 50, 50, 360, 360);
//Add another layer on the page
page.Layers.Add();
//Increment the layer
page.DefaultLayerIndex += 1;
graphics = page.DefaultLayer.Graphics;
graphics.TranslateTransform(100, 180);
graphics.SkewTransform(0, 50);
//Draw another set of elements
pen = new PdfPen(Color.Red, 50);
graphics.DrawArc(pen, rect, 360, 360);
pen = new PdfPen(Color.Blue, 30);
graphics.DrawArc(pen, 0, 0, 50, 50, 360, 360);
pen = new PdfPen(Color.Yellow, 20);
graphics.DrawArc(pen, rect, 360, 360);
pen = new PdfPen(Color.Green, 10);
graphics.DrawArc(pen, 0, 0, 50, 50, 360, 360);
//Save the pdf document.
document.Save("Layer.pdf");
//Close the document.
document.Close(true);
'Create new document.
Dim document As PdfDocument = New PdfDocument()
'Set page size.
document.PageSettings = New PdfPageSettings(New SizeF(350, 300))
'Add new page.
Dim page As PdfPage = document.Pages.Add()
'Create new instance for PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 16)
'Draw the text.
page.Graphics.DrawString("Layers", font, PdfBrushes.DarkBlue, New PointF(150, 10))
'Add the first layer
page.Layers.Add()
'Get default layer graphics.
Dim graphics As PdfGraphics = page.DefaultLayer.Graphics
graphics.TranslateTransform(100, 60)
'Create new instance for PDF pen.
Dim pen As PdfPen = New PdfPen(Color.Red, 50)
Dim rect As RectangleF = New RectangleF(0, 0, 50, 50)
'Draw arc.
graphics.DrawArc(pen, rect, 360, 360)
pen = New PdfPen(Color.Blue, 30)
graphics.DrawArc(pen, 0, 0, 50, 50, 360, 360)
pen = New PdfPen(Color.Yellow, 20)
graphics.DrawArc(pen, rect, 360, 360)
pen = New PdfPen(Color.Green, 10)
graphics.DrawArc(pen, 0, 0, 50, 50, 360, 360)
'Add another layer on the page
page.Layers.Add()
'Increment the layer
page.DefaultLayerIndex += 1
graphics = page.DefaultLayer.Graphics
graphics.TranslateTransform(100, 180)
graphics.SkewTransform(0, 50)
'Draw another set of elements
pen = New PdfPen(Color.Red, 50)
graphics.DrawArc(pen, rect, 360, 360)
pen = New PdfPen(Color.Blue, 30)
graphics.DrawArc(pen, 0, 0, 50, 50, 360, 360)
pen = New PdfPen(Color.Yellow, 20)
graphics.DrawArc(pen, rect, 360, 360)
pen = New PdfPen(Color.Green, 10)
graphics.DrawArc(pen, 0, 0, 50, 50, 360, 360)
'Save and close the document.
document.Save("Layer.pdf")
document.Close(True)
See Also
DefaultLayerIndex
Gets or sets index of the default layer.
Declaration
public int DefaultLayerIndex { get; set; }
Property Value
Type |
---|
System.Int32 |
Examples
//Create new document.
PdfDocument document = new PdfDocument();
//Set page size.
document.PageSettings = new PdfPageSettings(new SizeF(350, 300));
//Add new page.
PdfPage page = document.Pages.Add();
//Create new instance for PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 16);
//Draw the text.
page.Graphics.DrawString("Layers", font, PdfBrushes.DarkBlue, new PointF(150, 10));
//Add the first layer
page.Layers.Add();
//Get default layer graphics.
PdfGraphics graphics = page.DefaultLayer.Graphics;
graphics.TranslateTransform(100, 60);
//Create new instance for PDF pen.
PdfPen pen = new PdfPen(Color.Red, 50);
RectangleF rect = new RectangleF(0, 0, 50, 50);
//Draw arc.
graphics.DrawArc(pen, rect, 360, 360);
pen = new PdfPen(Color.Blue, 30);
graphics.DrawArc(pen, 0, 0, 50, 50, 360, 360);
pen = new PdfPen(Color.Yellow, 20);
graphics.DrawArc(pen, rect, 360, 360);
pen = new PdfPen(Color.Green, 10);
graphics.DrawArc(pen, 0, 0, 50, 50, 360, 360);
//Add another layer on the page
page.Layers.Add();
//Increment the layer
page.DefaultLayerIndex += 1;
graphics = page.DefaultLayer.Graphics;
graphics.TranslateTransform(100, 180);
graphics.SkewTransform(0, 50);
//Draw another set of elements
pen = new PdfPen(Color.Red, 50);
graphics.DrawArc(pen, rect, 360, 360);
pen = new PdfPen(Color.Blue, 30);
graphics.DrawArc(pen, 0, 0, 50, 50, 360, 360);
pen = new PdfPen(Color.Yellow, 20);
graphics.DrawArc(pen, rect, 360, 360);
pen = new PdfPen(Color.Green, 10);
graphics.DrawArc(pen, 0, 0, 50, 50, 360, 360);
//Save the pdf document.
document.Save("Layer.pdf");
//Close the document.
document.Close(true);
'Create new document.
Dim document As PdfDocument = New PdfDocument()
'Set page size.
document.PageSettings = New PdfPageSettings(New SizeF(350, 300))
'Add new page.
Dim page As PdfPage = document.Pages.Add()
'Create new instance for PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 16)
'Draw the text.
page.Graphics.DrawString("Layers", font, PdfBrushes.DarkBlue, New PointF(150, 10))
'Add the first layer
page.Layers.Add()
'Get default layer graphics.
Dim graphics As PdfGraphics = page.DefaultLayer.Graphics
graphics.TranslateTransform(100, 60)
'Create new instance for PDF pen.
Dim pen As PdfPen = New PdfPen(Color.Red, 50)
Dim rect As RectangleF = New RectangleF(0, 0, 50, 50)
'Draw arc.
graphics.DrawArc(pen, rect, 360, 360)
pen = New PdfPen(Color.Blue, 30)
graphics.DrawArc(pen, 0, 0, 50, 50, 360, 360)
pen = New PdfPen(Color.Yellow, 20)
graphics.DrawArc(pen, rect, 360, 360)
pen = New PdfPen(Color.Green, 10)
graphics.DrawArc(pen, 0, 0, 50, 50, 360, 360)
'Add another layer on the page
page.Layers.Add()
'Increment the layer
page.DefaultLayerIndex += 1
graphics = page.DefaultLayer.Graphics
graphics.TranslateTransform(100, 180)
graphics.SkewTransform(0, 50)
'Draw another set of elements
pen = New PdfPen(Color.Red, 50)
graphics.DrawArc(pen, rect, 360, 360)
pen = New PdfPen(Color.Blue, 30)
graphics.DrawArc(pen, 0, 0, 50, 50, 360, 360)
pen = New PdfPen(Color.Yellow, 20)
graphics.DrawArc(pen, rect, 360, 360)
pen = New PdfPen(Color.Green, 10)
graphics.DrawArc(pen, 0, 0, 50, 50, 360, 360)
'Save and close the document.
document.Save("Layer.pdf")
document.Close(True)
See Also
FormFieldsTabOrder
Gets or sets the tab order type for form fields
Declaration
public PdfFormFieldsTabOrder FormFieldsTabOrder { get; set; }
Property Value
Type |
---|
PdfFormFieldsTabOrder |
Examples
//Create a new document.
PdfDocument document = new PdfDocument();
//Create a new page.
PdfPage page = document.Pages.Add();
//Set form fields tab order.
page.FormFieldsTabOrder = PdfFormFieldsTabOrder.Manual;
//Create new text box field.
PdfTextBoxField field = new PdfTextBoxField(page, "Hello");
//Set field tab index as 3.
field.TabIndex = 3;
//Set field bounds.
field.Bounds = new RectangleF(0, 0, 100, 30);
//Create new text box field.
PdfTextBoxField field1 = new PdfTextBoxField(page, "Hello1");
//Set field tab index as 2.
field.TabIndex = 2;
//Set field bounds.
field1.Bounds = new RectangleF(200, 0, 100, 30);
//Create new text box field.
PdfTextBoxField field2 = new PdfTextBoxField(page, "Hello2");
//Set field tab index as 1.
field.TabIndex = 1;
//Set field bounds.
field2.Bounds = new RectangleF(0, 50, 100, 30);
//Create new text box field.
PdfTextBoxField field3 = new PdfTextBoxField(page, "Hello3");
//Set field tab index as 0.
field.TabIndex = 0;
//Set field bounds.
field3.Bounds = new RectangleF(200, 50, 100, 30);
//Adds the form field to the document.
document.Form.Fields.Add(field);
document.Form.Fields.Add(field1);
document.Form.Fields.Add(field2);
document.Form.Fields.Add(field3);
//Save the pdf document.
document.Save("TabOrder.pdf");
//Close the document.
document.Close(true);
'Create a new PDF document.
Dim document As PdfDocument = New PdfDocument()
'Creates a new page.
Dim page As PdfPage = document.Pages.Add()
'Set form fields tab order.
page.FormFieldsTabOrder = PdfFormFieldsTabOrder.Manual
'Create new text box field.
Dim field As PdfTextBoxField = New PdfTextBoxField(page, "Hello")
'Set field tab index as 3.
field.TabIndex = 3
'Set field bounds.
field.Bounds = New RectangleF(0, 0, 100, 30)
'Create new text box field.
Dim field1 As PdfTextBoxField = New PdfTextBoxField(page, "Hello1")
'Set field tab index as 2.
field.TabIndex = 2
'Set field bounds.
field1.Bounds = New RectangleF(200, 0, 100, 30)
'Create new text box field.
Dim field2 As PdfTextBoxField = New PdfTextBoxField(page, "Hello2")
'Set field tab index as 1.
field.TabIndex = 1
'Set field bounds.
field2.Bounds = New RectangleF(0, 50, 100, 30)
'Create new text box field.
Dim field3 As PdfTextBoxField = New PdfTextBoxField(page, "Hello3")
'Set field tab index as 0.
field.TabIndex = 0
'Set field bounds.
field3.Bounds = New RectangleF(200, 50, 100, 30)
'Adds the form field to the document.
document.Form.Fields.Add(field)
document.Form.Fields.Add(field1)
document.Form.Fields.Add(field2)
document.Form.Fields.Add(field3)
'Save document to disk.
document.Save("TabOrder.pdf")
'Close the document.
document.Close(True)
See Also
Graphics
Gets the graphics of the DefaultLayer.
Declaration
public PdfGraphics Graphics { get; }
Property Value
Type | Description |
---|---|
PdfGraphics | The PdfGraphics that represents a graphics of the page. |
Examples
//Create a PDF document
PdfDocument document = new PdfDocument();
//Create a PDF page
PdfPage page = document.Pages.Add();
//Get graphics
PdfGraphics graphics = page.Graphics;
//Draw a rectangle
graphics.DrawRectangle(PdfBrushes.Red, new RectangleF(0, 0, 100, 200));
//Save and close the document
document.Save("output.pdf");
document.Close(true);
'Create a PDF document
Dim document As New PdfDocument()
'Create a PDF page
Dim page As PdfPage = document.Pages.Add()
'Get graphics
Dim graphics As PdfGraphics = page.Graphics
'Draw a rectangle
graphics.DrawRectangle(PdfBrushes.Red, New RectangleF(0, 0, 100, 200))
'Save and close the document
document.Save("output.pdf")
document.Close(True)
See Also
ImagesInfo
Gets the information about the extracted image from the PDF page
Declaration
public PdfImageInfo[] ImagesInfo { get; }
Property Value
Type |
---|
PdfImageInfo[] |
Remarks
This property is not supported in WinRT, Windows Phone, Xamarin, Universal Windows Platform and Silverlight.
Examples
//Load PDF document.
PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf");
//Gets ImageInfo from the first page.
PdfImageInfo[] imageInfo = document.Pages[0].ImagesInfo;
//Gets the Image Boundary location.
RectangleF imageBounds = imageInfo[0].Bounds;
//Gets the Image.
Image image = imageInfo[0].Image;
//Gets the Image index.
int imageIndex = imageInfo[0].Index;
//Closing the PDF document.
document.Close(true);
'Load PDF document.
Dim document As New PdfLoadedDocument("Input.pdf")
'Gets ImageInfo from the first page.
Dim imageInfo As PdfImageInfo() = document.Pages(0).ImagesInfo
'Gets the Image Boundary location.
Dim imageBounds As RectangleF = imageInfo(0).Bounds
'Gets the Image.
Dim image As Image = imageInfo(0).Image
'Gets the Image index.
Dim imageIndex As Integer = imageInfo(0).Index
'Closing the PDF document.
document.Close(True)
See Also
IsBlank
Gets the PdfLoadedPage is blank or not;Default value is false
Declaration
public bool IsBlank { get; }
Property Value
Type |
---|
System.Boolean |
Examples
//load the existing pdf document
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf");
//set the bool value
bool value = true;
//load first page
bool page = loadedDocument.Pages[0].IsBlank;
//return the bool value of IsBlank property
page.Equals(value);
//close the loaded document
loadedDocument.Close(true)
'load the existing pdf document.
Dim loadedDocument As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf")
'set the bool value
Dim value As Boolean = True
'load first page.
Dim page As Boolean = loadedDocument.Pages(0).IsBlank
'return the bool value of IsBlank property.
page.Equals(value)
'close the loaded document.
loadedDocument.Close(True)
IsColored
Return true, when the page contains colored content.
Declaration
public bool IsColored { get; }
Property Value
Type |
---|
System.Boolean |
Layers
Gets the collection of the page's layers (Read only).
Declaration
public PdfPageLayerCollection Layers { get; }
Property Value
Type | Description |
---|---|
PdfPageLayerCollection | The PdfPageLayerCollection that represents the page's layers |
Examples
//Create a PDF document
PdfDocument document = new PdfDocument();
//Add page to the document
PdfPage page=document.Pages.Add();
//Get the page layer
PdfPageLayerCollection angle = page.Layers;
//Save and close the PDF document
document.Save("output.Pdf");
document.Close(true);
'Create a PDF document
Dim document As New PdfDocument()
'Add page to the document
Dim page As PdfPage = document.Pages.Add()
'Get the page layer
Dim angle As PdfPageLayerCollection = page.Layers
'Save and close the PDF document
document.Save("output.Pdf")
document.Close(True)
See Also
Rotation
Gets or sets the PDF page rotation.
Declaration
public PdfPageRotateAngle Rotation { get; set; }
Property Value
Type | Description |
---|---|
PdfPageRotateAngle | The PdfPageRotateAngle that represents the page rotation |
Examples
//Create a PDF document
PdfDocument document = new PdfDocument();
//Create a page
PdfPage page = new PdfPage();
//Insert page in the document
document.Pages.Insert(0, page);
//Get rotation
PdfPageRotateAngle angle = page.Rotation;
//Save and close the PDF document
document.Save("output.Pdf");
document.Close(true);
'Create a PDF document
Dim document As New PdfDocument()
'Create a page
Dim page As New PdfPage()
'Insert page in the document
document.Pages.Insert(0, page)
'Get rotation
Dim angle As PdfPageRotateAngle = page.Rotation
'Save and close the PDF document
document.Save("output.Pdf")
document.Close(True)
Size
Gets the size of the page (Read only).
Declaration
public abstract SizeF Size { get; }
Property Value
Type |
---|
System.Drawing.SizeF |
Examples
//Load an existing document.
PdfLoadedDocument ldoc = new PdfLoadedDocument("Input.pdf");
//Get size of first page
SizeF size = ldoc.Pages[0].Size;
//Save and close the document.
ldoc.Save("Output.pdf");
ldoc.Close(true);
'Load an existing document.
Dim ldoc As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf")
'Get size of first page
Dim size As SizeF = ldoc.Pages(0).Size
'Save and close the document.
ldoc.Save("Output.pdf")
ldoc.Close(True)
See Also
Methods
CreateTemplate()
Creates a template from page content and all annotation appearances.
Declaration
public PdfTemplate CreateTemplate()
Returns
Type | Description |
---|---|
PdfTemplate | The created PdfTemplate. |
Examples
//Load an existing PDF.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(fileName);
//Load the page
PdfLoadedPage loadedPage = loadedDocument.Pages[0] as PdfLoadedPage;
//Create the template from the page.
PdfTemplate template = loadedPage.CreateTemplate();
//Create a new PDF document
PdfDocument document = new PdfDocument();
//Set the document margin
document.PageSettings.SetMargins(2);
//Add the page
PdfPage page = document.Pages.Add();
//Create the graphics
PdfGraphics graphics = page.Graphics;
//Draw the template
graphics.DrawPdfTemplate(template, PointF.Empty,new SizeF(page.Size.Width/2,page.Size.Height));
//Save the new document.
document.Save("output.pdf");
//Close the documents
loadedDocument.Close(true);
document.Close(true);
'Load the existing PDF document.
Dim loadedDocument As New PdfLoadedDocument(fileName)
'Load the page
Dim loadedPage As PdfLoadedPage = TryCast(loadedDocument.Pages(0), PdfLoadedPage)
'Create the template from the page.
Dim template As PdfTemplate = loadedPage.CreateTemplate()
'Create a new PDF document
Dim document As New PdfDocument()
'Set the document margin
document.PageSettings.SetMargins(2)
'Add the page
Dim page As PdfPage = document.Pages.Add()
'Create the graphics
Dim graphics As PdfGraphics = page.Graphics
'Draw the template
graphics.DrawPdfTemplate(template, PointF.Empty, New SizeF(page.Size.Width \ 2, page.Size.Height))
'Save the new document.
document.Save("output.pdf")
'Close the documents
loadedDocument.Close(True)
ExtractImages()
Extract the images from the PDF
Declaration
public Image[] ExtractImages()
Returns
Type | Description |
---|---|
System.Drawing.Image[] | returns the List of images |
Examples
//Load an existing PDF.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(fileName);
//Load first page.
PdfPageBase pageBase = loadedDocument.Pages[0];
//Extract images from first page.
Image[] extractedImages = pageBase.ExtractImages();
//close the document
loadedDocument.Close(true);
'Load an existing PDF
Dim loadedDocument As New PdfLoadedDocument(fileName)
'Load first page.
Dim pageBase As PdfPageBase = loadedDocument.Pages(0)
'Extract images from first page.
Dim extractedImages As Image() = pageBase.ExtractImages()
'close the document.
loadedDocument.Close(True)
ExtractText()
Extracts text from the PDF Page.
Declaration
public string ExtractText()
Returns
Type | Description |
---|---|
System.String | The Extracted Text. |
Examples
//Load an existing PDF.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(fileName);
//Load the first page.
PdfPageBase page = loadedDocument.Pages[0];
//Extract text from first page.
string extractedText = page.ExtractText();
//Close the document
loadedDocument.Close(true);
'Load an existing PDF.
Dim loadedDocument As New PdfLoadedDocument(fileName)
'Load the first page.
Dim page As PdfPageBase = loadedDocument.Pages(0)
'Extract the text from first page.
Dim extractedText As String = page.ExtractText()
'close the document.
loadedDocument.Close(True)
ExtractText(out TextLines)
Extracts text from the page of PDF document with lines and words collection.
Declaration
public string ExtractText(out TextLines textLines)
Parameters
Type | Name | Description |
---|---|---|
TextLines | textLines | Holds the lines with bounds in the page. |
Returns
Type | Description |
---|---|
System.String | The Extracted Text. |
ExtractText(Boolean)
Extracts text from the PDF Page based on its layout
Declaration
public string ExtractText(bool IsLayout)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | IsLayout | Extracts text based on the Layout of PDF Document if the parameter is set to true, else Extracts text normally. |
Returns
Type | Description |
---|---|
System.String | The Extracted Text. |
Remarks
Extracting the text based on the layout may take additional processing time when compared to the normal extraction.
Examples
//Load an existing PDF.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(fileName);
//Load first page.
PdfPageBase page = loadedDocument.Pages[0];
//Extract text from first page.
string extractedTexts = page.ExtractText(true);
//close the document
loadedDocument.Close(true);
'Load an existing PDF.
Dim loadedDocument As New PdfLoadedDocument(fileName)
'Load first page.
Dim page As PdfPageBase = loadedDocument.Pages(0)
'Extract text from first page.
Dim extractedTexts As String = page.ExtractText(True)
'close the document
loadedDocument.Close(True)
ExtractText(out List<TextData>)
Extracts text along with its format from the PDF Page.
Declaration
public string ExtractText(out List<TextData> textDataCollection)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.List<TextData> | textDataCollection | Provides the text data collection |
Returns
Type | Description |
---|---|
System.String | Returns the extracted text. |
ParseContentStream(Int32, Matrix, List<String>)
specifies whether check skip node.
Declaration
protected bool ParseContentStream(int index, Matrix currentMatrix, List<string> keys)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | |
System.Drawing.Drawing2D.Matrix | currentMatrix | |
System.Collections.Generic.List<System.String> | keys |
Returns
Type |
---|
System.Boolean |
RemoveImage(PdfImageInfo)
Remove the image from PDF page in existing PDF document
Declaration
public void RemoveImage(PdfImageInfo imageInfo)
Parameters
Type | Name | Description |
---|---|---|
PdfImageInfo | imageInfo |
Examples
//Load an existing PDF.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(fileName);
//Load first page.
PdfPageBase pageBase = loadedDocument.Pages[0];
//Extract images from first page.
PdfImageInfo imageInfo = loadedDocument.Pages[0].ImagesInfo[0];
//Remove the Image.
loadedDocument.Pages[0].RemoveImage(imageInfo);
// Save the document.
loadedDocument.Save("output.pdf");
//close the document
loadedDocument.Close(true);
'Load an existing PDF
Dim loadedDocument As PdfLoadedDocument = New PdfLoadedDocument(fileName)
'Load first page.
Dim pageBase As PdfPageBase = loadedDocument.Pages(0)
'Extract images from first page.
Dim imageInfo As PdfImageInfo = loadedDocument.Pages(0).ImagesInfo(0)
'Remove the Image.
loadedDocument.Pages(0).RemoveImage(imageInfo)
' Save the document.
loadedDocument.Save("output.pdf")
'close the document
loadedDocument.Close(True)
ReplaceImage(Int32, PdfImage)
Replace the Image at index's Position.
Declaration
public void ReplaceImage(int imageIndex, PdfImage image)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | imageIndex | |
PdfImage | image | The New Replace image |
Examples
//Load the PDF document
PdfLoadedDocument doc = new PdfLoadedDocument(@"input.pdf");
//Create an image instance
PdfBitmap bmp = new PdfBitmap(@"Autumn Leaves.jpg");
//Replace the first image in the page.
doc.Pages[0].ReplaceImage(0, bmp);
//Save the document
doc.Save("output.pdf");
//Close the document
doc.Close(true);
'Load the PDF document///Dim doc As New PdfLoadedDocument("input.pdf")
'Create an image instance
Dim bmp As New PdfBitmap("Autumn Leaves.jpg")
'Replace the first image in the page.
doc.Pages(0).ReplaceImage(0, bmp)
'Save the document
doc.Save("output.pdf")
'Close the document
doc.Close(True)