Consulting

Results 1 to 2 of 2

Thread: Page set up in PDF-Creator software

  1. #1
    VBAX Newbie
    Joined
    Feb 2008
    Posts
    1
    Location

    Page set up in PDF-Creator software

    Hi to All,
    I came here after I gave up of answers in pdfforge.co.il
    I have made a vba script for solidworks cad software to print a batch of drawings using the PDFCreator software version 0.9.5.
    Attach a link for tha basis of my script for the use of PDFCreator excelguru.ca/node/21
    How do I force the pdfcreator to take the pagesetup setting of the printed document?
    When I send to print to PDFCreator a page with page setup of A3 it saves the document as it was printed on A4 and truncates the rest of the document.
    If I do it without the script, only manualy with PDFCreator the page is properly being saved without cutting any margins.
    I don't know how to set up the vba script so it will take the document original page setup.
    I will really appreciate any advice,
    Amir

  2. #2
    I would need more information for instance are we talking slddrw, sldprt, sldasm. Since you said drawings I will asume you use drawing files.

    How are you using pdfcreator? Are you sending the data to the printer or are you openinging pdfcreator and telling it to print the file.

    Anyways here is a function I use to setup the printer just befor I send the print command

    [vba]
    Private Function SetupPrint(ByRef modelDoc As SldWorks.ModelDoc2, ByRef application As SldWorks.SldWorks) As Boolean
    swaLog.MethodID = "SetupPrint"
    Dim objPageSetup As SldWorks.PageSetup
    Dim lngError As Long
    Dim lngWarning As Long
    Dim blnOkay As Boolean

    'Use the code below in ADOBEagent
    'Dim p As VB.Printer

    'For Each p In VB.Printers
    'If p.DeviceName = “ThePrinterIWantToBeTheDefault“ Then
    'Set VB.DefaultPrinter = p
    'End If
    'Next
    swaLog.BreadcrumbID = "Validating ModelDoc2 object"
    swaLog.Trace
    If modelDoc Is Nothing Then
    Err.Raise (424)
    Else
    modelDoc.Printer = swaPrinterName
    swaLog.BreadcrumbID = "Configuring graphics and saving document"
    swaLog.Trace
    modelDoc.ViewZoomtofit2
    modelDoc.GraphicsRedraw2
    blnOkay = modelDoc.Save3(swSaveAsOptions_Silent, lngError, lngWarning)
    swaLog.BreadcrumbID = "Setting up page"
    swaLog.Trace
    Set objPageSetup = modelDoc.PageSetup
    objPageSetup.ScaleToFit = True
    application.SetUserPreferenceIntegerValue swPageSetupPrinterDrawingColor, swPageSetup_ColorGrey
    End If
    End Function
    Public Function GetSheetNames() As String()
    Dim i As Integer
    Dim strSheets() As String
    ReDim strSheets(UBound(swaSheetNames))
    For i = 0 To UBound(swaSheetNames)
    strSheets(i) = swaSheetNames(i)
    Next i
    GetSheetNames = strSheets
    'GetSheetNames = swaSheetNames
    End Function

    [/vba]

    And here is the print function
    [vba]
    Private Function PrintDoc(ByVal printFileName As String, Optional ByVal documentPath As String) As Boolean
    swaLog.MethodID = "PrintDoc"
    On Error GoTo ErrorHandler
    Dim strPath As String
    Dim error As Long
    Dim warning As Long
    Dim strPrevPrinter As String
    Dim DocType As Long
    Dim varPages As Variant

    swaLog.BreadcrumbID = "Checking file path"
    swaLog.Trace
    If documentPath = "" Then
    If swaFilePath = "" Then
    Err.Raise 422, , "Required property not set."
    PrintDoc = False
    Exit Function
    Else
    strPath = swaFilePath
    End If
    Else
    strPath = documentPath
    End If

    swaLog.BreadcrumbID = "Getting document type"
    swaLog.Trace
    DocType = GetDocType()

    swaLog.BreadcrumbID = "Opening document"
    swaLog.Trace
    Set swaModel = swaApp.OpenDoc6(strPath, DocType, swOpenDocOptions_Silent, "", error, warning)
    Set swaModelDocExt = swaModel.extension
    swaApp.visible = False
    strPrevPrinter = swaApp.ActivePrinter
    Call SetupPrint(swaModel, swaApp)

    swaLog.BreadcrumbID = "Set variable for page names if drawing."
    swaLog.Trace
    If DocType = document.swDocDRAWING Then
    Set swaDraw = swaModel
    swaSheetNames = swaDraw.GetSheetNames
    swaDraw.ActivateSheet swaSheetNames(0)
    swaSheetCount = UBound(swaSheetNames)
    End If

    'Printing page
    swaLog.MethodID = "PrintDoc"
    swaLog.BreadcrumbID = "Printing document"
    swaLog.Trace
    swaModelDocExt.PrintOut2 varPages, 1, False, swaModel.Printer, printFileName
    swaModel.Printer = strPrevPrinter

    swaLog.BreadcrumbID = "Closing application"
    swaLog.Trace
    swaApp.ActivePrinter = swaPrinterName
    swaApp.QuitDoc swaFileName
    PrintDoc = True
    Exit Function
    ErrorHandler:
    swaLog.ErrorDescription = Err.Description
    swaLog.ErrorNumber = Err.Number
    swaLog.Fault
    Exit Function
    End Function
    [/vba]

    This should get you started

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •