View Full Version : Page set up in PDF-Creator software

02-19-2008, 08:00 AM
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,:mkay

05-24-2008, 08:20 PM
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

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
swaLog.BreadcrumbID = "Validating ModelDoc2 object"
If modelDoc Is Nothing Then
Err.Raise (424)
modelDoc.Printer = swaPrinterName
swaLog.BreadcrumbID = "Configuring graphics and saving document"
blnOkay = modelDoc.Save3(swSaveAsOptions_Silent, lngError, lngWarning)
swaLog.BreadcrumbID = "Setting up page"
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

And here is the print function

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"
If documentPath = "" Then
If swaFilePath = "" Then
Err.Raise 422, , "Required property not set."
PrintDoc = False
Exit Function
strPath = swaFilePath
End If
strPath = documentPath
End If

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

swaLog.BreadcrumbID = "Opening document"
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."
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"
swaModelDocExt.PrintOut2 varPages, 1, False, swaModel.Printer, printFileName
swaModel.Printer = strPrevPrinter

swaLog.BreadcrumbID = "Closing application"
swaApp.ActivePrinter = swaPrinterName
swaApp.QuitDoc swaFileName
PrintDoc = True
Exit Function
swaLog.ErrorDescription = Err.Description
swaLog.ErrorNumber = Err.Number
Exit Function
End Function

This should get you started