Class ImagePlacement

ImagePlacement class

تمثل خصائص الصورة الموضوعة في صفحة مستند Pdf.

public sealed class ImagePlacement

Properties

NameDescription
CompositingParameters { get; }يحصل على معلمات التركيب لحالة الرسومات النشطة للصورة الموضوعة على الصفحة.
Image { get; }يحصل على كائن مورد XImage المرتبط.
Matrix { get; }مصفوفة التحويل الحالية لهذه الصورة.
Operator { get; }المشغل المستخدم لعرض الصورة.
Page { get; }يحصل على الصفحة التي تحتوي على الصورة.
Rectangle { get; }يحصل على مستطيل الصورة.
Resolution { get; }يحصل على دقة الصورة.
Rotation { get; }يحصل على زاوية دوران الصورة.

Methods

NameDescription
Hide()يحذف الصورة من الصفحة.
Replace(Stream)يستبدل الصورة في المجموعة بصورة أخرى.
Save(Stream)يحفظ الصورة مع التحويلات المقابلة: التحجيم، الدوران والدقة.
Save(Stream, ImageFormat)يحفظ الصورة مع التحويلات المقابلة: التحجيم، الدوران والدقة.

Remarks

عند وضع صورة على صفحة، قد تكون لها أبعاد غير الأبعاد الفيزيائية المحددة في Resources. الكائن ImagePlacement مصمم لتوفير مثل هذه المعلومات مثل الأبعاد والدقة وما إلى ذلك.

Examples

المثال يوضح كيفية العثور على الصور في الصفحة الأولى من مستند PDF والحصول على الصور كصور نقطية بأبعاد مرئية.

// Open document
Document doc = new Document(@"D:\Tests\input.pdf");

// Create ImagePlacementAbsorber object to perform image placement search
ImagePlacementAbsorber abs = new ImagePlacementAbsorber();

// Accept the absorber for first page
doc.Pages[1].Accept(abs);

// Retrieve images with visible dimensions
foreach (ImagePlacement imagePlacement in abs.ImagePlacements)
{
    Bitmap scaledImage;
    using (MemoryStream imageStream = new MemoryStream())
    {
        // Retrieve image from resources
        imagePlacement.Image.Save(imageStream, ImageFormat.Png);
        Bitmap resourceImage = (Bitmap) Bitmap.FromStream(imageStream);
        // Create new bitmap with actual dimensions
        scaledImage = new Bitmap(resourceImage, (int)imagePlacement.Rectangle.Width, (int)imagePlacement.Rectangle.Height);
    }
} 

See Also