Print/Save to PDF Issue

Print/Save to PDF Issue

Anonymous
Not applicable
1,756 Views
2 Replies
Message 1 of 3

Print/Save to PDF Issue

Anonymous
Not applicable

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.

 

0 Likes
1,757 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable

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.

0 Likes
Message 3 of 3

jdkriek
Advisor
Advisor

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
MFG Solutions Engineer
KETIV Technologies, Inc.


0 Likes