Inventor Customization

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

Print/Save to PDF Issue

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

Hi,

 

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;

oPrint.SubmitPrint();

 

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
bennywise578
Posts: 32
Registered: ‎10-27-2011
Message 2 of 3 (517 Views)

Re: Print/Save to PDF Issue

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

UPDATE:

 

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*
jdkriek
Posts: 528
Registered: ‎03-29-2007
Message 3 of 3 (512 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"
        oDrgPrintMgr.SubmitPrint
    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

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube