Exporting Embedded PDF
Posted: Tue May 24, 2022 5:50 pm
Hello everyone,
I'm trying to automate the export of the embedded files (PDF and Office) from the design binder of a part,
I could open the files and save them but it's unreliable.
So I tried to write the buffer to a file, but there is some extra data that makes it unreadable.
Does someone know the encoding or serialization used for this buffer?
I'm trying to automate the export of the embedded files (PDF and Office) from the design binder of a part,
I could open the files and save them but it's unreliable.
So I tried to write the buffer to a file, but there is some extra data that makes it unreadable.
Does someone know the encoding or serialization used for this buffer?
Code: Select all
Const swCommands_Activate_Doc_Or_Journal As Integer = 2059
Private Sub ExtractOLE()
Dim swApp As SldWorks
swApp = GetObject(, "SldWorks.Application")
Dim swModel As ModelDoc2
swModel = swApp.ActiveDoc
Dim vOleObjs As Object
vOleObjs= swModel.Extension.GetOLEObjects(0)
Dim i As Integer
For Each swOleObj As SwOLEObject In vOleObjs
i += 1
'Console.WriteLine(" Filename: " & swOleObj.FileName & " Is linked? " & swOleObj.IsLinked)
'Console.WriteLine(" Buffer size: " & swOleObj.BufferSize)
'open the file
'swOleObj.Select(False)
'swModel.Extension.RunCommand(swCommands_Activate_Doc_Or_Journal, "")
'Extract the file
Dim OleData As Byte()
OleData = swOleObj.Buffer
File.WriteAllBytes("C:\temp\test" & i & ".pdf", OleData)
Next
End Sub