Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

create PDF in VB6

Posted on 2002-07-02
5
Medium Priority
?
1,597 Views
Last Modified: 2007-11-27
so far I've found this undocumented function to convert one tif to a pdf ...
my problem is that need to put more then one tif in a pdf ... any pointers would be greatly appreciated as automation is pretty new to me ... thanks

-------------------------------------------------------

Private Sub Tif2PDF(filename As String)
Dim AcroApp As Object
Dim AVDoc As Object
Dim PDDoc As Object
Dim IsSuccess As Boolean

Set AcroApp = CreateObject("AcroExch.App")
Set AVDoc = CreateObject("AcroExch.AVDoc")

Call AVDoc.Open(filename, "")

Set AVDoc = AcroApp.GetActiveDoc

If AVDoc.IsValid Then

Set PDDoc = AVDoc.GetPDDoc
' Fill in pdf properties.
PDDoc.SetInfo "Title", "test" 'txtDocTitle.Text
PDDoc.SetInfo "Author", "test" 'txtDocAuthor.Text
PDDoc.SetInfo "Subject", "test" 'cboDocType.Text
PDDoc.SetInfo "Keywords", "test" ' txtDocKeyword.Text
If PDDoc.Save(1 Or 4 Or 32, App.Path & "\docfile.pdf") <> True Then
MsgBox "Failed to save " & filename
End If
PDDoc.Close
End If
'Close the PDF
AVDoc.Close True
AcroApp.Exit
'Cleanup
Set PDDoc = Nothing
Set AVDoc = Nothing
Set AcroApp = Nothing
End Sub
0
Comment
Question by:Ninibini
  • 2
  • 2
5 Comments
 
LVL 54

Expert Comment

by:Ryan Chong
ID: 7126231
Some info that generate PDF using Word:

 Dim msWord As Word.Application
 Set msWord = GetObject(Class:="Word.Application.8")

 msWord.Visible = False
 msWord.ActivePrinter = "Acrobat PDFWriter"
 msWord.Documents.Open "c:\temp\spec.doc"
 msWord.ActiveDocument.PrintOut    

source: http://www.experts-exchange.com/visualbasic/Q_20318802.html
0
 
LVL 1

Author Comment

by:Ninibini
ID: 7126247
I already thought about using Word, but unfortunately it was requested that only Acrobat needs be installed on the computer.
0
 
LVL 1

Author Comment

by:Ninibini
ID: 7136999
i was able to figure it out myself...

.........
'open a template pdf, with one empty page

          Set pdDoc = CreateObject("AcroExch.PDDoc")
          pdDoc.Open template

          Set AVDoc = CreateObject("AcroExch.AVDoc")

          'Setzen der Dokumenteigenschaften
          pdDoc.SetInfo "Title", Now
          pdDoc.SetInfo "Author", ""
          pdDoc.SetInfo "Subject", curBarcodeNr
          pdDoc.SetInfo "Keywords", curBarcodeNr

'insert images ( call function as often as needed)
          If Not insertTif(basePath & .Fields("Volume2")) Then
            MsgBox "error occurred while inserting the file"
          End If

.............

'save the document
            pdDoc.DeletePages 0, 0 'delete first, empty page
            'Save PDF-Document
            If pdDoc.Save(1 Or 4 Or 32, PDF) <> True Then
              Print #2, "unable to save file"
            Else
              Print #2, "file saved"
              pdDoc.Close
            End If
            Set AVDoc = Nothing

....................


Private Function insertTif(file As String) As Boolean
  Dim tmp_PDDoc As Acrobat.CAcroPDDoc
 
  Call AVDoc.Open(file, "")
  Set AVDoc = AcroApp.GetActiveDoc
 
  If AVDoc.IsValid Then
    Set tmp_PDDoc = AVDoc.GetPDDoc
    pdDoc.InsertPages 0, tmp_PDDoc, 0, 1, False
    insertTif = True
  Else
    'Fehler beim Einfügen
    insertTif = False
  End If
  'Close the PDF
  AVDoc.Close True
  Set tmp_PDDoc = Nothing
End Function
0
 
LVL 54

Expert Comment

by:Ryan Chong
ID: 7137101
ok, please post a request at Community Support whether to PAQ this question with 0 pts or delete this question as you wish.
0
 

Accepted Solution

by:
ComTech earned 0 total points
ID: 7143691
This question has been ansered my the Member, and will be placed in PAQ.

Regards,
ComTech
CS Admin @ EE
0

Featured Post

[Webinar] Cloud Security

In this webinar you will learn:

-Why existing firewall and DMZ architectures are not suited for securing cloud applications
-How to make your enterprise “Cloud Ready”, and fix your aging DMZ architecture
-How to transform your enterprise and become a Cloud Enabler

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

885 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