Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - HTML Drawing - more quirks
  FAQ FAQ  Forum Search   Register Register  Login Login

HTML Drawing - more quirks

 Post Reply Post Reply
Author
Message
HNRSoftware View Drop Down
Senior Member
Senior Member


Joined: 13 Feb 11
Location: Washington, USA
Status: Offline
Points: 88
Post Options Post Options   Thanks (0) Thanks(0)   Quote HNRSoftware Quote  Post ReplyReply Direct Link To This Post Topic: HTML Drawing - more quirks
    Posted: 02 Dec 11 at 3:42PM
One would expect the following to produce sensible output (single spaces between the formatted words Quick/Brown/Fox) 
 
        s := 'The <b>Quick</b> <i>Brown</i> <u>Fox</u> is';
        QP.DrawHTMLText(1.00,2.00,6.00,s);
 
but it takes the following to do it:
 
        s := 'The <b>Quick </b> <i>Brown </i> <u>Fox</u> is';
        QP.DrawHTMLText(1.00,2.35,6.00,s);

 
Internet Explorer handles the original string correctly.
 
It would appear that a space is being treated as insignificant between two html tags.
 
 
Back to Top
HNRSoftware View Drop Down
Senior Member
Senior Member


Joined: 13 Feb 11
Location: Washington, USA
Status: Offline
Points: 88
Post Options Post Options   Thanks (0) Thanks(0)   Quote HNRSoftware Quote  Post ReplyReply Direct Link To This Post Posted: 06 Dec 11 at 1:05AM
HTML drawing is very powerful and works pretty well, but one thing has me baffled.  I have figured out how (and more or less why) to use SetHTMLNormalFont and the others.  The normal DrawText font has enough additional calls to control just about everything font-related - Fine.
 
What I can't figure out is how to set the HTML font to some specific size for the default height - size 1 or size 4  or whatever one could be considered the default.  It seems like it would be quite reasonable and/or straight-forward to do this, but there may be internal resons why this is not an easy thing to do.
 
A key reason why this would be useful is that effectively, each call to DrawHTMLText or the measure Height and Width calls all start from whatever that essential "default size" is, rather than what the current, or most recently used size is.  I can understand the code logic for this, but it means that I have to essentially preface every string to be output with a "<font ...>" tag to continue on with whatever I consider my "current" size whenever I want to measure or draw a string. 
 
This is not amazingly difficult to do, but it seems a bit cumbersome.  The reasoning may be that we are essentially dealing with 4 fonts sepaarately and it would just take tooo many calls to control all these things.
 
I just thought I would toss this into the ring.  Otherwise, I'm having great fun and making lots of progress with writing flexible table-equivalent output.
Back to Top
AndrewC View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 08 Dec 10
Location: Geelong, Aust
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndrewC Quote  Post ReplyReply Direct Link To This Post Posted: 06 Dec 11 at 5:31AM
Thanks for the feedback and reports.  I will look into the HTML when I get some free time.  There is also a small issue with &nbsp;  that I am working on.  

It is fairly complex code that I didn't write but I will see what I can do.

Andrew
Back to Top
HNRSoftware View Drop Down
Senior Member
Senior Member


Joined: 13 Feb 11
Location: Washington, USA
Status: Offline
Points: 88
Post Options Post Options   Thanks (0) Thanks(0)   Quote HNRSoftware Quote  Post ReplyReply Direct Link To This Post Posted: 06 Dec 11 at 1:35PM
Hi Andrew - Thanks for looking into it.  I have probably put in 25 hours or so exploring the HTML aspects of QPDF and I am not finding any serious defects - at most I call them quirks.  A "quirk" has a straight-forward work-around.
 
The one about the "<stack... " return from DrawHTMLTextBox is probably an actual "bug", but I am not sure this return would be practical to use even if it worked correctly, so ignoring it makes no difference to the work I'm doing.
 
The exact subset of HTML tags that QPDF implements is a very useful one wehn viewed as a way to format a short string (like a table cell).  The only small extensions I would suggest (small syntax impact, not necessarily small code impact) would be:
 
1. "<font size="+1"> - type relative size changes.  I'll bet this one would be easy.  I will probably work-around with a little string manipulation.
 
2. The documentation should mention that "</font>" is implemented and cancels the changes you previously made, but that a second "<font" tag specifying some other aspect leaves in the previous changes in place.
 
3. I love writing "complaints".  In trying to document the "bugs" I learn new things. I was going to complain about the need for "<p align="Right">" and I discovered that it is actually there, just not in the documentation - just like "</font>"
 
These are actually the kind of complaints a coder likes to see - where the code is already there, but a few lines need to be added to the documentation.  So, the net content of this post is a mild request for relative font size specification.
 
Thanks for a great product - Howard  
Back to Top
AndrewC View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 08 Dec 10
Location: Geelong, Aust
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndrewC Quote  Post ReplyReply Direct Link To This Post Posted: 08 Dec 11 at 12:56AM
Thanks for the valuable feedback.

The <stack> object is used to save the current drawing settings when jumping to a new page and is only used internally.  I don't fully understand myself how well it works or doesn't work as I didn't write the code.

I will pass your comments on to our documentation expert.

It seems the nbsp; function is working fine.  The issue was with QP.AddTrueTypeFont("Arial {1251})", 1);

As of 8.13 adding a TrueType font with a code page adds all the characters from this code page but converts these characters to their Unicode versions.  So when you call DrawText you need to use a Unicode string and not a 1251 encoded string.
Back to Top
HNRSoftware View Drop Down
Senior Member
Senior Member


Joined: 13 Feb 11
Location: Washington, USA
Status: Offline
Points: 88
Post Options Post Options   Thanks (0) Thanks(0)   Quote HNRSoftware Quote  Post ReplyReply Direct Link To This Post Posted: 24 Dec 11 at 10:51AM
This is WAY down on the quirk importance list.  I figured out the logic of needing four separate calls to AddStandardFont and SetHTMLxxxFont to set up a specific typeface for HTML work - Courier/Helvetica/TimesRoman.  There is a minor oddity in the standard font list variation order for italic and bold/italic for TimesRoman.  I was taking a shortcut of using  StandardFontIDs of 0, 4 and 8, and then adding 1 for bold, adding 2 for bolditalic and adding 3 for italic, but the last 2 are reversed for TimesRoman.  Once I got rid of the shortcut, I was able to set HTML font faces correctly.
 
 
Back to Top
HNRSoftware View Drop Down
Senior Member
Senior Member


Joined: 13 Feb 11
Location: Washington, USA
Status: Offline
Points: 88
Post Options Post Options   Thanks (0) Thanks(0)   Quote HNRSoftware Quote  Post ReplyReply Direct Link To This Post Posted: 24 Dec 11 at 11:56AM
Ok...  I figured out something about font faces and DrawHTMLtext.  I went over to /Windows/Fonts (in Windows 7 - Windows Explorer) and noticed that some of the fonts had stacked "file" icons to represent multiple files involved in the specific font face.  Selecting one and "copy" and then "paste"ing it into my project folder got me a group of ttf files that pretty clearly related to regular, bold, italic and bolditalic.
 
This code fragment set the four HTML modes correctly:
 
     fn := 'arial.ttf';        fontid := QP.AddTrueTypeFontFromFile(fn);
     if fontid > 0 then QP.SetHTMLNormalFont('Default',fontid);
     fn := 'ariali.ttf';       fontid := QP.AddTrueTypeFontFromFile(fn);
     if fontid > 0 then QP.SetHTMLItalicFont('Default',fontid);
     fn := 'arialbd.ttf';    fontid := QP.AddTrueTypeFontFromFile(fn);
     if fontid > 0 then QP.SetHTMLBoldFont('Default',fontid);
     fn := 'arialbi.ttf';     fontid := QP.AddTrueTypeFontFromFile(fn);
     if fontid > 0 then QP.SetHTMLBoldItalicFont('Default',fontid);
 
In the process, I discovered that a trivial "Quick Brown Fox" DrawHTMLText pdf page went from 12kbytes to 2.6Mbytes - then looking at the 4 ttf files, I can see that these total up about the same.
 
So, my conclusion is that it is reasonable to add in font files if needed, but that it is pretty expensive in file size to do so.
 
Back to Top
HNRSoftware View Drop Down
Senior Member
Senior Member


Joined: 13 Feb 11
Location: Washington, USA
Status: Offline
Points: 88
Post Options Post Options   Thanks (0) Thanks(0)   Quote HNRSoftware Quote  Post ReplyReply Direct Link To This Post Posted: 24 Dec 11 at 12:00PM
By the way - the previous code is just to see what actually compiles and executes.  I doubt that I have any legal right to copy the ttf files and include them in a pdf.  I don't think I would get in serious trouble, but browsing the internet shows a lot of people selling and giving away font files, so there are dollars involved.  I think I will stick with the "standard" fonts and not have to worry about it.  :=}
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store