probleme is image only and wxpdf...  [SOLVED]

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.
JPlaroche
Earned some good credits
Earned some good credits
Posts: 131
Joined: Fri Dec 09, 2005 4:58 pm
Contact:

probleme is image only and wxpdf...

Postby JPlaroche » Tue May 16, 2006 3:14 pm

int main(int argc, char** argv)
{
wxPdfDocument pdf;
pdf.AddPage();
pdf.Image(_T("clips.jpg"),40,10,0);
pdf.SaveAsFile(_T("clipping.pdf")); // ok generat pdf text not picture

return 0;
}


is very GOOD all works perfectly

except that the picture ..... does not climb in the pdf

version 0.7

I have tested and put in focntion d
apprendre et developper en C++ des sub routine interfac� HIM et BD pour validation acquis
Jean-Pierre

project define DB descripteur idem IBM400
http://www.ombrebleu.com/wxsrc/src/

JPlaroche
Earned some good credits
Earned some good credits
Posts: 131
Joined: Fri Dec 09, 2005 4:58 pm
Contact:

Re: probleme is image only and wxpdf...

Postby JPlaroche » Tue May 16, 2006 6:25 pm

int main(int argc, char** argv)
{
wxFileInputStream f(_T("wxpdfdoc.png"));
wxPdfDocument pdf;
pdf.Open();
pdf.AddPage();
pdf.SetFont(_T("courier"),_T("B"),10);
//wxColour(red=0, green=0, blue=0)
pdf.SetTextColor(wxColour(220,50,50));
// pdf.SetTextColor(128);
pdf.Text(01,3,_T("Hello World!"));
pdf.Image(_T("wxpdfdoc.png"),10,10,130,0,_T("PNG"));
pdf.Image(_T("wxpdfdoc.png"),10,50,130);
pdf.Image(_T("wxpdfdoc"),10,80,130);

// pdf.SetTextColor(128);
pdf.Text(01,50,_T("Hello World!"));
pdf.Close();
if (f.Ok() == true) pdf.SaveAsFile(_T("clipping.pdf"));

return 0;
}

is ok pdf is not ok picture

:?: :roll: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry:[/quote]
apprendre et developper en C++ des sub routine interfac� HIM et BD pour validation acquis

Jean-Pierre



project define DB descripteur idem IBM400

http://www.ombrebleu.com/wxsrc/src/

utelle
Moderator
Moderator
Posts: 828
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: probleme is image only and wxpdf...  [SOLVED]

Postby utelle » Tue May 16, 2006 10:28 pm

JPlaroche wrote:int main(int argc, char** argv)
{
wxFileInputStream f(_T("wxpdfdoc.png"));
wxPdfDocument pdf;
pdf.Open();
pdf.AddPage();
pdf.SetFont(_T("courier"),_T("B"),10);
//wxColour(red=0, green=0, blue=0)
pdf.SetTextColor(wxColour(220,50,50));
// pdf.SetTextColor(128);
pdf.Text(01,3,_T("Hello World!"));
pdf.Image(_T("wxpdfdoc.png"),10,10,130,0,_T("PNG"));
pdf.Image(_T("wxpdfdoc.png"),10,50,130);
pdf.Image(_T("wxpdfdoc"),10,80,130);

// pdf.SetTextColor(128);
pdf.Text(01,50,_T("Hello World!"));
pdf.Close();
if (f.Ok() == true) pdf.SaveAsFile(_T("clipping.pdf"));

return 0;
}

is ok pdf is not ok picture

Usually there are only two possible reasons why an image file is not included by wxPdfDocument:

1) The image file is not found at the given location.
2) The image file is not valid.

But your example reveals a third one:

Since you do not use wxApp in your code above (as the sample application coming with wxPdfDocument does) the local file system handler is not initialized. Since the Image method of wxPdfDocument uses wxFileSystem to access the image files the Image method fails to open the file due to the missing file handler.

Either use wxApp in your program or explicitly initialize the local file system handler in your program by calling

wxFileSystem::AddHandler(new wxLocalFSHandler);

at the beginning of your main program. But don't forget to call

wxFileSystem::CleanUpHandlers();

before exiting your program.

Regards,

Ulrich

JPlaroche
Earned some good credits
Earned some good credits
Posts: 131
Joined: Fri Dec 09, 2005 4:58 pm
Contact:

Re: probleme is image only and wxpdf...

Postby JPlaroche » Wed May 17, 2006 11:05 am

utelle wrote:
JPlaroche wrote:int main(int argc, char** argv)
{

wxFileSystem::AddHandler(new wxLocalFSHandler);

wxPdfDocument pdf;
pdf.Open();
pdf.AddPage();
pdf.SetFont(_T("courier"),_T("B"),10);
//wxColour(red=0, green=0, blue=0)
pdf.SetTextColor(wxColour(220,50,50));
pdf.Text(01,3,_T("Hello World!"));
pdf.Image(_T("wxpdfdoc.png"),10,10,130,0,_T("PNG"));
pdf.Close();
pdf.SaveAsFile(_T("clipping.pdf"));
wxFileSystem::CleanUpHandlers();
return 0;
}
I applied the modifications

wxFileSystem::AddHandler(new wxLocalFSHandler);

at the beginning of your main program. But don't forget to call

wxFileSystem::CleanUpHandlers();

before exiting your program.

Regards,

Ulrich



Merci ok
apprendre et developper en C++ des sub routine interfac� HIM et BD pour validation acquis

Jean-Pierre



project define DB descripteur idem IBM400

http://www.ombrebleu.com/wxsrc/src/


Return to “wxCode”

Who is online

Users browsing this forum: No registered users and 2 guests