PyPDF我正在尝试使用和编辑现有的 pdf 文件ReportLab。当我尝试放置红色圆圈和红色文本时,它似乎隐藏在白色容器或其他东西后面。如果我把它放在其他地方,它就可以正常工作。是什么原因造成的?
WHAT THE ERROR IS:
WHAT THE FINAL RESULT SHOULD BE:
from PyPDF2 import PdfWriter, PdfReader
import io
from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import letter
from reportlab.lib.colors import red
def main():
packet = io.BytesIO()
can = canvas.Canvas(packet, pagesize=letter)
can.setFillColorRGB(1, 0, 0)
can.circle(370,780,20,fill=1)
can.setFillColor(red)
can.setFont("Times-Roman", 14)
can.drawString(352, 785, "Customer Group #22")
can.save()
packet.seek(0)
new_pdf = PdfReader(packet)
existing_pdf = PdfReader(open("samplePDF.pdf", "rb"))
output = PdfWriter()
page = existing_pdf.pages[1]
page.merge_page(new_pdf.pages[0])
output.add_page(page)
outputStream = …Run Code Online (Sandbox Code Playgroud) 我在 下收到一条错误行StandardCharsets。我已经导入了它,所以我不确定为什么会收到错误StandardCharsets cannot be resolved to a variable。
import java.util.*;
import java.nio.charset.Charset;
import java.nio.file.Path;
public class Training
{
public static void main(String[] args)
{
Scanner in = new Scanner(Path.of("text.txt"),StandardCharsets.UTF_8);
System.out.print(in);
}
}
Run Code Online (Sandbox Code Playgroud)
我期望打印text.txt文件中的数据。