Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.Controls
Imports Leadtools.Pdf
Imports Leadtools.Svg
Imports Leadtools.WinForms
<TestMethod> _
Public Sub PDFDocumentImagesExample()
Dim pdfFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Leadtools.pdf")
Dim txtFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "LEAD_pdfImageInfo.txt")
' Save the results to the text file for examining
Using writer As StreamWriter = File.CreateText(txtFileName)
Using document As PDFDocument = New PDFDocument(pdfFileName)
' Look for image objects within the PDF
document.ParseDocumentStructure(PDFParseDocumentStructureOptions.Images)
' Output information about each image
For Each pdfImage As PDFImage In document.Images
WritePdfImageProperties(writer, pdfImage)
Next pdfImage
End Using
End Using
End Sub
Public Sub WritePdfImageProperties(ByVal writer As StreamWriter, ByVal image As PDFImage)
writer.WriteLine("PDFImage.PageNumber: {0}", image.PageNumber.ToString())
writer.WriteLine(" PDFImage.ObjectNumber: {0}", image.ObjectNumber.ToString())
writer.WriteLine(" PDFImage.ColorDevice: {0}", image.ColorDevice.ToString())
writer.WriteLine(" PDFImage.StreamOffset: {0}", image.StreamOffset.ToString())
writer.WriteLine(" PDFImage.StreamLength: {0}", image.StreamLength.ToString())
writer.WriteLine(" PDFImage.BitsPerComponent: {0}", image.BitsPerComponent.ToString())
writer.WriteLine(" PDFImage.ComponentCount: {0}", image.ComponentCount.ToString())
writer.WriteLine(" PDFImage.BitsPerPixel: {0}", image.BitsPerPixel.ToString())
writer.WriteLine(" PDFImage.Width: {0}", image.Width.ToString())
writer.WriteLine(" PDFImage.Height: {0}", image.Height.ToString())
writer.WriteLine(" PDFImage.ImageType: {0}", image.ImageType.ToString())
End Sub
Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Controls;
using Leadtools.Pdf;
using Leadtools.Svg;
using Leadtools.WinForms;
[TestMethod]
public void PDFDocumentImagesExample()
{
string pdfFileName = Path.Combine(LEAD_VARS.ImagesDir, @"Leadtools.pdf");
string txtFileName = Path.Combine(LEAD_VARS.ImagesDir, @"LEAD_pdfImageInfo.txt");
// Save the results to the text file for examining
using (StreamWriter writer = File.CreateText(txtFileName))
using (PDFDocument document = new PDFDocument(pdfFileName))
{
// Look for image objects within the PDF
document.ParseDocumentStructure(PDFParseDocumentStructureOptions.Images);
// Output information about each image
foreach (PDFImage pdfImage in document.Images)
WritePdfImageProperties(writer, pdfImage);
}
}
public void WritePdfImageProperties(StreamWriter writer, PDFImage image)
{
writer.WriteLine("PDFImage.PageNumber: {0}", image.PageNumber.ToString());
writer.WriteLine(" PDFImage.ObjectNumber: {0}", image.ObjectNumber.ToString());
writer.WriteLine(" PDFImage.ColorDevice: {0}", image.ColorDevice.ToString());
writer.WriteLine(" PDFImage.StreamOffset: {0}", image.StreamOffset.ToString());
writer.WriteLine(" PDFImage.StreamLength: {0}", image.StreamLength.ToString());
writer.WriteLine(" PDFImage.BitsPerComponent: {0}", image.BitsPerComponent.ToString());
writer.WriteLine(" PDFImage.ComponentCount: {0}", image.ComponentCount.ToString());
writer.WriteLine(" PDFImage.BitsPerPixel: {0}", image.BitsPerPixel.ToString());
writer.WriteLine(" PDFImage.Width: {0}", image.Width.ToString());
writer.WriteLine(" PDFImage.Height: {0}", image.Height.ToString());
writer.WriteLine(" PDFImage.ImageType: {0}", image.ImageType.ToString());
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}