wxPDFDoc without building a library Topic is solved
- evstevemd
- Part Of The Furniture
- Posts: 2409
- Joined: Wed Jan 28, 2009 11:57 am
- Location: United Republic of Tanzania
wxPDFDoc without building a library
I want to use wxPDFDoc with my app. I don't want to build it separately and I wonder if I can just include the files with my project and build them together.
Also I want to use System fonts so I don't want to include with my app extra fonts. Are those two things possible?
Also I want to use System fonts so I don't want to include with my app extra fonts. Are those two things possible?
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Re: wxPDFDoc without building a library
Sure, you can do that of course. There are currently no external dependencies except wxWidgets.evstevemd wrote:I want to use wxPDFDoc with my app. I don't want to build it separately and I wonder if I can just include the files with my project and build them together.
Well, that depends on the requirements of your application. If you can restrict your application to just use the 14 PDF / PostScript core fonts Helvetica (Regular, Bold, Oblique, BoldOblique), Times Roman ((Regular, Bold, Oblique, BoldOblique), Courier (Regular, Bold, Oblique, BoldOblique), Symbol, and ZapfDingbats, then no fonts have to be embedded into the resulting PDF document. You refer to those fonts by the names "Courier", "Helvetica", "Times", "Symbol", and "ZapfDingbats" in the wxPdfDocument API. It is not required to "register" those fonts; they are always "known" by wxPdfDocument.evstevemd wrote:Also I want to use System fonts so I don't want to include with my app extra fonts. Are those two things possible?
However, you have to face the fact that the core fonts support only a limited character set, corresponding more or less to Windows-1252 (Latin-1) or ISO-8859-1 codepages. You can find the list of available characters in Appendix D of the Adobe PDF reference.
Regards,
Ulrich
- evstevemd
- Part Of The Furniture
- Posts: 2409
- Joined: Wed Jan 28, 2009 11:57 am
- Location: United Republic of Tanzania
Re: wxPDFDoc without building a library
Thank you so much for your confirmation. I appreciate it!utelle wrote:Sure, you can do that of course. There are currently no external dependencies except wxWidgets.evstevemd wrote:I want to use wxPDFDoc with my app. I don't want to build it separately and I wonder if I can just include the files with my project and build them together.
I'm lost here, please excuse my ignorance.utelle wrote:Well, that depends on the requirements of your application. If you can restrict your application to just use the 14 PDF / PostScript core fonts Helvetica (Regular, Bold, Oblique, BoldOblique), Times Roman ((Regular, Bold, Oblique, BoldOblique), Courier (Regular, Bold, Oblique, BoldOblique), Symbol, and ZapfDingbats, then no fonts have to be embedded into the resulting PDF document. You refer to those fonts by the names "Courier", "Helvetica", "Times", "Symbol", and "ZapfDingbats" in the wxPdfDocument API. It is not required to "register" those fonts; they are always "known" by wxPdfDocument.evstevemd wrote:Also I want to use System fonts so I don't want to include with my app extra fonts. Are those two things possible?
However, you have to face the fact that the core fonts support only a limited character set, corresponding more or less to Windows-1252 (Latin-1) or ISO-8859-1 codepages. You can find the list of available characters in Appendix D of the Adobe PDF reference.
Regards,
Ulrich
Let say for example I use Liberation Sans (which comes with ubuntu and is availble for free), is there anything extra I need to do?
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Re: wxPDFDoc without building a library
Maybe I misinterpreted your question.evstevemd wrote:I'm lost here, please excuse my ignorance.utelle wrote:Well, that depends on the requirements of your application. If you can restrict your application to just use the 14 PDF / PostScript core fonts Helvetica (Regular, Bold, Oblique, BoldOblique), Times Roman ((Regular, Bold, Oblique, BoldOblique), Courier (Regular, Bold, Oblique, BoldOblique), Symbol, and ZapfDingbats, then no fonts have to be embedded into the resulting PDF document. You refer to those fonts by the names "Courier", "Helvetica", "Times", "Symbol", and "ZapfDingbats" in the wxPdfDocument API. It is not required to "register" those fonts; they are always "known" by wxPdfDocument.evstevemd wrote:Also I want to use System fonts so I don't want to include with my app extra fonts. Are those two things possible?
However, you have to face the fact that the core fonts support only a limited character set, corresponding more or less to Windows-1252 (Latin-1) or ISO-8859-1 codepages. You can find the list of available characters in Appendix D of the Adobe PDF reference.
Let say for example I use Liberation Sans (which comes with ubuntu and is availble for free), is there anything extra I need to do?
Usually, it is necessary to embed the font data of all used fonts in a PDF document, to make it displayable / readable anywhere. However, this is not the case for the 14 core fonts, which can be used without any special measures, since every PDF reader "knows" how to display those fonts. For example, on Windows platforms the font Arial is the equivalent of the core font Helvetica.
If you are going to use a font that is not one of the core fonts, wxPdfDocument needs access to the font data file. That is, you need to "register" the font in question with a method of the wxPdfDocument font manager (class wxPdfFontManager). This can be done in several ways:
- Call RegisterFont with the full path of the font data file
- Call RegisterFont with a wxFont instance of the font, if you used the very same font for on-screen display
- Call RegisterSystemFonts to register all fonts that are installed in the default font location of your system
- Call RegisterFontDirectory to register all font files located in a given directory
However, as far as I know, the Liberation fonts are open font replacements for the Microsoft fonts Times New Roman, Arial, and Courier New (which are in turn equivalent to the core fonts Times Roman, Helvetica, and Courier). That is, your application should be fine in just using the core fonts.
Regards,
Ulrich
- evstevemd
- Part Of The Furniture
- Posts: 2409
- Joined: Wed Jan 28, 2009 11:57 am
- Location: United Republic of Tanzania
Re: wxPDFDoc without building a library
That was comprehensive answer. I thank you. You have answered all I asked and more.
Thank you!
Thank you!
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
- evstevemd
- Part Of The Furniture
- Posts: 2409
- Joined: Wed Jan 28, 2009 11:57 am
- Location: United Republic of Tanzania
Re: wxPDFDoc without building a library
Hi Urlich,
I have one more question. Can I force the PDF to use only Single Font in rendering? For example I want everything to be rendered with Exo 2 font only without disturbing Sizes?
Thanks
I have one more question. Can I force the PDF to use only Single Font in rendering? For example I want everything to be rendered with Exo 2 font only without disturbing Sizes?
Thanks
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Re: wxPDFDoc without building a library
It's not fully clear what you intend to accomplish. wxPdfDocument requires the user / developer to select a font, before writing text to the PDF document. If you want to use only a single certain font, then restrict your application to select just that font.evstevemd wrote:Can I force the PDF to use only Single Font in rendering? For example I want everything to be rendered with Exo 2 font only without disturbing Sizes?
If you try to output something via wxPdfDC and your drawing method selects various wxFonts to generate the output, then the underlying wxPdfDocument instance will also use various fonts.
In short, it is the developer's responsibility to select the font(s).
If this does not answer your question, please be more specific about what problem you experience that you want to solve.
Regards,
Ulrich
- evstevemd
- Part Of The Furniture
- Posts: 2409
- Joined: Wed Jan 28, 2009 11:57 am
- Location: United Republic of Tanzania
Re: wxPDFDoc without building a library
I use wxPdfDC and I want to restrict fonts to single font. Here is my codeutelle wrote:It's not fully clear what you intend to accomplish. wxPdfDocument requires the user / developer to select a font, before writing text to the PDF document. If you want to use only a single certain font, then restrict your application to select just that font.evstevemd wrote:Can I force the PDF to use only Single Font in rendering? For example I want everything to be rendered with Exo 2 font only without disturbing Sizes?
If you try to output something via wxPdfDC and your drawing method selects various wxFonts to generate the output, then the underlying wxPdfDocument instance will also use various fonts.
In short, it is the developer's responsibility to select the font(s).
If this does not answer your question, please be more specific about what problem you experience that you want to solve.
Regards,
Ulrich
Code: Select all
void App::OnExportPDF(wxCommandEvent& event)
{
wxPageSetupDialogData dialogData = wxPageSetupDialogData();
//..
wxPdfPageSetupDialog* dialog = new wxPdfPageSetupDialog(wxTheApp->GetTopWindow(), &dialogData);
if(dialog->ShowModal() == wxID_OK)
{
dialogData = dialog->GetPageSetupData();
wxPdfPrintData printData = wxPdfPrintData(&dialogData);
wxPdfPrintDialog *printDialog = new wxPdfPrintDialog(wxTheApp->GetTopWindow(), &printData);
if(printDialog->ShowModal() == wxID_OK)
{
printData = printDialog->GetPdfPrintData();
//wxRichTextPrinting* m_printer;
m_printer->SetRichTextBufferPrinting(new wxRichTextBuffer());
wxRichTextPrintout *printPrintout = new wxRichTextPrintout(wxT("Export to PDF"));
// richtext printout accepts margins in tenths of mm
printPrintout->SetMargins(
10 * dialogData.GetMarginTopLeft().y,
10 * dialogData.GetMarginBottomRight().y,
10 * dialogData.GetMarginTopLeft().x,
10 * dialogData.GetMarginBottomRight().x
);
wxRichTextBuffer *printBuffer = GetNotepadBuffer();
printPrintout->SetRichTextBuffer(printBuffer);
wxPdfPrinter *printer = new wxPdfPrinter(&printData);
printer->Print(this, printPrintout, false);
//...
}
}
}
Thanks!
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Re: wxPDFDoc without building a library
It really depends on the content of the wxRichTextBuffer. If you used different fonts on creating the content using methods wxRichTextCtrl::SetDefaultStyle, wxRichTextCtrl::SetFont, wxRichTextCtrl::BeginFont, wxRichTextCtrl::SetStyle and the like, then the answer is unfortunately NO. wxPdfDC and hence wxPdfDocument will use the fonts that are associated with the content of the wxRichTextBuffer. In fact, this is not related to wxPdfDC at all - that's how wxRichTextPrintout handles writing to a DC.evstevemd wrote:I use wxPdfDC and I want to restrict fonts to single font. Here is my code
Now with this code is it possible to limit everything to single Font?Code: Select all
void App::OnExportPDF(wxCommandEvent& event) { wxPageSetupDialogData dialogData = wxPageSetupDialogData(); //.. wxPdfPageSetupDialog* dialog = new wxPdfPageSetupDialog(wxTheApp->GetTopWindow(), &dialogData); if(dialog->ShowModal() == wxID_OK) { dialogData = dialog->GetPageSetupData(); wxPdfPrintData printData = wxPdfPrintData(&dialogData); wxPdfPrintDialog *printDialog = new wxPdfPrintDialog(wxTheApp->GetTopWindow(), &printData); if(printDialog->ShowModal() == wxID_OK) { printData = printDialog->GetPdfPrintData(); //wxRichTextPrinting* m_printer; m_printer->SetRichTextBufferPrinting(new wxRichTextBuffer()); wxRichTextPrintout *printPrintout = new wxRichTextPrintout(wxT("Export to PDF")); // richtext printout accepts margins in tenths of mm printPrintout->SetMargins( 10 * dialogData.GetMarginTopLeft().y, 10 * dialogData.GetMarginBottomRight().y, 10 * dialogData.GetMarginTopLeft().x, 10 * dialogData.GetMarginBottomRight().x ); wxRichTextBuffer *printBuffer = GetNotepadBuffer(); printPrintout->SetRichTextBuffer(printBuffer); wxPdfPrinter *printer = new wxPdfPrinter(&printData); printer->Print(this, printPrintout, false); //... } } }
If you don't want different fonts in PDF output, you will have to regenerate the wxRichTextBuffer using just a single font.
Regards,
Ulrich
- evstevemd
- Part Of The Furniture
- Posts: 2409
- Joined: Wed Jan 28, 2009 11:57 am
- Location: United Republic of Tanzania
Re: wxPDFDoc without building a library
Ok great.
Thanks for clearing that out. I will find a solution on wxRTC before printing
Thanks for clearing that out. I will find a solution on wxRTC before printing
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?