https://www.cadforum.net/viewtopic.php?t=2058
I cannot attach samples due to company regulation.
I am trying to modify the PDM Task macro to print in PDF instead of a phisical printer as the export to PDF function (basically save as -> pdf) is bugged and the output pdf differs from what you see on screen. The PDF printer works perfectly from SW interface (File -> Print), but if it run from the macro there are some files in my sample data that often cannot be correctly exported: often they end up as a minuscule drawing in a corner of the paper, like the pdf creation was aborted midway before fitting drawing to the paper size; sometimes the drawing borders are fitted and only the text and some lines remain small in a corner of the "paper space".
The point is that the same files that "fail" with the macro are always printed correctly in PDF from SW UI, so even if there is a problem inside those files that issue is ignored by the print interface within solidworks and ghostscript makes a correct PDF.
With my very limited VBA skills I managed to modify the TASK macro to work with the PDF printer, and I tried to update the method from PrintOut2 to PrintOut3 with the same outcome. Same bugged PDF from the same "problematic" files.
I am looking to upgrade to PrintOut4 in the hope it fixes the PDF and give me the same outcome I get from the SW Print command in the UI, but PrintOut4 is quite different and I am looking for some help to undestand how to do it.
For reference
PrintOut2 Method (IModelDocExtension) https://help.solidworks.com/2010/englis ... tout2.html
Prints the document, without displaying any dialogs or message boxes.
Code: Select all
Dim instance As IModelDocExtension
Dim PageArray As System.Object
Dim Copies As System.Integer
Dim Collate As System.Boolean
Dim Printer As System.String
Dim PrintFileName As System.String
instance.PrintOut2(PageArray, Copies, Collate, Printer, PrintFileName)
Code: Select all
Dim instance As IModelDocExtension
Dim PageArray As System.Object
Dim Copies As System.Integer
Dim Collate As System.Boolean
Dim Printer As System.String
Dim PrintFileName As System.String
Dim ConvertToHighQuality As System.Boolean
instance.PrintOut3(PageArray, Copies, Collate, Printer, PrintFileName, ConvertToHighQuality)
PrintOut4 Method https://help.solidworks.com/2015/englis ... tOut4.html
Code: Select all
Dim instance As IModelDocExtension
Dim Printer As System.String
Dim PrintFileName As System.String
Dim PrintSpecification As System.Object
instance.PrintOut4(Printer, PrintFileName, PrintSpecification)
Code: Select all
Dim instance As IPrintSpecification
Property Collate Gets or sets whether to collate the pages in multiple copies of this document.
Property ConvertToHighQuality Gets or sets whether to convert draft quality drawing views to high quality.
Property CurrentSheet Gets the index of the current sheet.
Property FromScale Gets or sets the custom "from" scale factor for the current drawing sheet.
Property NumberOfCopies Gets or sets the number of copies to print.
Property PrintBackground Gets or sets whether to print the background.
Property PrintCrossHatchOnOutOfDateViews Gets or sets whether to print a cross hatch on out-of-date views.
Property PrinterQueue Gets or sets the printer to use.
Property PrintFile Gets or sets the path and file name to which to print the document.
Property PrintRange Gets or sets the range of pages to print.
Property PrintToFile Gets or sets whether to print to a file.
Property PrintWhiteItemsBlack Gets or sets whether to print white lines and white text in black.
Property ScaleMethod Gets or sets the page selection option for printing.
Property SheetCount Gets the number of sheets in this drawing.
Property ToScale Gets or sets the custom "to" scale factor for the current drawing sheet.
Property XOrigin Gets or sets the X-coordinate of the print window origin.
Property YOrigin Gets or sets the Y-coordinate of the print window origin.
From what I understand I need to set those properties before printing with PrintOut4.
To export in PDF I need a 100% scale, how it can be set up?
Also how the paper is passed to the printer?