我需要一个程序将每个PDF页分成两部分(左,右)。所以我编写了这个代码,但是由于某些原因它没有捕捉到标题的图像。在尝试其他书籍时,它也不起作用。你知道吗
import os
#Info that i collect to know the numbers of pages and the pdf file name
number = int(input("Number os pages: " ))
file = input("Name of the file: " )
file = str(file) + ".pdf"
text = open("for_the_latex.txt","w")
#Putting the first part of the latex document
a = "\documentclass{article}" + "\n"
b = "\\usepackage{pdfpages}" + "\n"
c = "\\begin{document}"
text.write(a)
text.write(b)
text.write(c)
#This is the core of the program
#It basically write in a text document to include the pdf for each page
for i in range(1,number +1):
a = "\includepdf[pages=" + str( i) + ",trim=0 0 400 0]{" + file + "}" + "\n"
text.write(a)
#Writing the finish part
quatro = "\end{document}"
text.write(quatro)
text.close()
#renaming to .tex
os.rename("for_the_latex.txt", "divided.tex")
#activating the latex
os.system("pdflatex divided.tex")
错误在哪里?你知道吗
我想把PDF文件一分为二。你知道吗
考虑以下最小文档(称为
example-document.pdf
),其中包含6页,每页按颜色和数字精确地分成两半:我们的想法是将这些文件分回到一个12页的文档中。以下是乳胶的代码:
不必读入每一页并确定其宽度(存储在
\pagedim
),但我不确定您的页面是否有不同的大小。你知道吗正如评论中提到的,我不太确定我是否正确理解你的问题。因为我可以执行您的程序,而且它只包含初始文档的左侧部分,所以我对代码进行了一些修改。你知道吗
相关问题 更多 >
编程相关推荐