PDF

编程入门 行业动态 更新时间:2024-10-04 03:30:29

<a href=https://www.elefans.com/category/jswz/34/1770975.html style=PDF"/>

PDF

我目前在 ReactJS 应用程序中使用 pdf-lib 版本 1.17.1 来生成一些文档。目前我已经将文本写入页面,以及嵌入图像并显示它。但是,我需要将图像裁剪成一个圆圈,事实证明,使用其他解决方案所建议的方法无法从库中使用各种方法很困难: 在 pdflib 中将图像拟合成椭圆

我当前运行的代码如下所示:

        // Define the ellipse parameters
        const ellipseX = 338 + (414 / 2);  // X-coordinate of the ellipse center
        const ellipseY = (currentY + 95) - (414 / 2);  // Y-coordinate of the ellipse center
        const ellipseWidth = 200;  // Width of the ellipse
        const ellipseHeight = 200;  // Height of the ellipse
        
        // 
        agentBioPage.pushOperators(
            pushGraphicsState(),
            ...drawEllipse({
                x: ellipseX,
                y: ellipseY,
                xScale: ellipseWidth,
                yScale: ellipseHeight,
                rotate: degrees(0),
                borderColor: rgb(0, 0, 0),  // Border color (black)
                borderWidth: 1,  // Border width (1 point)
                opacity: 1,  // Opacity (fully opaque)
                blendMode: 'Normal'  // Blend mode (normal)
            }),
            clip(),
        )
        
        // Draw the image onto the page
        agentBioPage.drawImage(embeddedProfilePicture, {
            x: ellipseX - ellipseWidth,
            y: ellipseY - ellipseHeight,
            width: ellipseWidth * 2,
            height: ellipseHeight * 2,
        })

        // 
        agentBioPage.pushOperators(popGraphicsState())

它在圆圈上绘制,在图像上绘制,但根本不剪裁图像(这里椭圆位于图像后面):

任何建议、提示和技巧将不胜感激!

干杯

回答如下:

更多推荐

PDF

本文发布于:2024-05-31 03:02:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1771207.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:PDF

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!