Solved

converting doc to pdf with bookmarks and links enabled

Posted on 2007-11-21
5
3,459 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Forced accept.

Computer101
EE Admin
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Power PDF (http://www.nuance.com/for-business/document-imaging-and-scanning/power-pdf-converter/index.htm) is the newest product from the Document Imaging division of Nuance Communications (http://www.nuance.com/). It is available in two editions — …
PDF files have been in the limelight due to its unmatched features.  Personal documents, emails, business reports and eBooks are all converted into PDF files owing to peerless features provided by it. Adding watermark to a PDF file is a method to se…
In this video, we show how to perform Bates Numbering/Stamping of PDF documents using Power PDF Advanced, the newest product from the Document Imaging division of Nuance Communications. There are two editions of Power PDF — Standard and Advanced. Th…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

744 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now