iLogic Code for PDF - Wont Accept Black & White (CutePDF Writer)

iLogic Code for PDF - Wont Accept Black & White (CutePDF Writer)

Jason.Rugg
Collaborator Collaborator
1,489 Views
9 Replies
Message 1 of 10

iLogic Code for PDF - Wont Accept Black & White (CutePDF Writer)

Jason.Rugg
Collaborator
Collaborator

I have the following code that uses "CutePDF Writer" to quickly generate a PDF drawing. I am unable to get it to come out Black & White though, it always comes out in color.

 

Any suggestions?

 

'[
Dim oDrgDoc As DrawingDocument
oDrgDoc = ThisApplication.ActiveDocument

' Set reference to drawing print manager' DrawingPrintManager has more options than PrintManager' as it's specific to drawing document
Dim oDrgPrintMgr As DrawingPrintManager
oDrgPrintMgr = oDrgDoc.PrintManager
' Set the printer name' comment this line to use default printer or assign another one
oDrgPrintMgr.Printer = "CutePDF Writer"

'Set the paper size , scale and orientation
oDrgPrintMgr.ScaleMode = kCustomScale
oDrgPrintMgr.ScaleMode = PrintScaleModeEnum.kPrintBestFitScale
oDrgPrintMgr.PaperSize = PaperSizeEnum.kPaperSizeLedger
'oDrgPrintMgr.PaperSize = 14338
oDrgPrintMgr.PrintRange = kPrintCurrentSheet
oDrgPrintMgr.Orientation = kLandscapeOrientation
'oDrgPrintMgr.PaperSource = 2
oDrgPrintMgr.AllColorsAsBlack = True
oDrgPrintMgr.SubmitPrint
']

0 Likes
1,490 Views
9 Replies
Replies (9)
Message 2 of 10

HermJan.Otterman
Advisor
Advisor

hello,

 

this VBA code is from the Inventor API help, maybe you can use this..

Public Sub PublishPDF()
    ' Get the PDF translator Add-In.
    Dim PDFAddIn As TranslatorAddIn
    Set PDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")

    'Set a reference to the active document (the document to be published).
    Dim oDocument As Document
    Set oDocument = ThisApplication.ActiveDocument

    Dim oContext As TranslationContext
    Set oContext = ThisApplication.TransientObjects.CreateTranslationContext
    oContext.Type = kFileBrowseIOMechanism

    ' Create a NameValueMap object
    Dim oOptions As NameValueMap
    Set oOptions = ThisApplication.TransientObjects.CreateNameValueMap

    ' Create a DataMedium object
    Dim oDataMedium As DataMedium
    Set oDataMedium = ThisApplication.TransientObjects.CreateDataMedium

    ' Check whether the translator has 'SaveCopyAs' options
    If PDFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then

        ' Options for drawings...

        oOptions.Value("All_Color_AS_Black") = 0

        'oOptions.Value("Remove_Line_Weights") = 0
        'oOptions.Value("Vector_Resolution") = 400
        'oOptions.Value("Sheet_Range") = kPrintAllSheets
        'oOptions.Value("Custom_Begin_Sheet") = 2
        'oOptions.Value("Custom_End_Sheet") = 4

    End If

    'Set the destination file name
    oDataMedium.FileName = "c:\temp\test.pdf"

    'Publish document.
    Call PDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
End Sub
If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


0 Likes
Message 3 of 10

Jason.Rugg
Collaborator
Collaborator

@HermJan.Otterman This code fails immediately, doesn't do anything for me.

0 Likes
Message 4 of 10

HermJan.Otterman
Advisor
Advisor

 

it is VBA code, you need to alter some small things if you want to use it in iLogic

so this works in iLogic:

  Public Sub main
        ' Get the PDF translator Add-In.
        Dim PDFAddIn As TranslatorAddIn
        PDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")

        'Set a reference to the active document (the document to be published).
        Dim oDocument As Document
        oDocument = ThisApplication.ActiveDocument

        Dim oContext As TranslationContext
        oContext = ThisApplication.TransientObjects.CreateTranslationContext
        oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism

        ' Create a NameValueMap object
        Dim oOptions As NameValueMap
        oOptions = ThisApplication.TransientObjects.CreateNameValueMap

        ' Create a DataMedium object
        Dim oDataMedium As DataMedium
        oDataMedium = ThisApplication.TransientObjects.CreateDataMedium

        ' Check whether the translator has 'SaveCopyAs' options
        If PDFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then

            ' Options for drawings...

            oOptions.Value("All_Color_AS_Black") = 0

            'oOptions.Value("Remove_Line_Weights") = 0
            'oOptions.Value("Vector_Resolution") = 400
            'oOptions.Value("Sheet_Range") = kPrintAllSheets
            'oOptions.Value("Custom_Begin_Sheet") = 2
            'oOptions.Value("Custom_End_Sheet") = 4

        End If

        'Set the destination file name
        oDataMedium.FileName = "c:\temp\test.pdf"

        'Publish document.
        PDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)

    End Sub

 

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


0 Likes
Message 5 of 10

chandra.shekar.g
Autodesk Support
Autodesk Support

@Jason.Rugg,

 

Minor correction in @HermJan.Otterman iLogic code(oOptions.Value("All_Color_AS_Black") = 1)

 

Public Sub main
        ' Get the PDF translator Add-In.
        Dim PDFAddIn As TranslatorAddIn
        PDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")

        'Set a reference to the active document (the document to be published).
        Dim oDocument As Document
        oDocument = ThisApplication.ActiveDocument

        Dim oContext As TranslationContext
        oContext = ThisApplication.TransientObjects.CreateTranslationContext
        oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism

        ' Create a NameValueMap object
        Dim oOptions As NameValueMap
        oOptions = ThisApplication.TransientObjects.CreateNameValueMap

        ' Create a DataMedium object
        Dim oDataMedium As DataMedium
        oDataMedium = ThisApplication.TransientObjects.CreateDataMedium

        ' Check whether the translator has 'SaveCopyAs' options
        If PDFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then

            ' Options for drawings...

            oOptions.Value("All_Color_AS_Black") = 1

            'oOptions.Value("Remove_Line_Weights") = 0
            'oOptions.Value("Vector_Resolution") = 400
            'oOptions.Value("Sheet_Range") = kPrintAllSheets
            'oOptions.Value("Custom_Begin_Sheet") = 2
            'oOptions.Value("Custom_End_Sheet") = 4

        End If

        'Set the destination file name
        oDataMedium.FileName = "c:\temp\test.pdf"

        'Publish document.
        PDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)

    End Sub

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



Message 6 of 10

Jason.Rugg
Collaborator
Collaborator

@chandra.shekar.g @HermJan.Otterman I took both sets of your code and pasted them into new illogic rules exactly as is and neither one of them output a B&W pdf, they both come out in color.

 

Attached is the drawing file I am working with.

0 Likes
Message 7 of 10

chandra.shekar.g
Autodesk Support
Autodesk Support

@Jason.Rugg,

 

To address this issue, a change request (INVGEN-27370) is created with engineering team.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 8 of 10

Jason.Rugg
Collaborator
Collaborator

@chandra.shekar.g So are you acknowledging that there definitely an issue here that needs resolved and that change request has been created?

0 Likes
Message 9 of 10

sebastien.forman
Advocate
Advocate

Hello, try to remove picture from your drawing (KCI and Whirlppol) for me this line work

 

oOptions.Value("All_Color_AS_Black") = 0 '(or 1)
0 Likes
Message 10 of 10

Jason.Rugg
Collaborator
Collaborator

@sebastien.forman No, this does not work for me either. I removed everything from the drawing except for the drawing views and it still outputs in color.

0 Likes