How do I extract XMP Data in Version 6

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 ?

Hello,

We were unable to reproduce the issue using your code on the latest version of the SDK. Could you please try the latest version of PDFTron, and let us know if you are still able to reproduce the issue?

You can download it from the below link:
https://www.pdftron.com/form/sign-in/

If you are still able to reproduce the issue, could you please email support@pdftron.com with the file you are testing with, so that we can investigate further?

Thank you.