Adobe PDF printer does not create a PDF file

I am creating an add-in in Revit 2017 . The application will export drawing sheets to PDF files. So, whenever I try to export a sheet, a dialog box appears to select the location to save. I tried to programmatically disable the Prompting program by adding a key to the Windows registry (as described in the Adobe documentation page 15-16 ).

Now the invitation has turned off, and now I am facing a problem. The problem is that Adobe Printer got stuck while creating the pdf file. See Image below: The progress bar of a PDF file seems to be frozen, I waited more than 10 minutes and it did not create a PDF file .

Can someone provide any fix? Appreciate any suggestion.

PDF file fails, process seems to be frozen

Edit here is the code I wrote for this purpose. Hope this helps identify the problem.

public static bool ExportSheetToPDF(Document doc, string path) { using (Transaction tx = new Transaction(doc) { tx.Start("Exportint to PDF"); PrintManager pm = doc.PrintManager; pm.SelectNewPrintDriver("Adobe PDF"); pm.Apply(); pm.PrintRange = PrintRange.Current; pm.Apply(); pm.CombinedFile = true; pm.Apply(); pm.PrintToFile = true; pm.Apply(); pm.PrintToFileName = path + @"\PDF\" + "abc.pdf"; pm.Apply(); SuppressAdobeDialogAndSaveFilePath(path + @"\PDF\" + "abc.pdf"); pm.SubmitPrint(); pm.Apply(); tx.Commit(); } return true; } // Add Registry Key to suppress the dialog box public static void SuppressAdobeDialogAndSaveFilePath(string value) { var valueName = @"C:\Program Files\Autodesk\Revit 2017\Revit.exe"; var reg = currentUser.OpenSubKey(key, true); var tempReg = reg.OpenSubKey(valueName); if (tempReg == null) { reg = reg.CreateSubKey(valueName); } reg.SetValue(valueName, value); reg.Close(); } 
0
source share

All Articles