Forum Discussion
Log4TurtleShell
3 years agoFrequent Visitor
How to Decode a Base64 Encoded Bookmark
I am using this library, https://github.com/microsoft/PowerBI-JavaScript, to embed reports and handle bookmarks. I am calling capture() from the bookmarksManager object on my report. This returns a b...
klirium
2 years agoNew Member
The state of bookmarks is gzipped, so after you decoded it from base64 you need to decompress it:
static class Program
{
public static void Main()
{
// Replace with your actual Base64-encoded and gzipped string
string encodedAndGzippedString = "";
// Decode the Base64 string
byte[] decodedBytes = Convert.FromBase64String(encodedAndGzippedString);
// Decompress the gzipped data
string decompressedString = DecompressGzip(decodedBytes);
Console.WriteLine("Decompressed data:");
Console.WriteLine(decompressedString);
}
public static string DecompressGzip(byte[] compressedData)
{
using (var memoryStream = new MemoryStream(compressedData))
using (var gzipStream = new GZipStream(memoryStream, CompressionMode.Decompress))
using (var reader = new StreamReader(gzipStream, Encoding.UTF8))
{
return reader.ReadToEnd();
}
}
}
SitiV
2 years agoNew Member
Great post klirium - we've been struggling with trying to find a way to interpret saved bookmarks to handle updates when a change is made to a report and then the previous saved bookmarks become partially invalid. I haven't tested your code, but I was able to verify the concept of base64 and decompress does work. This site gives a nice way to plug in individual encoded bookmarks and see the plaintext https://www.zickty.com/gziptotext