Solved

converting doc to pdf with bookmarks and links enabled

Posted on 2007-11-21
5
3,464 Views
Last Modified: 2013-11-25
I am converting Doc to PdF It  works fine using acrobat distiller and even pdfedit995,deskpdf etc..but the problem is bookmarks are not working in pdf file if convert through programmatically.Bookmarks works fine when you convert externally .e throu word right click and convert to pdf.
here is my code ..
 Dim wd As New Word.Application
Set wd = New Word.Application

wd.Documents.Open fileName:="C:\0000001.doc", _
ConfirmConversions:=False, ReadOnly:=False, AddToRecentFiles:=False, _
PasswordDocument:="", PasswordTemplate:="", Revert:=False, _
WritePasswordDocument:="", WritePasswordTemplate:="", Format:= _
wdOpenFormatAuto

wd.Documents.Application.ActivePrinter = "deskPDF"   'or pdf995
wd.Application.PrintOut fileName:="", Range:=wdPrintAllDocument, Item:=wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
Collate:=False, Background:=True, PrintToFile:=False

I think because of  wd.Application.PrintOut  bookmarks are not working .Is there any other method other than printout  to convert doc  to Pdf
Here is one more code gives same problem

Dim objWord As New Word.Application
Dim strDefaultPrinter As String
 
Dim pdf As String
Dim ps As String
Dim docname As String
OutputDir = "C:\outlook extractor"
    '**save the printer to restore later
strDefaultPrinter = objWord.ActivePrinter
objWord.Visible = False
    '**
'objWord.ActivePrinter = "Acrobat Distiller"
Dim objDistiller As New ACRODISTXLib.PdfDistiller
 ps = Mid(flename, 1, Len(flename) - 4) & ".ps"
docname = Replace(ps, ".ps", ".doc", , , vbTextCompare)
If InStr(1, flename, ".pdf", vbTextCompare) = 0 Then
    objWord.Documents.Open docname


   If (ps <> "") Then
        '**piece together the pdf name
        pdf = Replace(ps, ".ps", ".pdf", , , vbTextCompare)
        '**print out the postscript via distiller
       
        objWord.PrintOut False, False, False, ps, , , , , , , True
        '**print out the pdf from the postscript
        objDistiller.FileToPDF ps, pdf, ""  ' OutputDir & "\" & pdf, ""
       ' Fs.CopyFile pdf, OutputDir & ".pdf"
'        Fs.DeleteFile OutputDir & "\" & pdf
'        Fs.DeleteFile OutputDir & "\" & ps
    End If
   
    Fs.DeleteFile ps
    'fs.DeleteFile
   ' Fs.DeleteFile Replace(ps, ".ps", ".txt")
    ps = ""
    '**close the word file w/o saving
    Set objDistiller = Nothing
    objWord.ActiveDocument.Close False
    objWord.Quit
    Set objWord = Nothing
End If

Dim objWord As New Word.Application
Dim strDefaultPrinter As String
Dim Fol As Folder
Dim OutputDir As String
Dim pdf As String
Dim ps As String
Dim docname As String
OutputDir = "C:\outlook extractor"
    '**save the printer to restore later
strDefaultPrinter = objWord.ActivePrinter
objWord.Visible = False
    '**
'objWord.ActivePrinter = "Acrobat Distiller"
Dim objDistiller As New ACRODISTXLib.PdfDistiller
 ps = Mid(flename, 1, Len(flename) - 4) & ".ps"
docname = Replace(ps, ".ps", ".doc", , , vbTextCompare)
If InStr(1, flename, ".pdf", vbTextCompare) = 0 Then
    objWord.Documents.Open docname
 
 
   If (ps <> "") Then
        '**piece together the pdf name
        pdf = Replace(ps, ".ps", ".pdf", , , vbTextCompare)
        '**print out the postscript via distiller
        
        objWord.PrintOut False, False, False, ps, , , , , , , True
        '**print out the pdf from the postscript
        objDistiller.FileToPDF ps, pdf, ""  ' OutputDir & "\" & pdf, ""
       ' Fs.CopyFile pdf, OutputDir & ".pdf"
'        Fs.DeleteFile OutputDir & "\" & pdf
'        Fs.DeleteFile OutputDir & "\" & ps
    End If
    
    Fs.DeleteFile ps
    'fs.DeleteFile
   ' Fs.DeleteFile Replace(ps, ".ps", ".txt")
    ps = ""
    '**close the word file w/o saving
    Set objDistiller = Nothing
    objWord.ActiveDocument.Close False
    objWord.Quit
    Set objWord = Nothing
End If

Open in new window

0
Comment
Question by:annapolistech
  • 2
5 Comments
 
LVL 17

Accepted Solution

by:
wobbled earned 500 total points
ID: 20327688
This is very difficult to do.  PDF's use a hotlink area to create hyperlinks.  It is not so much that the text itself is given a link as in html, a rectangle is drawn over the word / button etc and this is given co-ordinates for its position.  To do this in a straight print out from word, you will need to write this co-ordination information directly into the top of the PS file.  As you can guess this is pretty complex and requires a great deal of VBA coding as well as a good knowledge of creating PS files in such a way to be interpreted correctly by Adobe Distiller.
0
 

Author Comment

by:annapolistech
ID: 20371883
This is not the solution what I needed and it is too difficult to do in this method..
0
 
LVL 17

Expert Comment

by:wobbled
ID: 20377178
Sorry to be the bringer of bad news, but I do not know of another way to do this, in fact my method above is how we got round the issue within the organisation I work for.  It resulted in a substantial addin being built.
0
 
LVL 1

Expert Comment

by:Computer101
ID: 20560953
Forced accept.

Computer101
EE Admin
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In a previous article published here at Experts Exchange, Signature Image with Transparent Background (http://www.experts-exchange.com/Web_Development/Document_Imaging/A_12380-Signature-Image-with-Transparent-Background.html), I explained how to cre…
This article focuses on how to remove password security from multiple PDF files by Adobe Acrobat program. Sometimes it is essential to access the stored data items and to print, edit as well as copy content from Portable Document Format files in abs…
In this first video of the three-part Xpdf series, we introduce and describe Xpdf, a library containing nine command line utilities that perform various functions on PDF files. We show where the library is located and how to download it, discuss its…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

837 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question