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
Yes you can! (at least I managed to do so)
First read the properties from your inventor file. Then 'simply' write them to the pdf.
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.
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 🙂
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