이미지 크기 설정

Contents
[ ]

다음 코드 스니펫은 Aspose.PDF.Drawing 라이브러리와 함께 작동합니다.

PDF 파일에 추가되는 이미지의 크기를 설정할 수 있습니다. 크기를 설정하려면 Aspose.Pdf.Image 클래스의 FixWidth 및 FixHeight 속성을 사용할 수 있습니다. 다음 코드 스니펫은 이미지의 크기를 설정하는 방법을 보여줍니다:

// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void SetImageSizeInPDF()
{
    // The path to the documents directory
    var dataDir = RunExamples.GetDataDir_AsposePdf_Images();

    // Create PDF document
    using (var document = new Aspose.Pdf.Document())
    {
        // Add page
        var page = document.Pages.Add();

        // Create an image instance
        var img = new Aspose.Pdf.Image();

        // Set Image Width and Height in Points
        img.FixWidth = 100;
        img.FixHeight = 100;

        // Set image type as SVG
        img.FileType = Aspose.Pdf.ImageFileType.Unknown;

        // Path for source file
        img.File = dataDir + "InputImage.jpg";

        // Add image to the page
        page.Paragraphs.Add(img);

        // Set page properties
        page.PageInfo.Width = 800;
        page.PageInfo.Height = 800;

        // Save PDF document
        document.Save(dataDir + "SetImageSize_out.pdf");
    }
}