Inventor Customization

Inventor Customization

Active Contributor
Posts: 32
Registered: ‎10-27-2011
Message 1 of 3 (612 Views)

Print/Save to PDF Issue

612 Views, 2 Replies
06-15-2012 11:22 AM



I am simply trying to print or save an Inventor .DWG file to a .PDF file via C# - the issue being that the .PDF page size must correspond to the active sheet size in Inventor.


When I try printing to a PDF using:


oPrint.Printer = "Adobe PDF";

oPrint.ScaleMode = PrintScaleModeEnum.kPrintBestFitScale;

oPrint.PaperSize = PaperSizeEnum.kPaperSize11x17;

oPrint.Orientation = PrintOrientationEnum.kLandscapeOrientation;

oPrint.SetSheetRange(1, 1);

oPrint.PrintRange = PrintRangeEnum.kPrintSheetRange;



I get a message saying I have to uncheck "Rely on system fonts only; do not use document fonts." in the Adobe PDF settings. Is there a way to do this programmatically?


When I export to PDF using:


TranslatorAddIn PDFAddin = (TranslatorAddIn)instance.ApplicationAddIns.get_ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}");

TranslationContext oContext = instance.TransientObjects.CreateTranslationContext();

oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism;

NameValueMap oOptions = instance.TransientObjects.CreateNameValueMap();

DataMedium oData = instance.TransientObjects.CreateDataMedium();

oOptions.set_Value("Sheet_Range", PrintRangeEnum.kPrintCurrentSheet);

oData.FileName = @"C:\Users\bsmith\Desktop\test.pdf";

PDFAddin.SaveCopyAs(oDoc, oContext, oOptions, oData);


This works but I cannot set the PDF page size. Again, is there a way to do this programmatically?


I am using Inventor 2010, Adobe Acrobat 9 Pro, Windows 7, 64 bit.



Any help/suggestions would be greatly appreciated. Thank you.


Active Contributor
Posts: 32
Registered: ‎10-27-2011
Message 2 of 3 (593 Views)

Re: Print/Save to PDF Issue

06-18-2012 06:27 AM in reply to: bennywise578



I am able to remove the "Rely on system fonts only; do not use document fonts" error by simply configuring my printer so that this box is always unchecked.


Now when I SubmitPrint() I do not receive an error but the Save As... dialog box comes up which I would like to avoid.


When I try PrintToFile("filename") I get the following error:


"Acrobat could not open '[name of file]' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded).


To create an Adobe PDF document, go to the source application. Then print the document to Adobe PDF."


Again, any help would be greatly appreciated. Thanks.

*Expert Elite*
Posts: 545
Registered: ‎03-29-2007
Message 3 of 3 (588 Views)

Re: Print/Save to PDF Issue

06-18-2012 11:22 AM in reply to: bennywise578

PrintToFile() and SubmitPrint() work fine with CutePDF Writer, it's free as well.


Public Sub TrinityCutePDF()
    Set oApp = ThisApplication
    If oApp.ActiveDocument.DocumentType = kDrawingDocumentObject Then
        Dim oDrgDoc As DrawingDocument
        Set oDrgDoc = ThisApplication.ActiveDocument
        Dim oDrgPrintMgr As DrawingPrintManager
        Set oDrgPrintMgr = oDrgDoc.PrintManager
        'Printer name
        oDrgPrintMgr.Printer = "CutePDF Writer"
        'Paper size, scale and orientation
        oDrgPrintMgr.AllColorsAsBlack = True
        oDrgPrintMgr.ColorMode = kPrintGrayScale
        oDrgPrintMgr.ScaleMode = kPrintBestFitScale
        oDrgPrintMgr.PaperSize = kPaperSize11x17
        oDrgPrintMgr.PrintRange = kPrintAllSheets
        oDrgPrintMgr.Orientation = kLandscapeOrientation
        oApp.StatusBarText = "Creating PDF"
    End If
End Sub



Jonathan D. Kriek

Autodesk Inventor Certified Expert
Microsoft Certified Application Developer
Did I help you? Please choose Accept as Solution or Kudos below
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.