Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Using VB to print a PDF file

Using VB to print a PDF file

Using VB to print a PDF file

Does anyone have an example of using visual basic to drive
Acrobat Distiller or Acrobat PDFWriter to print a file to a specific location?


RE: Using VB to print a PDF file

There is a tool called ACG PDF and Mail Library. Works very well.

RE: Using VB to print a PDF file

Here's the code to get SolidWorks to make a PDF file in the same location as SolidWorks drawing if anyone is interested.

Put this in a module and call from VB app:

Option Explicit
Const vbPRORPortrait                    As Long = 1
Const vbPRORLandscape                   As Long = 2
Const vbPRPSLetter                      As Long = 1
Const vbPRPSLetterSmall                 As Long = 2
Const vbPRPSTabloid                     As Long = 3
Const vbPRPSLedger                      As Long = 4
Const vbPRPSLegal                       As Long = 5
Const vbPRPSStatement                   As Long = 6
Const vbPRPSExecutive                   As Long = 7
Const vbPRPSA3                          As Long = 8
Const vbPRPSA4                          As Long = 9
Const vbPRPSA4Small                     As Long = 10
Const vbPRPSA5                          As Long = 11
Const vbPRPSB4                          As Long = 12
Const vbPRPSB5                          As Long = 13
Const vbPRPSFolio                       As Long = 14
Const vbPRPSQuarto                      As Long = 15
Const vbPRPS1_H14                       As Long = 16
Const vbPRPS11x17                       As Long = 17
Const vbPRPSNote                        As Long = 18
Const vbPRPSEnv9                        As Long = 19
Const vbPRPSEnv10                       As Long = 20
Const vbPRPSEnv11                       As Long = 21
Const vbPRPSEnv12                       As Long = 22
Const vbPRPSEnv14                       As Long = 23
Const vbPRPSCSheet                      As Long = 24
Const vbPRPSDSheet                      As Long = 25
Const vbPRPSESheet                      As Long = 26
Const vbPRPSEnvDL                       As Long = 27
Const vbPRPSEnvC3                       As Long = 29
Const vbPRPSEnvC4                       As Long = 30
Const vbPRPSEnvC5                       As Long = 28
Const vbPRPSEnvC6                       As Long = 31
Const vbPRPSEnvC65                      As Long = 32
Const vbPRPSEnvB4                       As Long = 33
Const vbPRPSEnvB5                       As Long = 34
Const vbPRPSEnvB6                       As Long = 35
Const vbPRPSEnvItaly                    As Long = 36
Const vbPRPSEnvMonarch                  As Long = 37
Const vbPRPSEnvPersonal                 As Long = 38
Const vbPRPSFanfoldUS                   As Long = 39
Const vbPRPSFanfoldStdGerman            As Long = 40
Const vbPRPSFanfoldLglGerman            As Long = 41
Const vbPRPSUser                        As Long = 256
' Defined in swconst.bas
Const swPrintPaperSize                  As Long = 0
Const swPrintOrientation                As Long = 1
Const SWPrinter     As String = "Acrobat PDFWriter"

Sub PDF()
    Dim swApp100                As Object 'SldWorks.SldWorks
    Dim swModel100              As Object 'SldWorks.ModelDoc2
    Dim swDrwDoc                As Object 'SldWorks.DrawingDoc
    Dim swSheet                 As Object 'SldWorks.sheet
    Dim NumSheet                As Long
    Dim PathName                As String
    Dim PrintFileName           As String
    Dim SheetName               As String
    Dim Errors                  As Long
    Dim i                       As Long
    Set swApp100 = CreateObject("SldWorks.Application")
    Set swModel100 = swApp100.ActiveDoc
    Set swDrwDoc = swModel100
    ' strip off SolidWorks file extension (.sld???)
    PathName = swModel100.GetPathName
    PathName = Left(PathName, Len(PathName) - 7)
    'go back to the first sheet
    NumSheet = swDrwDoc.GetSheetCount
    For i = 0 To NumSheet - 1
    Next i
    For i = 0 To NumSheet - 1
        ' generate print filename based on sheet number
        PrintFileName = PathName + "_Sheet-" + Trim(Str(i))
        swModel100.PrintOut2 i + 1, i + 1, 1, False, SWPrinter, 0#, True, PrintFileName
    Next i
    Set swDrwDoc = Nothing

End Sub




RE: Using VB to print a PDF file


any luck with printing pdfs from VB? I looked at the ACG product but it is for Access rather than VB (not being an expert perhaps there's a way to use the MDE but unsure). I don't want to create a pdf, all I want to do is send the pdf to a nominated printer without user interaction with either the adobe reader dialog or print dialog.

(sidenote: I used to do this by shelling from VB with the command:

acrord32 /t "pdffilename.pdf" "printername"

however, the reader now runs minimised with version 5 and stays open rather than in hidden context. This means it prints once but if you invoke again it fails unless you close the first instance of the reader.This method was never satisfactory as there was no guarantee that the shell would work)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Low-Volume Rapid Injection Molding With 3D Printed Molds
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Design for Additive Manufacturing (DfAM)
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a part’s function at the center of their design considerations. Download Now
Taking Control of Engineering Documents
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close