We sometimes receive questions on how best to automate the printing of DWF files. Autodesk Design Review 2008 now has a new Batch Print Plug-in enabling just this.
Once you've installed the plug-in, you'll be able to use the Batch Print Wizard in Design Review (on the file menu, once a DWF has been loaded). This Wizard allows you to configure a batch job for Design Review to process and save it to a BPJ (Batch Print Job) file. This BPJ (which is basically a very simple XML file) can then be used to drive the batch print process automatically.
The next logical step is clearly to create the BPJ programmatically, which can be done using a number of XML libraries (MS XML etc.) or simply by writing out a text file using your favourite string output routines.
So let's look at creating the BPJ file "manually" using the Batch Print Wizard.
Here's the second screen you'll see, once you've skipped the welcome:
When you've selected the files you wish to print and added them to the right-hand side using the ">" button, you can move on to the next page:
This is where you modify the print setup for each of your DWFs, by clicking on the item and hitting "Print Setup", or just double-clicking the item.
And then you're ready to save the BPJ file (or just "Print" directly).
I saved mine as "c:\My Documents\MyFiles.bpj", and here are its contents, with additional whitespace added for readability:
<configuration_file>
<DWF_File
FileName="C:\My Documents\\First.dwf"
PageSize="11.0 x 8.5 in"
NoOfSections="2"
Print_to_scale="100"
User_defined_Zoom_Factor="100"
Print_Style="0"
Print_What="0"
Fit_To_Paper="1"
Paper_Size="9"
Paper_Size_Width="2100"
Paper_Size_Height="2970"
Orientation="2"
Number_of_copies="1"
PrinterName="\\beihpa001\BEIPRN003"
Page_Range="1"
Print_Range_Str=""
Reverse_Order="0"
Collate="0"
printColor="0"
printAlignment="4"
Use_DWF_Paper_Size="0"
PaperName="A4"
useHPIP="0"
HPIPMediaID="-1"
HPIPExcludeEModel="1"
HPIPPaperName=""/>
<DWF_File
FileName="C:\My Documents\\Second.dwf"
PageSize="11.0 x 8.5 in"
NoOfSections="2"
Print_to_scale="100"
User_defined_Zoom_Factor="100"
Print_Style="0"
Print_What="0"
Fit_To_Paper="1"
Paper_Size="9"
Paper_Size_Width="2100"
Paper_Size_Height="2970"
Orientation="2"
Number_of_copies="1"
PrinterName="\\beihpa001\BEIPRN003"
Page_Range="1"
Print_Range_Str=""
Reverse_Order="0"
Collate="0"
printColor="0"
printAlignment="4"
Use_DWF_Paper_Size="0"
PaperName="A4"
useHPIP="0"
HPIPMediaID="-1"
HPIPExcludeEModel="1"
HPIPPaperName=""/>
</configuration_file>
This is clearly straightforward to create programmatically from your application. The next question is how best to automate the print process, now we have our BPJ.
The simplest way is to call the Design Review executable with the BPJ file as a command-line argument:
The executable returns straight away, and you'll see a log file created in the same location as the BPJ (in my case "c:\My Documents\MyFiles.log"), detailing the results of the print job:
Batch Printing initiated with Configuration file: "\My Documents\MyFiles.bpj". Start Time: Thu May 10 17:16:35 2007
Opening DWF file : "C:\My Documents\\First.dwf". Start Time: Thu May 10 17:16:35 2007
DWF file: "C:\My Documents\\First.dwf" Opened successfully. End Time: Thu May 10 17:16:37 2007
Status:DWF Open Successful
Started Printing DWF File: "C:\My Documents\\First.dwf". Start Time: Thu May 10 17:16:39 2007
Printing To : \\beihpa001\BEIPRN003
HPIP set to : False
Paper Size : 2100 X 2970
Print Range : Current Page
No Of Copies : 1
Scale : 100 %, Tile Pages (Not Applicable For 3D Sections)
Print Alignment: LowerLeft (Not Applicable For 3D Sections)
Orientation : Landscape
Print Color : Color
Started Printing Section Number : 0. Start Time: Thu May 10 17:16:39 2007
Finished Printing Section Number: 0. End Time : Thu May 10 17:16:42 2007
Started Printing Section Number : 1. Start Time: Thu May 10 17:16:43 2007
Finished Printing Section Number: 1. End Time : Thu May 10 17:16:43 2007
Finished Printing DWF file: "C:\My Documents\\First.dwf" . End Time: Thu May 10 17:16:43 2007
Opening DWF file : "C:\My Documents\\Second.dwf". Start Time: Thu May 10 17:16:43 2007
DWF file: "C:\My Documents\\Second.dwf" Opened successfully. End Time: Thu May 10 17:16:45 2007
Status:DWF Open Successful
Started Printing DWF File: "C:\My Documents\\Second.dwf". Start Time: Thu May 10 17:16:46 2007
Printing To : \\beihpa001\BEIPRN003
HPIP set to : False
Paper Size : 2100 X 2970
Print Range : Current Page
No Of Copies : 1
Scale : 100 %, Tile Pages (Not Applicable For 3D Sections)
Print Alignment: LowerLeft (Not Applicable For 3D Sections)
Orientation : Landscape
Print Color : Color
Started Printing Section Number : 0. Start Time: Thu May 10 17:16:46 2007
Finished Printing Section Number: 0. End Time : Thu May 10 17:16:49 2007
Started Printing Section Number : 1. Start Time: Thu May 10 17:16:49 2007
Finished Printing Section Number: 1. End Time : Thu May 10 17:16:50 2007
Finished Printing DWF file: "C:\My Documents\\Second.dwf" . End Time: Thu May 10 17:16:50 2007
Batch Printing Finished with Configuration file: "\My Documents\MyFiles.bpj". End Time: Thu May 10 17:16:50 2007
Total Time Taken to complete Batch Print Process: 0 hr: 0 Min: 15 Sec.
This log file can be parsed programmatically if it's important for your application to know whether any pages had difficulty printing.





Subscribe via RSS
Thanks for sharing this!
Posted by: Printing Australia- flyers, brochures, pamphlets, postcards & fliers | December 14, 2007 at 03:18 AM
Thank you for your example. It was very helpful for me.
I have a question. I created a new plotter using "Autodesk ePlot (PDF)". When I use AutoCAD's Plot command, it takes couple of seconds to produce the PDF file. However, when I try to generate the plot through the code, after pe.EndPlot(null), it takes between 30 Sec to a minute till PDF gets created. I have to actually test the ProcessPlotState during this time as I don’t want to return the control while PDF is not ready.
Any idea why it takes so much longer to produce the PDF this way?
Posted by: Artem | January 07, 2008 at 11:47 PM
Hi Artem,
It could be that background plotting is switched on. If the BACKGROUNDPLOT sysvar is set to 1 or 3, then PLOT will background plot. This doesn't explain why the command takes less time than your code, but it's a direction in which to start your investigations.
Regards,
Kean
Posted by: Kean | January 08, 2008 at 09:12 AM
Hi Kean,
That was it! Setting BACKGROUNDPLOT sysvar to zero resolved the issue.
Thanks,
Artem
Posted by: Artem | January 08, 2008 at 06:00 PM
Kean,
I'm a VB.NET programmer and need to write a Windows Service that prints DWF files. Can I use the Design Review API to print DWF files using VB.NET? Any basic code examples would be very helpful as well.
Thanks in advance!
Posted by: Todd | June 13, 2008 at 05:26 PM
Yes, you should be able to, though I don't have specific source code showing how to.
I'd personally be happier with implementing a web service to do this than a Windows service (which I don't know for sure will work with ADR as a component).
Regards,
Kean
Posted by: Kean | June 13, 2008 at 05:39 PM
Thanks for the quick reply. Any ideas where I could get source code examples using Design Review in VB.NET?
Posted by: Todd | June 13, 2008 at 05:43 PM
The ADR API documentation includes some sample code in C#, VB6 and JavaScript. C# or VB6 should be a good start for VB.NET.
Kean
Posted by: Kean | June 13, 2008 at 05:48 PM
I'm currently working with the batch printing and it's working properly. I'm dynamically creating the BPJ file in C# and then running the batch. The problem I'm having is trying to set the Page Range for printing. No matter what I put in this variable, it will print all the pages of a DWF. I'd like to only print the first page in the DWF. In fact when I'm using the Batch Print Wizard in Design Review it grays out all of the options to choose a page range in the Print Settings, "All" is the only option you can select. Do you know why this is?
Posted by: JD | December 02, 2008 at 09:10 PM
Hi JD,
Sorry - I don't know why that is.
Regards,
Kean
Posted by: Kean | December 02, 2008 at 10:56 PM