Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm not an expert, more precisely I'm learning C++. Can someone can help me with the code, I wrote the code but I get the error:
"no instance of constructor "Spire::Pdf::Graphics::PdfSolidBrush::PdfSolidBrush" matches the argument leaf"
'Spire::Pdf::Graphics::PdfSolidBrush::PdfSolidBrush(Spire::Pdf::Graphics::PdfRGBColor)': cannot convert argument 1 from 'Spire::Pdf::Graphics::PdfRGBColor ^' to 'Spire::Pdf::Graphics::PdfRGBColor ^' :Pdf::Graphics::PdfRGBColor'"

The next question is, how to display the document in spire pdfviwer without saving

What I have tried:

C++
private: System::Void button1_Click
     (System::Object^ sender, System::EventArgs^ e) {
		PdfDocument^ doc = gcnew PdfDocument;
		PdfPageBase^ page = doc->Pages->Add();
		Spire::Pdf::Graphics::PdfFontBase^ font = 
          gcnew Spire::Pdf::Graphics::PdfFont
          (Spire::Pdf::Graphics::PdfFontFamily::Helvetica, 15.0f);
		   Spire::Pdf::Graphics::PdfRGBColor^ color = gcnew 
           Spire::Pdf::Graphics::PdfRGBColor(0, 175, 178);
		   Spire::Pdf::Graphics::PdfSolidBrush^ brush = gcnew 
           Spire::Pdf::Graphics::PdfSolidBrush(color);
		   page->Canvas->DrawString
           (textBox3->Text, font, brush, 130.0f, 130.0f);
	}
Posted
Updated 6-Nov-23 4:06am
v2

1 solution

I know nothing about Spire, but the error message suggests the constructor is asking for a PdfRGBColor object, rather than a reference. So try something like:
C++
Spire::Pdf::Graphics::PdfRGBColor color(0, 175, 178);
Spire::Pdf::Graphics::PdfSolidBrush^ brush = gcnew Spire::Pdf::Graphics::PdfSolidBrush(color);


But you really need to check the documentation to be certain.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900