ArcGIS for Desktop

  • 文档
  • 合约
  • 支持

  • My Profile
  • 帮助
  • Sign Out
ArcGIS for Desktop

ArcGIS Online

专为贵组织打造的制图平台

ArcGIS for Desktop

全面的专业性 GIS

ArcGIS for Server

面向企业的 GIS

ArcGIS for Developers

用于构建位置感知应用程序的工具

ArcGIS Solutions

适用于行业的免费模板地图和应用程序

ArcGIS Marketplace

获取适用于组织的应用程序和数据

  • 文档
  • 合约
  • 支持
Esri
  • 登录
user
  • 我的个人资料
  • 登出

帮助

  • 主页
  • 入门
  • 制图
  • 分析
  • 管理数据
  • 工具
  • 更多...

PDFDocumentCreate

  • 摘要
  • 讨论
  • 语法
  • 代码实例

摘要

在内存中创建空的 PDFDocument 对象。

讨论

PDFDocumentCreate 函数接收路径以确定新创建的 PDF 文件的保存位置和文件名。尽管如此,如果不对 PDF 文件执行插入或追加页面以及保存等后续操作,仍不能生成 PDF 文件。PDFDocumentCreate 将返回脚本应执行和保存的 PDFDocument 对象。使用此函数的常见情况是创建 PDF 地图册。这些步骤通常包括从地图文档导出一定数量的独立 PDF 文件、创建新的 PDFDocument 对象、从已导出的 PDF 文件和其他文档追加内容以及保存最终的 PDF 地图册。

请注意,既不可能创建空白 PDF 文件,PDFDocumentCreate 函数也不可能将任何空白页添加到文档内容中。要使 saveAndClose 方法能够成功创建文件,必须使用 appendPages 或 insertPages 方法将内容添加到 PDFDocument 对象中。

有关如何创建地图册的详细说明,请参阅使用 ArcGIS 构建地图册帮助主题。

语法

PDFDocumentCreate (pdf_path)
参数说明数据类型
pdf_path

A string that specifies the path and file name for the resulting PDF file when the saveAndClose method is called.

String

代码实例

PDFDocumentCreate 示例

此脚本将创建新 PDF 文档、追加来自三个独立 PDF 文档的内容并保存生成的 PDF 文件。

import arcpy, os

#Set file name and remove if it already exists
pdfPath = r"C:\Project\ParcelAtlasMapBook.pdf"
if os.path.exists(pdfPath):
    os.remove(pdfPath)

#Create the file and append pages
pdfDoc = arcpy.mapping.PDFDocumentCreate(pdfPath)
pdfDoc.appendPages(r"C:\Project\Title.pdf")
pdfDoc.appendPages(r"C:\Project\ParcelAtlas.pdf")
pdfDoc.appendPages(r"C:\Project\ContactInfo.pdf")

#Commit changes and delete variable reference
pdfDoc.saveAndClose()
del pdfDoc
有关此主题的反馈?

ArcGIS for Desktop

  • 主页
  • 文档
  • 合约
  • 支持

ArcGIS 平台

  • ArcGIS Online
  • ArcGIS for Desktop
  • ArcGIS for Server
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

关于 Esri

  • 关于我们
  • 招贤纳士
  • 内部人员博客
  • 用户大会
  • 开发者峰会
Esri
© Copyright 2016 Environmental Systems Research Institute, Inc. | 隐私政策 | 法律声明