Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SaveFileAsPdf with VB.net?

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
mucip
4524 Views, 10 Replies

SaveFileAsPdf with VB.net?

Hi,

Is there way to save as pdf file our idw files? I do not want to use "pdf printer" method like "zan image" or "PDF Creator"...

 

Infact, there is menu "save as pdf"... So why shouldn't I use it in VB.Net?...

 

Version Inventor 2012...

 

Regards,

Mucip:)

 

10 REPLIES 10
Message 2 of 11
thomaskennedy
in reply to: mucip

You can use the SaveAs method in VB but you need to add ".PDF" to your filename

 

In iLogic you would use :

 

ThisDoc.Document.SaveAs("C:\yourfolder\filename.PDF" , True)

Or in vb you would use something like :

 

Dim oDoc As Inventor.Document
oDoc = ThisApplication.ActiveDocument

oDoc.SaveAs("C:\yourfolder\filename.PDF",True)  

 

Hope this helps,

Tom

Message 3 of 11
mucip
in reply to: thomaskennedy

Hi,

Thanks alot for your kind interest... Yesterday I found this info below page infact.

http://modthemachine.typepad.com/my_weblog/2009/01/translating-files-with-the-api.html

 

But I need to create merged pdf file from more than one idw files which have more than one sheets... But in abowe case we can create only only one pdf file of each idw sheet... Is there any solution?...

 

Regards,

Mucip:)

 

 

 

 

Message 4 of 11
jdkriek
in reply to: mucip

I actually access our PDF addin - like the old Plot to File, so that I can set certain options within it including all sheets as one PDF.

 

Public Sub MakePDF()
    If ThisApplication.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.ScaleMode = kPrintBestFitScale
        oDrgPrintMgr.PaperSize = kPaperSize11x17
        oDrgPrintMgr.PrintRange = kPrintAllSheets
        oDrgPrintMgr.Orientation = kLandscapeOrientation
        oDrgPrintMgr.SubmitPrint
    End If
End Sub

 

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 5 of 11
mucip
in reply to: mucip

Hi,

Thanks a lot for your kind interest.

 

I solved! As I said before I did not want to use third party printer like Cute or Zan image...

 

I use "saved as" all sheets to pdf and save their filenames like 000.pdf, 001.pdf, 003.pdf etc..  in temp directory. Than I used "itextsharp.dll" to merge all these pdf documents. And perfect solution 🙂

 

Regards,

Mucip 🙂

Message 6 of 11
skyngu
in reply to: mucip

hi,

 

how do you use "itextsharp.dll"? i can not add reference in vba editor. thanks.

Autodesk Inventor Professional 2019
Message 7 of 11
mucip
in reply to: mucip

Hi,

Actually I did not use this dll with VBA. I used it with VB Express 2010. I do not have any idea about using this with VBA...

 

Regards,

Mucip:) 

Message 8 of 11
ekinsb
in reply to: mucip

Here's another approach where you don't need to use any additional components.  Inventor's PDF translator supports writing all of the sheets into a single file.  By directly driving the translator you can control this.  Below is a VBA sample from Inventor's programming help that demonstrates 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("Sheet_Range") = kPrintAllSheets
 
        'oOptions.Value("Remove_Line_Weights") = 0
        'oOptions.Value("Vector_Resolution") = 400
        '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

Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 9 of 11
mucip
in reply to: mucip

Hi,

For your information... I got a problem when I use standart pdf create function of Inventor... When I use this I can not search Turkish string in pdf output drawing file...

 

Be careful...

 

Regards,

Mucip:)

Message 10 of 11
skyngu
in reply to: mucip

brian,

 

I am using the same approach as you. but i want to merage all pdf file into one.

in my case, all part drawings from one assembly go into one pdf.  I guess I need third party resource.

thanks.

 

mucip,

i found out itextsharp is .net not .com. I dont think i can use in vba.

thanks

Autodesk Inventor Professional 2019
Message 11 of 11
skyngu
in reply to: skyngu

base on the resource i have right now, i do everything in iloigc which is .net.

then I call ilogic rule at vba. it works fine....haha such as workaround.

Autodesk Inventor Professional 2019

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report