| PDF Xpress for .NET - User Guide > How To > Modify PDF Document Content > Create & Delete Thumbnails |
Within a PDF document, each page may have zero or one thumbnail images associated with it. These thumbnails are stored within the PDF document. PDF Xpress™ can be used to create or delete thumbnails within the PDF document.
Thumbnails can be created on a specified page from image information accessed from file, handle, memory, or ImageDataInfo object. To create a thumbnail, use the CreateThumbnail methods.
| C# Example |
Copy Code
|
|---|---|
// This code demonstrates how to add a thumbnail from a file
Accusoft.PdfXpressSdk.PdfXpress pdfXpress1 = null;
Document document = null;
try
{
pdfXpress1 = new PdfXpress();
pdfXpress1.Initialize();
document = new Document(pdfXpress1, " C:\test.pdf");
document.CreateThumbnail(0, "C:\testImage.jpg", 0);
}
catch (System.Exception)
{
}
finally
{
if (null != document)
{
document.Dispose();
}
if (null != pdfXpress1)
{
pdfXpress1.Dispose();
}
}
|
|
| C# Example |
Copy Code
|
|---|---|
// This code demonstrates how to add a thumbnail from Global Memory
public void AddThumbnailFromGlobalMemory(Document document, Int32 pageIndex, IntPtr globalBufferHandlePtr, Int32 imagePageIndex)
{
try
{
document.CreateThumbnail(pageIndex, globalBufferHandlePtr, imagePageIndex);
}
catch (PdfXpressLibraryException)
{
// A problem was encountered attempting to add thumbnail.
}
catch (PdfXpressException)
{
// A problem was encountered attempting to add thumbnail.
}
finally
{
}
}
|
|
| C# Example |
Copy Code
|
|---|---|
// This code demonstrates how to add a thumbnail from Local Memory
public void AddThumbnailFromLocalMemory(Document document, Int32 pageIndex, byte[] imageData, Int32 imagePageIndex)
{
try
{
document.CreateThumbnail(pageIndex, imageData, imagePageIndex);
}
catch (PdfXpressLibraryException)
{
// A problem was encountered attempting to add thumbnail.
}
catch (PdfXpressException)
{
// A problem was encountered attempting to add thumbnail.
}
finally
{
}
}
|
|
To delete a thumbnail on a specified page of the PDF document, call the DeleteThumbnail method.
| C# Example |
Copy Code
|
|---|---|
// This code demonstrates how to delete a thumbnail
Accusoft.PdfXpressSdk.PdfXpress pdfXpress1 = null;
Document document = null;
try
{
pdfXpress1 = new PdfXpress();
pdfXpress1.Initialize();
document = new Document(pdfXpress1, "C:\\pdfsample.pdf");
document.DeleteThumbnail(0);
}
catch (System.Exception)
{
}
finally
{
if (null != document)
{
document.Dispose();
}
if (null != pdfXpress1)
{
pdfXpress1.Dispose();
}
}
|
|