I want to get the XMP-Data of an PDF-File.
In PDFTRON V.5.9.3 I used successfully the following VB code:
Dim l_pdfdoc As PDFDoc
l_pdfdoc = New PDFDoc(“c:\temp\test.pdf”)
If Not l_pdfdoc.InitSecurityHandler() Then
Return
End If
Dim xmp_stm As Obj = l_pdfdoc.GetRoot().FindObj(“Metadata”)
If Not xmp_stm Is Nothing Then
Dim stm As Filters.Filter = xmp_stm.GetDecodedStream()
Dim freader As New Filters.FilterReader(stm)
Dim outfile As New Filters.StdFile(“c:\temp\test.xmp”, Filters.StdFile.OpenMode.e_write_mode)
Dim fwriter As New Filters.FilterWriter(outfile)
fwriter.WriteFilter(freader)
fwriter.Flush()
outfile.Close()
End If
In Version 6.7.1 the Filters.StdFile does no longer exists and it is recommended to
use Filter.WriteToFile instead.
So I changed my code to:
Dim l_pdfdoc As PDFDoc
l_pdfdoc = New PDFDoc(“c:\temp\test.pdf”)
If Not l_pdfdoc.InitSecurityHandler() Then
Return
End If
Dim xmp_stm As Obj = l_pdfdoc.GetRoot().FindObj(“Metadata”)
If Not xmp_stm Is Nothing Then
Dim stm As Filters.Filter = xmp_stm.GetDecodedStream()
stm.WriteToFile(“c:\temp\test.xmp”, False)
End If
However the written file contains the whole pdf-file instead of the
XMP-Data.
What gets wrong here ?