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: 

inventor properties to pdf properties

4 REPLIES 4
Reply
Message 1 of 5
DJFore
1353 Views, 4 Replies

inventor properties to pdf properties

Can anyone tell me if there is a way to get a iproperty from a idw file into the (meta data) properties of a PDF.

I am creating pdf's of drawings for our online store to reference and I need these properties to be filled out so it can find the right file.

I would like to use ilogic that I have in inventor that tells it to save a pdf of the file also tell it to export the properties into PDF as well. Things like title would equal part number etc.. I may even have to tell it when it saves to pdf to create custom properties inside the pdf file to match what is coming from inventor.

Any suggestions would be greatly appreciated. 

Thanks

4 REPLIES 4
Message 2 of 5
mttb
in reply to: DJFore

Yes you can! Smiley Happy (at least I managed to do so)

First read the properties from your inventor file. Then 'simply' write them to the pdf.Smiley Very Happy

I use the Microsoft dsoFile.dll (http://support.microsoft.com/kb/224351/en-us). Read all carefully. You can access it via Inventor VBA for sure.

There are a few 'buts':

- It is clear that the custom properties in the pdf are properties that are applied to it from a non-native pdf environment, as if they are attached to it with a stapler. But they are there.

- I think I noticed that the properties aren't copied together with the file when copying the file via Windows Exploder, as if the stapled info isn't copied.

- I also use it for copying props to Excel 2003 docs, I'm not sure this will be true for 2007 or 2010.

 

 

 

Message 3 of 5
travistwinter
in reply to: mttb

i dont suppose you could post an example of the ilogic code involved in this?

if you could i would be most greatful as i am also interested this option 🙂

Message 4 of 5
mttb
in reply to: travistwinter

Hi Travistwinter,

 

the code I use is written in VBA. For TheDoc you can use any OLE doc (and I'm sure it used to work for pdf, too). See support.microsoft.com/kb/224351. After your reply I checked the functionality of my code again and found that it doesn't work for pdf anymore (switched from XP to win7), or at least isn't visible. Raised my eyebrows. However, below is the code. And if you google you can find more info on (custom) file properties and that pdf is different. Found something about XMP for adding metadata, but didn't look into that yet.

If you stumble upon a new solution, please let me know.

For Excel docs the code still works fine.

 

Sub Test()
 Dim oDoc As DrawingDocument
 Set oDoc = ThisApplication.ActiveDocument 'drawing to save as pdf
 Dim TheDoc As String
 TheDoc = "C:\test.pdf"
 oDoc.SaveAs TheDoc, True 'saveas pdf, otherwise for comment the line 
 Title = oDoc.PropertySets.Item("Design Tracking Properties").Item("Description").Value
 WriteProp TheDoc, "Title", Title
 SetAttr TheDoc, vbReadOnly + vbArchive 'set the file attribute flags (if needed)
End Sub

 

Sub WriteProp(fnam As String, propname As String, propval As Variant)
 On Error Resume Next
 Dim DSO As DSOFile.OleDocumentProperties
 Set DSO = New DSOFile.OleDocumentProperties
 Err.Clear
 DSO.Open fnam, ReadOnly:=False
 If Err.Number <> 0 Then
    DSO.Close False
    WritePropertyToClosedFile = False
    Exit Sub
 End If
 CallByName DSO.SummaryProperties, propname, VbLet, propval
 WritePropertyToClosedFile = (Err.Number = 0)
 DSO.Close savebeforeclose:=True
End Sub

 

Message 5 of 5
travistwinter
in reply to: DJFore

Thanks heaps mate
Ill give this a try 🙂
Ive gotta say this whole world of vba is fun as

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

Post to forums  

Autodesk Design & Make Report