Automating batch printing of DWF files using Design Review 2008

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:

Batch_print_wizard_2

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:

Batch_print_wizard_3

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.

Batch_print_wizard_4

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:

Batch_print_using_design_review

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.

14 responses to “Automating batch printing of DWF files using Design Review 2008”

  1. Printing Australia- flyers, br Avatar
    Printing Australia- flyers, br

    Thanks for sharing this!

  2. 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?

  3. 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

  4. Hi Kean,

    That was it! Setting BACKGROUNDPLOT sysvar to zero resolved the issue.

    Thanks,
    Artem

  5. 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!

  6. Kean Walmsley Avatar

    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

  7. Thanks for the quick reply. Any ideas where I could get source code examples using Design Review in VB.NET?

  8. Kean Walmsley Avatar

    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

  9. 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?

  10. Hi JD,

    Sorry - I don't know why that is.

    Regards,

    Kean

  11. Not only is there no sample code there,
    even if it were it would have no
    relevance to this particular topic as it
    is solely concerned with customizing the
    user interface.

    (And did you know your comment preview is
    a bit borked? It cuts off the right side.)

  12. Sorry, I don't quite see your point. I was answering a question that didn't directly relate to the post - a request for ADR API sample code.

    Yes, this post - unlike the vast majority of the others on this blog - is about using a product/tool's UI to customize it.

    And yes, the comment preview is messy, but it's TypePad's. I don't have any control over it.

  13. Hi Kean, I wrote the program for PDF program to follow your example & had success to plot. I had a problem is: its too slow to convert into PDF from DWG, Is there any way to do faster plot?

  14. Kean Walmsley Avatar

    Have you tried using AutoCAD with either the DWF/PDF Batch Publisher or ScriptPro 2.0 (ADN Plugins of the Month on Autodesk Labs)?

    Kean

Leave a Reply to Printing Australia- flyers, br Cancel reply

Your email address will not be published. Required fields are marked *