微软Visio Professional 2013:“另存为PDF”会扭曲字体——字符间距不均匀。

4
我一直在尝试从我的Visio图形中创建PDF文件。我目前的方法非常简单,就是在Visio中使用“另存为”PDF。我遇到的一个问题是,绘图转换为PDF后,字符间距变得不均匀。我在此附上两张图片。第一张显示Visio中的原始字体,另一张显示PDF中扭曲的字体。

此图像显示Visio中的字体。

此图像显示从Visio转换的PDF中的字体。

有人遇到过这个问题吗?你会建议如何解决吗?

谢谢!


你能发布一个样本 PDF 吗?你有访问 Adobe Acrobat 的权限来测试它是否可以为你创建 PDF 吗?Microsoft 的内置版本做得还不错,但 Adobe 已经成为事实上的标准。如果您有,请也发布该 PDF。 - Chris Haas
@ChrisHaas 你所说的使用Adobe Acrobat创建PDF,是指使用Adobe PDF打印机吗?我认为免费的Adobe Acrobat没有这个功能。我刚试过使用PdfCreator,它可以帮助解决问题,虽然不如我所希望的那么方便。我对Visio中pdf转换器的表现很失望。 - kc2uno
我指的是付费版的Adobe Acrobat。如果你有人可以访问Adobe Acrobat和Microsoft Visio,我建议你看看他们能否创建该文件。这不是一个解决方法,但如果你能提供一个外观正确和一个外观不正确的PDF文件,我们就可以告诉你两个文件之间的主要区别,希望你能尽可能地调整内置导出设置。 - Chris Haas
5个回答

2

我发现使用Visio 2013导出PDF时存在相同的间距问题,但是使用Adobe Acrobat XI Pro输出PDF时没有这个问题。当将Microsoft Visio绘图对象粘贴或从Visio粘贴EMF到Word 2013中时,也会出现此问题;然而,从相同的Visio绘图中插入WMF则没有这个问题。虽然2016版本已经推出,但我刚开始使用2013时并没有遇到这个问题。-- 7/2016:我保留了大部分之前的观察结果,但是这个问题似乎已经被Microsoft更新修复了。


0

发布PDF输出本身将非常有帮助,但从您已经说过的内容以及您在图像中展示的内容来看,似乎Visio输出正在单独设置每个字符并且获取字符宽度错误,因此每个后续字母的位置都比前面的字母要远得多。

我也不太确定基线定位,因为您发布的截图中“c”下方弯曲的蓝线的端点与渲染后的PDF中的文本相比,距离显着更近。

首先尝试使用Courier处理Visio,因为这是一种等宽字体(即每个字形在行上占据相同的宽度)。如果它生成的Courier文本仍然显示漫游字母间距,则我会开始想知道是否有新的/更新的Visio版本可供寻找,而不是继续与此进行斗争。


0

这显然是Visio中一个长期存在的bug。我在我的Visio 1708版本(build 8431.2250)中仍然看到它。这个bug已经存在至少4年了。

避免单个图表出现字距问题的有效解决方法是将它们导出为任何位图格式(例如png)或Windows元文件格式(WMF),或使用屏幕截图工具从屏幕上复制图表。

因此,解决方案可能是调整PDF渲染器以生成一组光栅图像,而不是使用嵌入式矢量图形。

Microsoft Answers上的错误报告:

https://answers.microsoft.com/en-us/office/forum/office_2013_release-word/font-spacing-kerning-issues-after-cut-paste-from/e930ec40-507f-4b25-9d72-c6c41b9d70cf


0
一种解决方案是使用打印功能生成PDF文件:
  • 按下Ctrl+P打开打印对话框
  • 从打印机列表中选择“Microsoft Print to PDF”(或任何其他已安装的PDF打印机)
  • 选择一个足够大以容纳整个图纸的纸张格式
  • 点击“打印”按钮
  • 在现在打开的“保存PDF”对话框中,将文件保存在某个地方。
  • 使用类似于pdfcrop(如果您安装了LaTeX,则可在命令行上使用)或Briss(我个人没有测试过)的程序来删除图纸周围的空白区域。

您也可以使用VBA脚本自动化此过程

在我的电脑上,对于大约350个Visio文件的文件夹,下面的脚本需要大约15-20分钟才能执行完毕。

使用下面展示的VBA脚本将所有Visio文件打印为PDF后,您只需要使用pdfcrop来删除空白部分。注意:在Windows上,您需要安装ActivePerl以及MikTeX才能使用pdfcrop。不知道这是否也适用于TeXLive。

一个PowerShell命令的例子如下:

Get-ChildItem "*-print.pdf" | Foreach-Object {
    pdfcrop $_.FullName
}

或者在bash中:
for f in *-print.pdf; do
    pdfcrop "$f"    # or pdfcrop "$f" "${f%-print.pdf}.pdf"
done

完成后,您将会得到一个filename-print-crop.pdf文件,对应于每个filename.vsdx文件。

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'' Copy this code into the "ThisDocument" module in a new vsdx file.
'' Save the vsdx file into the folder where the documents reside that
'' you want to convert to pdf.
'' Then run the macro "PrintAllDocumentsInCurrentFolder".
'' Then use pdfcrop or a similar tool to remove the white space.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Public Sub PrintOpenDocumentToPDF(oDoc As Document, sOutputFileName As String, Optional iPage As Integer = 1)
    ' First, ensure that the document fits on one page, without rescaling
    If oDoc.Pages(iPage).PrintTileCount > 1 Then
        oDoc.PaperSize = visPaperSizeA3 ' Try larger paper
        DoEvents ' Let Visio calculate the tiling
    End If
    If oDoc.Pages(iPage).PrintTileCount > 1 Then
        ' Still doesn't fit... try changing paper orientation
        oDoc.PrintLandscape = Not oDoc.PrintLandscape
        DoEvents ' Let Visio calculate the tiling
    End If
    If oDoc.Pages(iPage).PrintTileCount > 1 Then
        ' If it still doesn't fit, rescale the image to the paper size
        oDoc.PrintFitOnPages = True
        oDoc.PrintPagesAcross = 1
        oDoc.PrintPagesDown = 1
        DoEvents ' Let Visio calculate the tiling
    End If
    
    oDoc.PrintOut visPrintFromTo, iPage, iPage, , "Microsoft Print to PDF", True, sOutputFileName
End Sub

Public Sub PrintDocumentToPDF(fileName As String, Optional suffix As String = "-print.pdf")
    Dim iExtensionIndex As Integer
    Dim sOutputFileName As String
    Dim oDoc As Document
    
    iExtensionIndex = InStrRev(fileName, ".")
    If iExtensionIndex = 0 Then
        MsgBox "Error, could not determine the file extension of file '" + fileName + "'", vbExclamation
        Exit Sub
    End If
    
    sOutputFileName = Left(fileName, iExtensionIndex - 1) + suffix
    
    Set oDoc = Documents.Open(fileName)
    If IsNull(oDoc) Then
        MsgBox "Error, could open file '" + fileName + "'", vbExclamation
        Exit Sub
    End If
    
    PrintOpenDocumentToPDF oDoc, sOutputFileName
    Dim lAlertResponseOld As Long
    
    lAlertResponseOld = Application.AlertResponse 'Save alert response so we can revert
    Application.AlertResponse = 7 'Tell Visio to choose "Don't Save Changes"
    oDoc.Close ' Save changes dialog will not be shown
    Application.AlertResponse = lAlertResponseOld 'Revert back to original setting
End Sub

Public Sub PrintAllDocumentsInCurrentFolder()
    Dim sFolderName, sThisDocumentName As String
    Dim isThisFile, isVsdFile As Boolean
    Dim oFSO As Object
    Dim oFolder As Object
    Dim oFile As Object
    Dim iExtensionPos
    Dim oPrinter As Object
    
    sFolderName = ThisDocument.Path
    sThisDocumentFileName = sFolderName + ThisDocument.Name
    
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    Set oFolder = oFSO.GetFolder(sFolderName)
    
    For Each oFile In oFolder.Files
        isThisFile = StrComp(oFile.Path, sThisDocumentFileName) = 0
        isVsdFile = InStrRev(oFile.Name, ".vsd") > 0
        If isVsdFile And Not isThisFile Then
            PrintDocumentToPDF oFile.Path
        End If
    Next oFile

End Sub

-1

PDF 生成器使用的字体与 Visio 相似,但不完全相同。您发布的示例中笔画的粗细不同(请注意“e”和“t”中的横线)。

尝试其他字体。


我尝试了许多不同的字体,但是即使对于不同的单词,不均匀间距仍然会发生。 - kc2uno

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接