Module pdffile: PDF file inclusion¶
The pdffile module embeds pages from external PDF files directly as native
vector PDF Form XObjects when generating PDF output, preserving all vector paths,
embedded fonts, images, and resources:
from pyx import *
c = canvas.canvas()
c.insert(pdffile.pdffile(0, 0, "diagram.pdf", page=1, width=8))
c.writePDFfile("output")
Class pdffile¶
- class pdffile.pdffile(x, y, filename, width=None, height=None, scale=None, align='bl', clip=1, translatebbox=True, bbox=None, page=1, kpsearch=False)¶
Creates a canvas item representing page page of the external PDF file filename placed at
(x, y)(in user units or PyX lengths).Argument
Description
x,yCoordinates of the reference point at which the PDF page is placed.
filenamePath to the PDF file, or an open binary file-like object.
width=NoneDesired width of the graphic, or
Noneto use its natural bounding-box width (or scale proportionally from height). Cannot be combined with scale.height=NoneDesired height of the graphic, or
Noneto use its natural bounding-box height (or scale proportionally from width). Cannot be combined with scale.scale=NoneUniform scaling factor, or
Nonefor no scaling. Cannot be combined with width or height.align="bl"Two-character alignment string specifying how the PDF page is aligned relative to
(x, y). The first character sets vertical alignment ("b"bottom,"c"center,"t"top) and the second sets horizontal alignment ("l"left,"c"center,"r"right).clip=1When true (default), clips the included page to its bounding box.
translatebbox=TrueWhen true (default), translates the PDF page so that the lower-left corner of its bounding box sits at the reference origin before scaling and alignment.
bbox=NoneOptional
bbox.bboxoverriding the page’sCropBox(orMediaBoxif noCropBoxis defined).page=11-based page number of the PDF file to include.
kpsearch=FalseWhen true, locates filename via the TeX
kpathseafile search system (config).
Note
Because pdffile embeds the page’s content stream and resource
dictionary directly as a PDF Form XObject, it is supported when writing PDF
output (canvas.canvas.writePDFfile() and
document.document.writePDFfile()).