from ironpdf import * html_a = """<p> [PDF_A] </p> <p> [PDF_A] 1st Page </p> <div style='page-break-after: always;'></div> <p> [PDF_A] 2nd Page</p>""" html_b = """<p> [PDF_B] </p> <p> [PDF_B] 1st Page </p> <div style='page-break-after: always;'></div> <p> [PDF_B] 2nd Page</p>""" renderer = ChromePdfRenderer() # Create our main document pdfdoc_a = renderer.RenderHtmlAsPdf(html_a) # Create and select a page to copy pdfdoc_b = renderer.RenderHtmlAsPdf(html_b) page_to_insert = pdfdoc_b.CopyPage(1) # 3 ways to insert: pdfdoc_a.AppendPdf(page_to_insert) # at the end # or pdfdoc_a.PrependPdf(page_to_insert) # at the start # or pdfdoc_a.InsertPdf(page_to_insert, 1) # in the middle pdfdoc_a.SaveAs("CopiedPages.pdf")
從 PDF 文件之間複製頁面