我发现使用Visio 2013导出PDF时存在相同的间距问题,但是使用Adobe Acrobat XI Pro输出PDF时没有这个问题。当将Microsoft Visio绘图对象粘贴或从Visio粘贴EMF到Word 2013中时,也会出现此问题;然而,从相同的Visio绘图中插入WMF则没有这个问题。虽然2016版本已经推出,但我刚开始使用2013时并没有遇到这个问题。-- 7/2016:我保留了大部分之前的观察结果,但是这个问题似乎已经被Microsoft更新修复了。
发布PDF输出本身将非常有帮助,但从您已经说过的内容以及您在图像中展示的内容来看,似乎Visio输出正在单独设置每个字符并且获取字符宽度错误,因此每个后续字母的位置都比前面的字母要远得多。
我也不太确定基线定位,因为您发布的截图中“c”下方弯曲的蓝线的端点与渲染后的PDF中的文本相比,距离显着更近。
首先尝试使用Courier处理Visio,因为这是一种等宽字体(即每个字形在行上占据相同的宽度)。如果它生成的Courier文本仍然显示漫游字母间距,则我会开始想知道是否有新的/更新的Visio版本可供寻找,而不是继续与此进行斗争。
这显然是Visio中一个长期存在的bug。我在我的Visio 1708版本(build 8431.2250)中仍然看到它。这个bug已经存在至少4年了。
避免单个图表出现字距问题的有效解决方法是将它们导出为任何位图格式(例如png)或Windows元文件格式(WMF),或使用屏幕截图工具从屏幕上复制图表。
因此,解决方案可能是调整PDF渲染器以生成一组光栅图像,而不是使用嵌入式矢量图形。
Microsoft Answers上的错误报告:
Ctrl+P
打开打印对话框pdfcrop
(如果您安装了LaTeX,则可在命令行上使用)或Briss(我个人没有测试过)的程序来删除图纸周围的空白区域。在我的电脑上,对于大约350个Visio文件的文件夹,下面的脚本需要大约15-20分钟才能执行完毕。
使用下面展示的VBA脚本将所有Visio文件打印为PDF后,您只需要使用pdfcrop
来删除空白部分。注意:在Windows上,您需要安装ActivePerl
以及MikTeX
才能使用pdfcrop
。不知道这是否也适用于TeXLive。
一个PowerShell命令的例子如下:
Get-ChildItem "*-print.pdf" | Foreach-Object {
pdfcrop $_.FullName
}
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
PDF 生成器使用的字体与 Visio 相似,但不完全相同。您发布的示例中笔画的粗细不同(请注意“e”和“t”中的横线)。
尝试其他字体。