Using PDFCreatotr with Revit

I am trying to use PDF Creator 3.0.2 with Revit 2014 through 2018. Specifically, I have a Revit Add-In written in C# that uses the Revit API to batch print PDF Files. I have configured an AutoSave profile but am having issues setting the Folder value (TargetDirectory) value. I cannot set the TargetDirectory from within my C# code using either Registry calls or the COM Wrapper. The only way I can get things to work is to set the TargetDirectory using the PDFCreator UI and hard coding the Folder field. I do not have the same issue with the FileName (FileNameTemplate) field. Is this behavior by design or is there a bug in PDFCreator preventing the Folder value from being set?

Hi,

it should work with the COM wrapper, could you share a little code snippet or additional details? The COM workflow doesn’t know a setting for automatic saving, it is always automatic; because of this, you also can’t change the setting for the target directory, but rather call ConvertTo(path) for the print job directly. There are some C# examples in the “COM Scripts” folder which gets installed together with PDFCreator.
Changing the setting through the registry should also be possible, but will only work if you set it before PDFCreator is loaded.

Best regards,

Robin

Here is a short snippet of code. This does not include setup code that sets the Revit Printing API to the PdfCreatorAutoSave virtual printer.

plotView.Print(true); // print a sheet using the Revit API
if (jobQueue.Count > 0) // there is a job in the queue
{
PrintJob printJob = jobQueue.NextJob;
printJob.SetProfileByGuid(“7d76f5b5-add8-4dc8-a399-a6e7df684b5b”);
printJob.SetProfileSetting(“FileNameTemplate”, Path.GetFileNameWithoutExtension(pdfOutputFilename)); // the actual filename
printJob.SetProfileSetting(“TargetDirectory”, “exportFolder”); // the output folder
}

I will replace the SetProfileSetting calls with the ConverTo(path) call to see if this works.

The code below seems to be working. I have some large jobs (800+ PDF files) I need to test with, but so far, things look good.

plotView.Print(true); // print a sheet using the Revit API
if (jobQueue.Count > 0) // there is a job in the queue
{
PrintJob printJob = jobQueue.NextJob;
printJob.SetProfileByGuid(“7d76f5b5-add8-4dc8-a399-a6e7df684b5b”);
printJob.ConvertTo(networkPdfOutputFilename);
}

1 Like

RevitPdf, did you manage to get your code to work? I'm having the same issues. Can you share a snippet of the plotView.Print?
Thanks

I did not. We are using Bluebeam right now.

Thanks for the replay.
I'm having na issue with the queued jobs, in one line of code it Works, and in another it doesn't work.
var jobQueue = CreateQueue();

                //var assemblyDir = Assembly.GetExecutingAssembly().Location;
                var resultsDir = dirName;
                //Directory.CreateDirectory(resultsDir);
                var convertedFilePath = Path.Combine(resultsDir, folhaNome + ".pdf");


                try
                {
                    //MessageBox.Show("Initializing the job queue");
                    //jobQueue.Clear();

                    jobQueue.Initialize();

                    //jobQueue.GetJobByIndex(1);
                    t.Start();

                    printMgr.PrintRange = PrintRange.Current;

                    printMgr.Apply();
                    System.Windows.Forms.MessageBox.Show(colorDepth.ToString());
                    view.Print(true);
                    //printMgr.SubmitPrint(view);
                    t.Commit();
                    System.Windows.Forms.MessageBox.Show("SUBMIT");
                    System.Windows.Forms.MessageBox.Show(convertedFilePath);
                    System.Windows.Forms.MessageBox.Show(view.Name.ToString());
                    //System.Windows.Forms.MessageBox.Show(printMgr.SubmitPrint().ToString());
                    System.Windows.Forms.MessageBox.Show(jobQueue.Count.ToString());
                    //MessageBox.Show("Printing windows test page...");
                    //PrintWindowsTestPage();

                    if (!jobQueue.WaitForJob(6))
                    {
                        System.Windows.Forms.MessageBox.Show("The job didn't arrive within 100 seconds");
                    }
                    else
                    {
                        //MessageBox.Show("Currently there are " + jobQueue.Count + " job(s) in the queue");
                        //MessageBox.Show("Getting job instance");
                        PrintJob printJob = jobQueue.NextJob;
                        //printMgr.SubmitPrint(view);
                        printJob.SetProfileByGuid("DefaultGuid");

                        printJob.ConvertTo(convertedFilePath);

                        if (!printJob.IsFinished || !printJob.IsSuccessful)
                        {
                            System.Windows.Forms.MessageBox.Show("Could not convert: ");
                        }
                    }
                }
                catch (Exception err)
                {
                    System.Windows.Forms.MessageBox.Show("An error occured: " + err.Message);
                }
                finally
                {
                    //MessageBox.Show("Releasing the queue object");
                    jobQueue.ReleaseCom();
                }

Hi RevitPdf, your code helped me.

I have a concern, how to add a view into queue ?? Because it always shows 0.

this is my code
Type queueType = Type.GetTypeFromProgID("PDFCreator.JobQueue");
dynamic queue = Activator.CreateInstance(queueType);

                                currentView.Print(true);

                                //queue.Initialize();

                                if (queue.Count > 0) // there is a job in the queue
                                {
                                    PrintJob printJob = queue.NextJob;
                                    printJob.SetProfileByGuid("7d76f5b5 - add8 - 4dc8 - a399 - a6e7df684b5b");
                                    printJob.ConvertTo(exportFilesPath+".pdf");
                                }

But my view gets printed with this statement currentView.Print(true); itself and queue always remains zero. Hence doesn't get inside that loop.

Thanks

Suraj