Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Thu Jun 08, 2023 2:28 pm

Dear Support Team,

I am writing to seek your expert assistance regarding the usage of the Spire.Doc library for converting DOCX files to PDF format. I have encountered a specific issue that requires your guidance and expertise.

The problem I am facing is related to the appearance of bookmarks in the resulting PDF files. Upon conversion, I have noticed that the bookmarks appear in red color, which is not the desired outcome. I have thoroughly reviewed my implementation, and I am utilizing the "SetCreateWordBookmarksUsingHeadings(true)" method to generate the bookmarks during the saving process.

To provide you with a comprehensive understanding of the situation, I have attached the relevant source code, input DOCX file, and the converted PDF to this support case. This will allow you to examine the issue firsthand and identify any potential causes or misconfigurations.

I kindly request your professional insight on the matter. Specifically, I would like to know if acquiring a license for Spire.Doc will resolve the red color issue with the bookmarks in the PDF files.

If the problem lies within my code rather than the licensing aspect, I would greatly appreciate your expertise in identifying any errors or shortcomings. Your guidance will be invaluable in rectifying the issue and ensuring the successful conversion of DOCX files to PDF format.

Thank you for your time and attention to this matter. I eagerly await your response, and I am confident that with your assistance, I will be able to resolve this issue promptly.

Sincerely, Dmytro

dima_test_account
 
Posts: 4
Joined: Mon May 29, 2023 12:09 pm

Fri Jun 09, 2023 9:06 am

Hello,

Thanks for your inquiry.
When using the “SetCreateWordBookmarksUsingHeadings(true) ”method, the generated bookmarks will indeed have the orange color by default. If you want to use the default bookmark color(or a custom color), you can implement it using the following code:
Code: Select all
       Document* wordDoc = new Document();
   wordDoc->LoadFromFile(L"sample.docx");
   ToPdfParameterList* parameters = new ToPdfParameterList();
   parameters->SetCreateWordBookmarksUsingHeadings(true);
               
        Spire::Common::Color color;
   boost::intrusive_ptr<Spire::Common::Color> colorPtr(&color);
   parameters->SetWordBookmarksColor(colorPtr);
   wordDoc->SaveToFile(L"converted.pdf", parameters);

Looking forward to your test feedback.

Sincerely
Wenly
E-iceblue support team
User avatar

Wenly.Zhang
 
Posts: 149
Joined: Tue May 16, 2023 2:19 am

Fri Jun 09, 2023 12:30 pm

Thanks, I am pleased to inform you that everything is now working perfectly after implementing the slight changes you proposed in the snippet. Specifically, I utilized the following code:

boost::intrusive_ptr<Spire::Common::Color> colorPtr(new Spire::Common::Color());
parameters->SetWordBookmarksColor(colorPtr);

These adjustments have completely resolved the problem, and the bookmarks now appear correctly in the PDF files without any red color.

dima_test_account
 
Posts: 4
Joined: Mon May 29, 2023 12:09 pm

Mon Jun 12, 2023 1:30 am

Hello,

You're welcome.
I'm glad to hear that your issue has been resolved. If you encounter other issues related to our products in the future, please feel free to contact us.
Have a nice day!

Sincerely,
Wenly
E-iceblue support team
User avatar

Wenly.Zhang
 
Posts: 149
Joined: Tue May 16, 2023 2:19 am

Return to Spire.Doc