明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2054|回复: 2

转PDF

[复制链接]
发表于 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

发表于 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的打印设置

 ublic 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

 楼主| 发表于 2006-12-25 15:42:00 | 显示全部楼层

谢谢兰州人,我下来慢慢消化。

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

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2025-2-23 03:37 , Processed in 0.165667 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表