4

I've been trying to create PDF files from my Visio drawings. My current method is very simple, just "Save As" pdf in Visio. One issue I have is that the inter-character spacing becomes uneven after the drawing is converted to pdf. I've attached two images here. The first one shows the original font in Visio and the other shows the distorted font in PDF.

This image shows the font in Visio.

This image shows the font in the converted PDF from Visio.

Has anyone experienced this problem before? How would you suggest on fixing this?

Thanks!

kc2uno
  • 1,141
  • 2
  • 12
  • 16
  • Can you post a sample PDF? Do you have access to Adobe Acrobat to test having it create a PDF for you? Microsoft's built-in version does an OK job but Adobe's is pretty much the de facto standard. If you do, could you post that PDF, too? – Chris Haas Jan 11 '16 at 21:19
  • @ChrisHaas When you say using Adobe Acrobat to create a PDF, did you mean by using [Adobe PDF Printer](https://acrobat.adobe.com/us/en/how-to/print-to-pdf.html)? I think the free Adobe Acrobat does not have this function. I just tried using [PdfCreator](http://www.pdfforge.org/pdfcreator), which actually helps solve the problem, although it's not as convenient as I would like to. I'm quite surprised by how poor the job the pdf converter does in Visio. – kc2uno Jan 11 '16 at 21:45
  • I meant the paid Adobe Acrobat version. If you have access to someone with both Adobe Acrobat and Microsoft Visio I'd see if they can create the file. This isn't a fix but if you can give us a PDF that looks correct and one that looks incorrect we can tell you the major differences between the two files and hopefully you can adjust your built-in export settings if possible. – Chris Haas Jan 11 '16 at 21:54

5 Answers5

2

I observed the same spacing problem with Visio 2013's export to PDF feature, but not when outputting a PDF using Adobe Acrobat XI Pro. It also appeared when pasting a Microsoft Visio drawing object or pasting and EMF from Visio into Word 2013; however, inserting a WMF from the same Visio drawing does not have the problem. I had just started using 2013 although 2016 versions were already available. I did not have the problem with Visio/Word 2007. -- 7/2016: I left most of my prior observations, but this, the issue appears to have been fixed by Microsoft Update.

Randy
  • 21
  • 2
0

Posting the PDF output itself would be very helpful, but from what you have said already, coupled with what you have shown in images, it appears that the Visio output is setting each character individually and getting the character widths wrong, thus the placement of each following letter is too far beyond the preceding one.

I'm not too sure of the baseline positioning, either, because the endpoint of that curving blue line below the "c" in the screenshots you posted is significantly closer to the text in the rendered PDF than in the initial screenshot above it.

See if Visio can deal with Courier first, as that is a monospace font (i.e. each glyph occupies the same width on the line). If it generates text in Courier that still shows wandering letterspacing, I would begin to wonder whether there's a newer/updated Visio release to seek out before continuing to fight with this.

acg_so
  • 274
  • 1
  • 4
0

This is apparently a long lasting bug in Visio. I still see it in my Visio 1708, build 8431.2250). The bug is at least 4 years here already.

The working fix to avoid kerning problems for single diagrams is to export them in any bitmap format (e.g. png) or Windows Metafile Format (WMF) or use screen snipping tools to copy diagrams from the screen.

From that, may be the solution can be in tuning the PDF renderer to produce set of raster images instead of using the embedded vector graphics.

Bug report on 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

Anton Golubev
  • 1,333
  • 12
  • 21
0

One solution is to use the Print function to generate the PDF:

  • Press Ctrl+P to open the print dialog
  • Select "Microsoft Print to PDF" from the list of printers (or any other PDF printer you may have installed)
  • Select a paper format that is large enough to contain your whole drawing
  • Click the "Print" button
  • In the "Save PDF" dialog that opens now, save the file somewhere.
  • Use a program like pdfcrop (available on the command line if you have LaTeX installed) or Briss (did not test it personally) to remove the white space around your drawing.

You can also script this process with VBA

On my machine, the script below took about 15-20 minutes to execute in a folder with ~350 Visio files.

After using the VBA script shown below to print all Visio files to PDF, you only need to use pdfcrop to remove the whitespace. Note: On Windows you will need to install ActivePerl in addition to MikTeX in order to use pdfcrop. Don't know if this is also necessary with TeXLive.

An example PowerShell command could be:

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

Or in bash:

for f in *-print.pdf; do
    pdfcrop "$f"    # or pdfcrop "$f" "${f%-print.pdf}.pdf"
done

After this, you will have a filename-print-crop.pdf for each 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
Fritz
  • 1,293
  • 15
  • 27
-1

The PDF generator is using a similar, but not the same font as Visio. The stroke weights of the examples you posted are not the same (note the horizontal lines in the 'e' and 't').

Try a different font.

  • I tried using many different fonts. The uneven spacing still happens although for different words. – kc2uno Jan 11 '16 at 21:31