在pdf上叠加点

2024-10-05 12:28:02 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试创建一个在线应用程序,其中特定数据点需要叠加或放在特定图表上(来自世卫组织)。 https://www.dietitians.ca/Downloads/Public/LFA-WFA_Birth-24_BOYS_SET-2_EN.aspx

实现这一点的最简单方法是什么,以便将点放在这张精确的图表上?该应用程序将使用Python/Django构建

如有任何建议,将不胜感激


Tags: 数据https应用程序downloadswww图表publicca
1条回答
网友
1楼 · 发布于 2024-10-05 12:28:02

我将使用PyMuPDF在所需位置为点绘制一个圆。下面是一些示例代码:

import fitz  # pip install PyMuPDF

src_pdf_filename = 'LFA-WFA_Birth-24_BOYS_SET-2_EN.pdf'
dst_pdf_filename = 'LFA-WFA_Birth-24_BOYS_SET-2_EN_Edited.pdf'

document = fitz.open(src_pdf_filename)

# Get the first page
page = document[0]

# Draw a circle for a point in the upper right part of page
# http://pymupdf.readthedocs.io/en/latest/page/#Page.drawCircle
page.drawCircle(fitz.Point(517, 147), 5, color=(1, 0, 0), fill=(1, 0, 0))

# Keep original PDF; save to different PDF
document.save(dst_pdf_filename, garbage=4, clean=True, deflate=True)
document.close()

相关问题 更多 >

    热门问题