乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 43|回复: 2

转PDF

[复制链接]

35

主题

329

帖子

7

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
468
发表于 2006-12-21 20:08:00 | 显示全部楼层 |阅读模式
下面的程序能够把p1,p2构成的区域打印n份。
现在我想用程序将图形转PDF,但我不知道怎样将打印机名设为"Adobe PDF",也不知道怎样设定PDF文件名。
请高手帮忙。
ThisDrawing.ModelSpace.Layout.RefreshPlotDeviceInfo
ThisDrawing.ActiveLayout.PlotType = acWindow
ThisDrawing.ActiveLayout.UseStandardScale = True
ThisDrawing.ActiveLayout.StandardScale = acScaleToFit
ThisDrawing.ActiveLayout.SetWindowToPlot p1, p2
ThisDrawing.Plot.NumberOfCopies = n
ThisDrawing.Plot.PlotToDevice
回复

使用道具 举报

120

主题

326

帖子

7

银币

中流砥柱

Rank: 25

铜币
806
发表于 2006-12-24 16:34:00 | 显示全部楼层
基本原理如下:
1. 使用Acrobat Distiller打印激活worksheet or range生成postscript文件
2. 使用Acrobat Distiller API 将postscript转化成 .PDF 文件
其次要做以下几步
A 在VBA工程中引用Acrobat Distiller
B 然后,进行Acrobat Distiller的打印设置
&nbspublic
                        Sub MakePDF(ByVal strPDFFileName As
                        String)

            ' Define the postscript and .pdf file names.
            Dim strPSFileName As
                        String

            Dim xlWorksheet As Worksheet
            Dim objPdfDistiller As PdfDistiller

            strPSFileName = Left(strPDFFileName, InStrRev(strPDFFileName, "\")) & "tmpPostScript.ps"

            ' Print the Excel ActiveSheet to the postscript file
            Set xlWorksheet = ActiveSheet
            Call xlWorksheet.PrintOut(copies:=1, preview:=False, ActivePrinter:="Acrobat Distiller", printtofile:=True, collate:=True, prtofilename:=strPSFileName)

            ' Convert the postscript file to .pdf
            Set objPdfDistiller = New PdfDistiller
            Call objPdfDistiller.FileToPDF(strPSFileName, strPDFFileName, "")

            ' Finally, delete the postscript file
            Call Kill(strPSFileName)

        End
                        Sub
细节见http://blog.csdn.net/fangxinggood/archive/2006/02/14/599045.aspx
回复

使用道具 举报

35

主题

329

帖子

7

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
468
发表于 2006-12-25 15:42:00 | 显示全部楼层
谢谢兰州人,我下来慢慢消化。
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-7-7 05:19 , Processed in 2.077776 second(s), 58 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表