Set bookmark color works only with some colors

WebViewer Version: 10.3.0

setting bookmark color is not working correctly, some colors get set correctly but the majority is not.

Correct behavior:
await pdfnetBookmark.setColor(255, 0, 0); // set the book mark color to style="color: rgb(255, 0, 0);

Wrong behavior
but any other rgb combination is wrongly set:
await pdfnetBookmark.setColor(255, 50, 50); // set the bookmark color to style="color: rgb(255, 255, 255);

await pdfnetBookmark.setFlags(2); // doesn’t set bookmark font to bold?

Hello Senussi,

Thank you for reaching out, can you provide a sample application demonstrating your issue and what youre trying to accomplish? Thank you.

@tgordon

Thanks for reply,

I’m trying to re construct bookmarks from saved json from DB.

  1. first step is create Pdfnet Bookmark:
const pdfnetBookmark = await instance.Core.PDFNet.Bookmark.create(pdfDoc, outlineBookmark.name);
await pdfnetBookmark.setFlags(outlineBookmark.flags); // to set font bold, but doesn't work either
await pdfnetBookmark.setColor(outlineBookmark.r, outlineBookmark.g, outlineBookmark.b);

second step is to add that created bookmarks to pdfDoc

let pdfDoc = await _documentViewer.getDocument().getPDFDoc();
pdfDoc.addRootBookmark(pdfnetBookmark).then();

the problem:
setColor works only with some colors like setColor(255,0,0) this sets the bookmark style correctly to rgb(255,0,0)
But when setColor(100, 50, 100) that sets bookmark style to style=“color: rgb(255, 255, 255);”
which is completely a wrong color as shown in attachments.
bookmark_wrong_colors

Hello Senussi,

The PDF spec defines the color for Bookmarks from 0.0 → 1.0.
You can use this code snippet to convert from 0 → 255

    const calculatedColor = (r,g,b) => {return [r/255, g/255, b/255]};
    await pdfnetBookmark.setColor(...calculatedColor(100,50,100));

Best regards,
Tyler

@tgordon

Thanks for your answer. that fixed the problem.

Do you have any idea regards settings flags for font weight? it doesn’t work:

await pdfnetBookmark.setFlags(outlineBookmark.flags); // to set font bold, but doesn't work either

Hello Senussi,

What are you passing into outlineBookmark.flags? If you pass in 3 that would be bold and italics.

Thank you.
Tyler

@tgordon
Thanks for reply,
I pass 3 or 2 but nothing gets rendered no bold neither bold&italic.

Hello Senussi,

It looks like we currently dont support this in our bookmarks panel at the moment. I have created a feature request to support this.

Best regards,
Tyler