<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: not able to save print to pdf file in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/not-able-to-save-print-to-pdf-file/m-p/11549151#M30612</link>
    <description>&lt;P&gt;Try this one just change path. You can edit for your need&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;'response = MessageBox.Show("Did you change path in this rule?", "Reminder",MessageBoxButtons.YesNo)&lt;BR /&gt;'If response = vbNo Then Exit Sub&lt;/P&gt;&lt;P&gt;'iLogicVb.RunRule("SAVE PDF")&lt;BR /&gt;&lt;BR /&gt;'Save PDF with options&lt;BR /&gt;'SaveLoc = "C:\"&lt;BR /&gt;'FileName = ThisDoc.FileName(True)&lt;BR /&gt;'ThisDoc.Document.SaveAs(FileName &amp;amp; (".pdf") , True)&lt;BR /&gt;oPath = ThisDoc.Path&lt;BR /&gt;PN = iProperties.Value("Project", "Part Number")&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;'path_and_namePDF = ThisDoc.Pathandname(False)&lt;BR /&gt;oFileName = ThisDoc.FileName(False) 'without extension&lt;BR /&gt;oPDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")&lt;BR /&gt;oDocument = ThisApplication.ActiveDocument&lt;BR /&gt;oContext = ThisApplication.TransientObjects.CreateTranslationContext&lt;BR /&gt;oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism&lt;BR /&gt;oOptions = ThisApplication.TransientObjects.CreateNameValueMap&lt;BR /&gt;oDataMedium = ThisApplication.TransientObjects.CreateDataMedium&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If oPDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then&lt;BR /&gt;oOptions.Value("All_Color_AS_Black") = 1&lt;BR /&gt;oOptions.Value("Remove_Line_Weights") = 1&lt;BR /&gt;oOptions.Value("Vector_Resolution") = 400&lt;BR /&gt;oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets&lt;BR /&gt;'oOptions.Value("Custom_Begin_Sheet") = 1&lt;BR /&gt;'oOptions.Value("Custom_End_Sheet") = 4&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;'Set the destination file name&lt;BR /&gt;oPath = "c:\"&lt;BR /&gt;'oPath = InputBox("Replace Path","New Path")&lt;BR /&gt;&lt;BR /&gt;oDataMedium.FileName = oPath &amp;amp; "\" &amp;amp; PN &amp;amp; ".pdf"&lt;BR /&gt;'Publish document&lt;BR /&gt;'Confirmation message&lt;BR /&gt;MessageBox.Show("PDF SAVED TO: " &amp;amp; oDataMedium.FileName, "PDF Saved", MessageBoxButtons.OK)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;On Error Goto handlePDFLock&lt;BR /&gt;'Publish document.&lt;BR /&gt;Call oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;'--------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Exit Sub&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;handlePDFLock:&lt;BR /&gt;MessageBox.Show("PDF could not be saved, most likely someone else has it open", "No PDF for you " &amp;amp; ThisApplication.GeneralOptions.UserName &amp;amp; "!")&lt;BR /&gt;Resume Next&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;handleXLSLock:&lt;BR /&gt;MessageBox.Show("No XLS", "iLogic")&lt;BR /&gt;Resume Next&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 13 Nov 2022 13:14:53 GMT</pubDate>
    <dc:creator>GosponZ</dc:creator>
    <dc:date>2022-11-13T13:14:53Z</dc:date>
    <item>
      <title>not able to save print to pdf file</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/not-able-to-save-print-to-pdf-file/m-p/11548941#M30611</link>
      <description>&lt;P&gt;Hi, here is my code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dim oDoc As PartDocument&lt;BR /&gt;oDoc = g_inventorApplication.ActiveDocument&lt;BR /&gt;Dim oPath As String = System.IO.Path.GetDirectoryName(oDoc.FullDocumentName)&lt;/P&gt;&lt;P&gt;'-----get PDF target folder path-----&lt;BR /&gt;Dim oPDFFolder As String = oPath &amp;amp; "\" &amp;amp; " PDF Files"&lt;/P&gt;&lt;P&gt;'-----Check for the pdf folder and create it if it does not exist-----&lt;BR /&gt;If Not System.IO.Directory.Exists(oPDFFolder) Then&lt;BR /&gt;System.IO.Directory.CreateDirectory(oPDFFolder)&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;'-----Search for idw's in folder-----&lt;BR /&gt;Dim MyDwgFiles As String()&lt;/P&gt;&lt;P&gt;MyDwgFiles = System.IO.Directory.GetFiles(oPath, "*.idw")&lt;/P&gt;&lt;P&gt;'-----Starts the Loop-----&lt;BR /&gt;For Each MyDwgFile As String In MyDwgFiles&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;g_inventorApplication.SilentOperation = True&lt;BR /&gt;Dim partDoc As DrawingDocument = g_inventorApplication.Documents.Open(MyDwgFile, False)&lt;BR /&gt;Dim CurrentFilename As String = System.IO.Path.GetFileNameWithoutExtension(partDoc.FullDocumentName)&lt;/P&gt;&lt;P&gt;'-----Filename definition-----&lt;BR /&gt;Dim oFileName As String = oPDFFolder &amp;amp; "\" &amp;amp; CurrentFilename &amp;amp; ".pdf"&lt;/P&gt;&lt;P&gt;'-----Publish document-----&lt;BR /&gt;Dim oDrgPrintMgr As Inventor.DrawingPrintManager = partDoc.PrintManager&lt;BR /&gt;oDrgPrintMgr.Printer = "PDFfill"&lt;BR /&gt;'oDoc.Interactive = False&lt;/P&gt;&lt;P&gt;'Dim oDrgPrintMgr As DrawingPrintManager&lt;BR /&gt;'oDrgPrintMgr = oDoc.PrintManager&lt;BR /&gt;oDrgPrintMgr.AllColorsAsBlack = True&lt;BR /&gt;oDrgPrintMgr.ScaleMode = Inventor.PrintScaleModeEnum.kPrintBestFitScale&lt;BR /&gt;oDrgPrintMgr.PaperSize = Inventor.PaperSizeEnum.kPaperSize11x17&lt;BR /&gt;oDrgPrintMgr.Orientation = Inventor.PrintOrientationEnum.kLandscapeOrientation&lt;BR /&gt;oDrgPrintMgr.ColorMode = Inventor.PrintColorModeEnum.kPrintColorPalette&lt;BR /&gt;oDrgPrintMgr.NumberOfCopies = 1&lt;BR /&gt;oDrgPrintMgr.Rotate90Degrees = False&lt;BR /&gt;oDrgPrintMgr.AllColorsAsBlack = False&lt;BR /&gt;oDrgPrintMgr.RemoveLineWeights = True&lt;BR /&gt;oDrgPrintMgr.TilingEnabled = False&lt;BR /&gt;oDrgPrintMgr.PrintToFile(oFileName)&lt;BR /&gt;oDrgPrintMgr.SubmitPrint()&lt;/P&gt;&lt;P&gt;partDoc.Close(False)&lt;BR /&gt;partDoc = Nothing&lt;BR /&gt;g_inventorApplication.SilentOperation = False&lt;/P&gt;&lt;P&gt;Next&lt;/P&gt;&lt;P&gt;g_inventorApplication.Documents.CloseAll(True)&lt;BR /&gt;'-----Opens PDF Folder-----&lt;BR /&gt;Shell("explorer.exe " &amp;amp; oPDFFolder, vbNormalFocus)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;In the above code " oDrgPrinter.Printer = "PDFfill"" on this line I am getting the error like "System.Runtime.InteropServices.COMException: 'Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))'"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If I commented out that line then pdf file is not saving at the destination folder. If anyone has idea please solve this problem.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 13 Nov 2022 08:23:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/not-able-to-save-print-to-pdf-file/m-p/11548941#M30611</guid>
      <dc:creator>2020mme013</dc:creator>
      <dc:date>2022-11-13T08:23:07Z</dc:date>
    </item>
    <item>
      <title>Re: not able to save print to pdf file</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/not-able-to-save-print-to-pdf-file/m-p/11549151#M30612</link>
      <description>&lt;P&gt;Try this one just change path. You can edit for your need&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;'response = MessageBox.Show("Did you change path in this rule?", "Reminder",MessageBoxButtons.YesNo)&lt;BR /&gt;'If response = vbNo Then Exit Sub&lt;/P&gt;&lt;P&gt;'iLogicVb.RunRule("SAVE PDF")&lt;BR /&gt;&lt;BR /&gt;'Save PDF with options&lt;BR /&gt;'SaveLoc = "C:\"&lt;BR /&gt;'FileName = ThisDoc.FileName(True)&lt;BR /&gt;'ThisDoc.Document.SaveAs(FileName &amp;amp; (".pdf") , True)&lt;BR /&gt;oPath = ThisDoc.Path&lt;BR /&gt;PN = iProperties.Value("Project", "Part Number")&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;'path_and_namePDF = ThisDoc.Pathandname(False)&lt;BR /&gt;oFileName = ThisDoc.FileName(False) 'without extension&lt;BR /&gt;oPDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")&lt;BR /&gt;oDocument = ThisApplication.ActiveDocument&lt;BR /&gt;oContext = ThisApplication.TransientObjects.CreateTranslationContext&lt;BR /&gt;oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism&lt;BR /&gt;oOptions = ThisApplication.TransientObjects.CreateNameValueMap&lt;BR /&gt;oDataMedium = ThisApplication.TransientObjects.CreateDataMedium&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If oPDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then&lt;BR /&gt;oOptions.Value("All_Color_AS_Black") = 1&lt;BR /&gt;oOptions.Value("Remove_Line_Weights") = 1&lt;BR /&gt;oOptions.Value("Vector_Resolution") = 400&lt;BR /&gt;oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets&lt;BR /&gt;'oOptions.Value("Custom_Begin_Sheet") = 1&lt;BR /&gt;'oOptions.Value("Custom_End_Sheet") = 4&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;'Set the destination file name&lt;BR /&gt;oPath = "c:\"&lt;BR /&gt;'oPath = InputBox("Replace Path","New Path")&lt;BR /&gt;&lt;BR /&gt;oDataMedium.FileName = oPath &amp;amp; "\" &amp;amp; PN &amp;amp; ".pdf"&lt;BR /&gt;'Publish document&lt;BR /&gt;'Confirmation message&lt;BR /&gt;MessageBox.Show("PDF SAVED TO: " &amp;amp; oDataMedium.FileName, "PDF Saved", MessageBoxButtons.OK)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;On Error Goto handlePDFLock&lt;BR /&gt;'Publish document.&lt;BR /&gt;Call oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;'--------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Exit Sub&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;handlePDFLock:&lt;BR /&gt;MessageBox.Show("PDF could not be saved, most likely someone else has it open", "No PDF for you " &amp;amp; ThisApplication.GeneralOptions.UserName &amp;amp; "!")&lt;BR /&gt;Resume Next&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;handleXLSLock:&lt;BR /&gt;MessageBox.Show("No XLS", "iLogic")&lt;BR /&gt;Resume Next&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 13 Nov 2022 13:14:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/not-able-to-save-print-to-pdf-file/m-p/11549151#M30612</guid>
      <dc:creator>GosponZ</dc:creator>
      <dc:date>2022-11-13T13:14:53Z</dc:date>
    </item>
  </channel>
</rss>

