【问题标题】:VBA converting Excel to PDF with non-standard fontVBA使用非标准字体将Excel转换为PDF
【发布时间】:2015-01-03 08:51:34
【问题描述】:

我正在尝试使用 ExportAsFixedFormat 将 Excel 工作表导出为 PDF,我拥有的代码正在创建 PDF,但它用转换后的 pdf 中的标准字体替换了我的 Excel 文件中的 Myriad Pro。

导出代码如下:

awb.Sheets("PIN").ExportAsFixedFormat Type:=xlTypePDF, _
                 fileName:=strFileName, _
                 Quality:=xlQualityStandard, _
                 IncludeDocProperties:=True, _
                 IgnorePrintAreas:=False, _
                 OpenAfterPublish:=False

有什么方法可以强制 Adob​​e 使用我设置的字体而不是恢复为标准字体?当我手动将单个工作表转换为 PDF 时,它工作正常。

【问题讨论】:

  • When I convert a single sheet to PDF manually it works fine. 你是怎么转换的? File|PrintFile|SaveAs?
  • 我有一个用于 excel 的 Acrobat 插件,可以转换为 pdf - 在首选项中它有一个选项“依赖系统字体”,可以取消勾选。
  • 那么这个插件是如何工作的呢?需要点击File|Print吗?
  • AFAIK,.ExportAsFixedFormat 不使用 Adob​​e
  • 要使用插件进行转换 - 我的 excel 菜单中有一个 acrobat 选项卡,我选择了它,并且有转换为 pdf 选项,然后使用预设将选定的工作表保存为 pdf 文件分页符等。

标签: vba excel pdf fonts


【解决方案1】:

如果 Acrobat Distiller 安装在每台将使用您的文件的机器上,您就可以使用它...如果是这种情况,您可以这样做:

首先,在 Distiller 的打印机设置中,您需要禁用 Rely on system fonts only; do not use document fonts 选项,否则您会收到错误消息。

其次,在 VB 编辑器的 Tools 菜单中,转到 References 选项。您需要找到并检查Acrobat Distiller 参考。

代码:

Sub ExportPDF()
    Dim acro As New ACRODISTXLib.PdfDistiller6
    Dim wk As Worksheet
    
    Const opFile As String = "C:\test\test.ps"
    Const PDFFile As String = "C:\test\test.pdf"
    Const PrinterName As String = "Adobe PDF"
    
    Set wk = Sheet1
    
    wk.PrintOut ActivePrinter:=PrinterName, PrintToFile:=True, PrToFileName:=opFile
    
    acro.FileToPDF opFile, PDFFile, ""
    
End Sub

这应该是一个很好的起点。

注意:对于不同版本的 Distiller,Distiller 的对象名称和打印机名称可能不同。

【讨论】:

  • 谢谢,稍后再试:)
  • 我已经设法对其进行调整以生成 PDF 文件,但现在我遇到的问题让我回到 exportasfixedformat 问题 - 当我尝试使用上述方法转换我的一张 Excel 工作表时方法我收到%%[ Warning: Empty job. No PDF file produced. ] %% 错误,工作表中肯定有内容,并且该方法在我们使用的几乎相同的 Excel 工作表上运行良好 - 有什么想法吗?
  • 尝试使用标准打印输出,看看你会得到什么。我猜你的打印区域很奇怪。
猜你喜欢
  • 2018-12-31
  • 2015-10-11
  • 1970-01-01
  • 2019-02-17
  • 1970-01-01
  • 2016-04-15
  • 2023-03-27
  • 1970-01-01
  • 2013-10-11
相关资源
最近更新 更多