Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
다음 코드 스니펫은 Aspose.PDF.Drawing 라이브러리와 함께 작동합니다.
Aspose.PDF for .NET는 PDF 문서에 그래프 객체(예: 그래프, 선, 사각형 등)를 추가하는 기능을 지원합니다. 또한 대시 패턴, 색상 및 선 요소의 기타 형식을 지정할 수 있는 선 객체를 추가할 수 있는 이점을 제공합니다.
아래 단계를 따르세요:
새 PDF 문서를 만듭니다.
PDF 파일의 페이지 컬렉션에 페이지를 추가합니다.
그래프 인스턴스를 만듭니다.
페이지 인스턴스의 단락 컬렉션에 그래프 객체를 추가합니다.
사각형 인스턴스를 만듭니다.
선 너비를 설정합니다.
그래프 객체의 도형 컬렉션에 사각형 객체를 추가합니다.
PDF 파일을 저장합니다.
다음 코드 스니펫은 색상으로 채워진 사각형 객체를 추가하는 방법을 보여줍니다.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void AddLineObjectToPDF()
{
    // The path to the document 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 Graph instance
        var graph = new Aspose.Pdf.Drawing.Graph(100, 400);
        // Add graph object to paragraphs collection of page instance
        page.Paragraphs.Add(graph);
        // Create Line instance with specified coordinates
        var line = new Aspose.Pdf.Drawing.Line(new float[] { 100, 100, 200, 100 });
        // Specify dash settings for the line
        line.GraphInfo.DashArray = new int[] { 0, 1, 0 };
        line.GraphInfo.DashPhase = 1;
        // Add line object to shapes collection of Graph object
        graph.Shapes.Add(line);
        // Save PDF document
        document.Save(dataDir + "AddLineObject_out.pdf");
    }
}

// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void DashLengthInBlackAndDashLengthInWhite()
{
    // The path to the document 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 Drawing object with certain dimensions
        var canvas = new Aspose.Pdf.Drawing.Graph(100, 400);
        // Add drawing object to paragraphs collection of page instance
        page.Paragraphs.Add(canvas);
        // Create Line object
        var line = new Aspose.Pdf.Drawing.Line(new float[] { 100, 100, 200, 100 });
        // Set color for Line object
        line.GraphInfo.Color = Aspose.Pdf.Color.Red;
        // Specify dash array for line object
        line.GraphInfo.DashArray = new int[] { 3, 2 }; // Dash and gap lengths in points
        // Set the dash phase for Line instance
        line.GraphInfo.DashPhase = 1;
        // Add line to shapes collection of drawing object
        canvas.Shapes.Add(line);
        // Save PDF document
        document.Save(dataDir + "DashLengthInBlackAndDashLengthInWhite_out.pdf");
    }
}
결과를 확인해 보세요:

선 객체를 사용하여 왼쪽 하단에서 오른쪽 상단 모서리 및 왼쪽 상단 모서리에서 오른쪽 하단 모서리로 교차하는 선을 그릴 수도 있습니다.
이 요구 사항을 충족하기 위한 다음 코드 스니펫을 살펴보세요.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void ExampleLineAcrossPage()
{
    // The path to the document directory
    var dataDir = RunExamples.GetDataDir_AsposePdf_Images();
    // Create PDF document
    using (var document = new Aspose.Pdf.Document())
    {
        // Add page
        var page = document.Pages.Add();
        // Set page margin on all sides as 0
        page.PageInfo.Margin.Left = 0;
        page.PageInfo.Margin.Right = 0;
        page.PageInfo.Margin.Bottom = 0;
        page.PageInfo.Margin.Top = 0;
        // Create Graph object with Width and Height equal to page dimensions
        var graph = new Aspose.Pdf.Drawing.Graph(
            (float)page.PageInfo.Width,
            (float)page.PageInfo.Height);
        // Create first line object starting from Lower-Left to Top-Right corner of page
        var line1 = new Aspose.Pdf.Drawing.Line(new float[]
        {
            (float)page.Rect.LLX, 0,
            (float)page.PageInfo.Width,
            (float)page.Rect.URY
        });
        // Add line to shapes collection of Graph object
        graph.Shapes.Add(line1);
        // Create second line object starting from Top-Left corner to Bottom-Right corner of page
        var line2 = new Aspose.Pdf.Drawing.Line(new float[]
        {
            0, (float)page.Rect.URY,
            (float)page.PageInfo.Width, (float)page.Rect.LLX
        });
        // Add line to shapes collection of Graph object
        graph.Shapes.Add(line2);
        // Add Graph object to paragraphs collection of page
        page.Paragraphs.Add(graph);
        // Save PDF document
        document.Save(dataDir + "ExampleLineAcrossPage_out.pdf");
    }
}

Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.