Author Topic: Export as HTML, RTF, ...  (Read 29215 times)

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Export as HTML, RTF, ...
« Reply #30 on: October 27, 2005, 06:08:02 pm »
Regards,

Ulrich
(Developer of wxPdfDocument)

Wow! :shock: It is an honor having you here! :) Welcome!

Offline utelle

  • Single posting newcomer
  • *
  • Posts: 9
Re: Export as HTML, RTF, ...
« Reply #31 on: October 27, 2005, 06:55:21 pm »
I would be very very careful about embedding fonts or font-related information in a PDF.

It is common practice to embed fonts in PDF files. There is nothing special about that. Almost all tools for creating PDF files allow this. For example Adobe Acrobat, or the commercial libraries PDFLib and CPDFLib, or open source libraries like libharu, or FPDF to name just a few. Neither Adobe nor PDFLib GmbH nor FastIO nor any developer can control the user. They can't stop him to embed fonts he doesn't own or which are not freely available. Nevertheless these products/libraries are sold resp. distributed.

Quote from: thomas
Certain companies can be get very nasty if you do that. Remember some companies even regard adjusting character stem widths or the mere drawing of cubic bezier curves as a violation of intellectual property.

Certainly a user has to respect the font licences. wxPdfDocument will not provide any font metric files, instead there will be a tool to create special wxPdfDocument font metric files (containing only the information needed to properly use a font with wxPdfDocument). To create these files the user has to provide an AFM or UFM file for the font he wants to embed. It is assumed that the user owns the right to use the fonts, as each of the companies named above assumes, too. For TrueType fonts the tool checks the font file whether the licence allows to embed the font file and respects this information.

Regards,

Ulrich

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1442
    • CenizaSOFT
Re: Export as HTML, RTF, ...
« Reply #32 on: October 29, 2005, 05:55:03 pm »
Regards,

Ulrich
(Developer of wxPdfDocument)

Wow! :shock: It is an honor having you here! :) Welcome!

Ditto.

The question is: there will be a way to embed the fonts just by calling a class method and providing the font face name without calling external utilities?

Oh, could I also suggest wxPdfDocument's makefile allow static compilation using dynamic wxWidgets? I've got a working one already and seems to be working just fine.

Offline utelle

  • Single posting newcomer
  • *
  • Posts: 9
Re: Export as HTML, RTF, ...
« Reply #33 on: October 29, 2005, 08:32:13 pm »
Wow! :shock: It is an honor having you here! :) Welcome!
Ditto.

Thanks. :D

Quote from: Ceniza
The question is: there will be a way to embed the fonts just by calling a class method and providing the font face name without calling external utilities?

To use a non-standard font (i.e. oher than Courier, Times, Helvetica=Arial, Symbol, ZapfDingBats) wxPdfDocument needs some information about these fonts - for example the width of each character provided by the font, the underline position etc. In the next release of wxPdfDocument there will be a small utility (MakeFont) which allows to create a wxPdfDocument specific font metric file and to prepare the font for embedding. An application using wxPdfDocument needs only these generated files at runtime. To make such a font known to wxPdfDocument, the application has to call the method AddFont (see the font embedding example of the wxPdfDocument distribution).

Although it would be possible to extract the needed font information on the fly I do not plan to implement such a feature. The reasons are efficiency (it makes no sense to extract the font information again and again each time the application runs) and legal issues (it may not be allowed to embed a specific font).

Quote from: Ceniza
Oh, could I also suggest wxPdfDocument's makefile allow static compilation using dynamic wxWidgets? I've got a working one already and seems to be working just fine.

Do you mean to compile wxPdfDocument as a static library while using wxWidgets as a shared/dynamic library?

I use bakefile (also used by wxWidgets) to generate the makefiles for wxPdfDocument. As far as I know bakefile currently supports only the combinations "static library + static wxWidgets library" and "dynamic library + dynamic wxWidgets library", but I'll investigate this issue.

Of course you always could simply add the wxPdfDocument source files to your own project.

Regards,

Ulrich

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1442
    • CenizaSOFT
Re: Export as HTML, RTF, ...
« Reply #34 on: November 04, 2005, 08:29:30 pm »
Quote from: utelle
Do you mean to compile wxPdfDocument as a static library while using wxWidgets as a shared/dynamic library?

Yep, that's what I mean.

Quote from: utelle
Of course you always could simply add the wxPdfDocument source files to your own project.

That's what I did :P

I've been working on the PDF exporter and it's... exporting, but I've been unable to allow text background to be drawn correctly, if any.

Code: [Select]
pdf.Cell(pdf.GetStringWidth(text), 4, text);//, wxPDF_BORDER_NONE, 0, wxPDF_ALIGN_LEFT, 1);
That's my current text drawing call (ugly hack to get it working). If I enable the commented piece, some of the previous text will be also painted white (or should I say erased?).

Any idea?

Offline utelle

  • Single posting newcomer
  • *
  • Posts: 9
Re: Export as HTML, RTF, ...
« Reply #35 on: November 04, 2005, 11:44:47 pm »
Quote from: utelle
Do you mean to compile wxPdfDocument as a static library while using wxWidgets as a shared/dynamic library?
Yep, that's what I mean.

Currently no news on this topic. I drop a note here if I find a way to accomplish this.

Quote from: Ceniza
I've been working on the PDF exporter and it's... exporting, but I've been unable to allow text background to be drawn correctly, if any.

Could you please explain, what you are trying to accomplish? The method Cell allows to draw a text background color, as shown for example in sample tutorial3.cpp. If a specific area of the page should have a background color you could also use the method Rect to draw a colored rectangle. If you do this before writing the text the text will be visible.

Quote from: Ceniza
Code: [Select]
pdf.Cell(pdf.GetStringWidth(text), 4, text);//, wxPDF_BORDER_NONE, 0, wxPDF_ALIGN_LEFT, 1);
That's my current text drawing call (ugly hack to get it working). If I enable the commented piece, some of the previous text will be also painted white (or should I say erased?).

Any idea?

Unfortunately no. As stated above enabling the Cell options should work as it does in the samples. But maybe there is a bug in wxPdfDocument. Could you quote - here or in a private message - the code which produces the unwanted result and the resulting PDF file? (To allow me easier inspection of the generated PDF file please use SetCompression(false) after instantiating wxPdfDocument.)

Regards,

Ulrich

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1442
    • CenizaSOFT
Re: Export as HTML, RTF, ...
« Reply #36 on: November 05, 2005, 12:45:30 am »
Quote from: utelle
Could you please explain, what you are trying to accomplish?

In the editor, you can choose a background color for something, lets say... strings: blue text on black (I know they don't mix, but it's just an example).

This is the result



I just tried without compression and it seems the problem is here:

109.95 280.63 67.20 -11.34 re f q 0.000 0.000 1.000 rg BT 112.79 272.56 Td ("Calligrapher") Tj ET Q

I just played with those values and they seem to be causing the white border around that's deleting some of the previous written text.

Here's the PDF file.

I just enabled the commented bit of code to create it.

In a few words: I set a font, style and color. Write some text using that function. Change style and color. Write some more text, and so on.

I hope it be of any use so you can track down the problem.

Thanks in advance.

Offline utelle

  • Single posting newcomer
  • *
  • Posts: 9
Re: Export as HTML, RTF, ...
« Reply #37 on: November 05, 2005, 03:42:30 pm »
In the editor, you can choose a background color for something, lets say... strings: blue text on black (I know they don't mix, but it's just an example).
[...]
I just played with those values and they seem to be causing the white border around that's deleting some of the previous written text.

In a few words: I set a font, style and color. Write some text using that function. Change style and color. Write some more text, and so on.

I hope it be of any use so you can track down the problem.

Well, it's not exactly a bug, you may call it a feature.  :wink:

The Cell method assumes an internal cell margin to the left and to the right of the text. This cell margin is set to 1 millimeter in the wxPdfDocument constructor and - unfortunately - there is no method to manipulate this margin at the moment. I will add one in the next release. The cell margin is subtracted two times from the cell width and then the text is aligned in the remaining space as requested. Usually this is ok and gives pleasant results. In your case the cell width is equal to the text width. Nevertheless, the Cell method adds the cell margin as an offset on the left side of the cell. This causes the text to extend beyond the right side by the same amount and so 1 mm of the previous text is overwritten by the next call to Cell.

As an interim solution you could add 2 mm to the cell width parameter of the Cell method.

Regards,

Ulrich

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1442
    • CenizaSOFT
Re: Export as HTML, RTF, ...
« Reply #38 on: November 07, 2005, 06:10:20 am »
Well, in the meanwhile I'll keep the cell filling disabled...

I committed the PDF exporter a few hours ago, even though I had some problems adding the folder with wxPdfDocument sources.

After a bunch of cvs add and a final cvs ci I got them there. There must be an easier way to do that, mabye using cvs import but..., once again, the files are already there.

utelle: I'll be waiting for the next release then :)

Offline kisoft

  • Almost regular
  • **
  • Posts: 194
Re: Export as HTML, RTF, ...
« Reply #39 on: November 08, 2005, 01:22:57 pm »
...
I committed the PDF exporter a few hours ago, even though I had some problems adding the folder with wxPdfDocument sources.
...

I compile CVS C::B today. Export a source file to PDF, and look strange (I mean), see screenshot.
On figure 1 see, then a bottom lines lies closed to bottom edge of list. Hmm..
On figure 2 see, then text (wide line) goes out of list (may be my problem, don't try another variants).

In other hands allright! Thanks!  :lol:


[attachment deleted by admin]
OS: WinXPSP3
wxWidgets: 2.8.12
CodeBlocks: Master github cbMakefileGen plugin:
https://github.com/kisoft/cbmakefilegen

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1442
    • CenizaSOFT
Re: Export as HTML, RTF, ...
« Reply #40 on: November 08, 2005, 05:23:21 pm »
I noticed the problem in 2 but couldn't find a good way to solve it. The method Write is the one that should be used there, but it's adding a lot of spacing between text and wouldn't allow me to add a background (I'd say the spacing is a bug in Write). Cell isn't breaking line when it reaches the right margin, but it allows me to put a background (which currently I disabled due to the white border that erases the previous text).

Trying to solve that problem I called another function, but it didn't solve it (it was for something else) and caused what you see in 1.

I just removed that function call and 1 is gone.

2 will have to wait for a fixed Write, a fixed and smarter Cell, a fixed Write with a background option or a new function doing that.

I'll just commit that change and with my head in my hands I'll sit and cry.

Forget the last bit :P

Offline kisoft

  • Almost regular
  • **
  • Posts: 194
Re: Export as HTML, RTF, ...
« Reply #41 on: November 09, 2005, 08:27:55 am »
...
I just removed that function call and 1 is gone.
...

I see (compile now CVS). Look better! Thanks!  8)

So, in save dialog, FileName field - empty string.
Why not set it an exported fileName (w/o extention, or with extention, need see)?
I try export some times, and it already anoyed me  :(
OS: WinXPSP3
wxWidgets: 2.8.12
CodeBlocks: Master github cbMakefileGen plugin:
https://github.com/kisoft/cbmakefilegen

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1442
    • CenizaSOFT
Re: Export as HTML, RTF, ...
« Reply #42 on: November 09, 2005, 02:00:57 pm »
Quote from: kisoft
So, in save dialog, FileName field - empty string.
Why not set it an exported fileName (w/o extention, or with extention, need see)?

I always considered that bit, but never implemented it. I'll try to get it soon... maybe today :)

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1442
    • CenizaSOFT
Re: Export as HTML, RTF, ...
« Reply #43 on: November 09, 2005, 02:42:57 pm »
Ok, I just committed the changes to CVS. It should be visible for anonymous CVS in a few hours.

Offline kisoft

  • Almost regular
  • **
  • Posts: 194
Re: Export as HTML, RTF, ...
« Reply #44 on: November 09, 2005, 03:03:55 pm »
Ok, I just committed the changes to CVS. It should be visible for anonymous CVS in a few hours.

So, I can sleep while  :D
OS: WinXPSP3
wxWidgets: 2.8.12
CodeBlocks: Master github cbMakefileGen plugin:
https://github.com/kisoft/cbmakefilegen