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 - DrawHTMLTextBox Returns Strange Characters
  FAQ FAQ  Forum Search   Register Register  Login Login

DrawHTMLTextBox Returns Strange Characters

 Post Reply Post Reply
Author
Message
Lord Jim View Drop Down
Beginner
Beginner
Avatar

Joined: 07 Sep 11
Location: USA
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote Lord Jim Quote  Post ReplyReply Direct Link To This Post Topic: DrawHTMLTextBox Returns Strange Characters
    Posted: 07 Sep 11 at 2:06PM
Hello everyone,

I'm trying to use DrawHTMLTextBox to place HTML text on a page. The text may be several pages in length. My understanding is that each call to this function would return the balance of text to be displayed, which could then be passed to the function in successive calls until the entire string has been rendered. However, when I call DrawHTMLTextBox, the first page is correctly rendered, however the return string is something like the following snippet:

???????????       ? ??????       ? ??              ?        ????????????????? ???? ?? ??? ???? ?? ???????????????? ?? ????? ??????? ? ?? ?? ???????? ???? ?????????????? ??? ?????? ???????? ???????? ?? ???? ?????? ???????? ??? ????? ????????????? ?????????? ????????? ??? ?? ?????? ???????? ?? ?????? ?????? ??? ??? ????? ??????? ?????? ???????? ??????????? ??? ??? ????????? 

The data returned always appears to be about the correct length, but as you can see isn't too useful. Can you tell me what I'm doing wrong? Any help would be greatly appreciated.

This project is in VB6 using the latest release of Quick PDF 8.11, ActiveX version.

Best regards,

Jim K.
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: 07 Sep 11 at 4:39PM
I have just confirmed that this is a new 8.11 bug introduced with the introduction of 8.11.

We will fix this for the 8.12 release.

Basically the every 2nd byte in the string needs to be swapped to obtain the correct string.

ABCDEFGH   needs to be converted to 
BADCFEHG   before the string can be used.  

Here is the Delphi fix - Looks like it only needs to be used on the return string from DrawHTMLBox.
WS := QP.DrawHTMLTextBox(100, 500, 50, 50, 'This is a very long paragraph that should not fix into a 50x50 unit');
    for X := 1 to Length(WS) do
    begin
      WS[X] := WideChar(((Ord(WS[X]) and $FF) shl 8) + ((Ord(WS[X]) and $FF00) shr 8));
    end;
    Memo1.Lines.Add(WS);
Update : The developer has just fixed the problem.  This problem was only with this function and not the library in general.
One option is to go back to 7.26 for the time being.  I may be able to send you an updated ActiveX DLL if that is too difficult.
Andrew.
Back to Top
Lord Jim View Drop Down
Beginner
Beginner
Avatar

Joined: 07 Sep 11
Location: USA
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote Lord Jim Quote  Post ReplyReply Direct Link To This Post Posted: 07 Sep 11 at 5:11PM
Dear Andrew:

Yes, an updated ActiveX DLL would be great, as regressing to the previous version would be difficult at this point. I'd be happy to report any issues that arise with the update.

Best regards,

Jim K.
Back to Top
Lord Jim View Drop Down
Beginner
Beginner
Avatar

Joined: 07 Sep 11
Location: USA
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote Lord Jim Quote  Post ReplyReply Direct Link To This Post Posted: 08 Sep 11 at 1:45PM
Dear Andrew:

When I swap the high and low bytes in the return string, I get the following:

<stack><!--0000000103AD8DB000000010##000000        N00000000LN--></stack>been made in the area of customizability: in  fact, Version 5 is so

It looks like some kind of stack trace which is prefixed to the remaining text.

Jim K.
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 Sep 11 at 2:39PM
That text looks correct.  QPL adds <stack> to the string to keep track of the current HTML state.  You should be  able to pass this string into another DrawHTMLTextBox call for the second page.

We should be releasing the 8.12 beta sometime next week with the fix.
Back to Top
Lord Jim View Drop Down
Beginner
Beginner
Avatar

Joined: 07 Sep 11
Location: USA
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote Lord Jim Quote  Post ReplyReply Direct Link To This Post Posted: 08 Sep 11 at 5:24PM
Dear Andrew:

The document I've been trying to render is about two and a half pages long. Swapping the byte-pairs  allows the first to pages to be generated correctly, but when passing the returned text for the third page, I get this error: "Method 'DrawHTMLTextBox' of object 'IPDFLibrary' failed". I managed to get it to work by stripping the <stack> frame before I passed the returned string for the next call. I think these workarounds are sufficient for my purposes. I'll download the 8.12 beta when you release it, and go from there.

Thanks for all your help,

Jim K.
Back to Top
Lord Jim View Drop Down
Beginner
Beginner
Avatar

Joined: 07 Sep 11
Location: USA
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote Lord Jim Quote  Post ReplyReply Direct Link To This Post Posted: 09 Sep 11 at 4:10PM
Here is another possible issue with DrawHTMLTextBox:

When using an HTML unordered list (i.e. <ul>) I get a double-quote prefixing each line of the list. For example, the following code:

<ul>
  <li><i>The menu bar and method of opening the page at the top</i></li>
  <li><i>A sample display of the page</i></li>
  <li><i>A description of the display and its purpose</i></li>
  <li><i>Any configurable items on that page</i></li>
  <li><i>The security level normally required for changing that item</i></li>
</ul>

gives me this:

" The menu bar and method of opening the page at the top
" A sample display of the page
" A description of the display and its purpose
" Any configurable items on that page
" The security level normally required for changing that item

So far I've only tested it in Foxit Reader.

Jim K.
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: 12 Sep 11 at 9:21AM
Can you post a copy of that small section of code so that I can reproduce the problem exactly.
Back to Top
Lord Jim View Drop Down
Beginner
Beginner
Avatar

Joined: 07 Sep 11
Location: USA
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote Lord Jim Quote  Post ReplyReply Direct Link To This Post Posted: 12 Sep 11 at 3:10PM
Dear Andrew:

I zipped up my test program along with some sample files. You can retrieve the archive from the URL below:

ftp://updates:lj@lordjim.dyndns.org/QuickPDFTest.zip

The included "test.pdf" file demonstrates a couple of issues. The first is the aforementioned HTML list problem of preceeding quote characters. You'll see that in the middle of the first page, where you will see the italicized list.

The other issue is what happens when a paragraph is split across a page break. In particular, examine the text at the top of pages 3 and 4: notice that the last seven or eight words from the last line are repeated at the very end.

It's not shown here, but I also noted that format settings made on one page do not carry over into the next page. Font size, for example, will be reset to a default value after a page break.

In the sample code provided, make sure that you set the IDEPath constant at the top to the location of the unzipped files. Also, at the bottom of the Form_Load event, the routine attempts to shell out to Foxit Reader, which you may not want.

Best regards,

Jim K.
Back to Top
Lord Jim View Drop Down
Beginner
Beginner
Avatar

Joined: 07 Sep 11
Location: USA
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote Lord Jim Quote  Post ReplyReply Direct Link To This Post Posted: 12 Sep 11 at 3:13PM
Dear Andrew:

As this is a public forum, I removed my developer key from the sample source.

Best regards,

Jim K.
Back to Top
Lord Jim View Drop Down
Beginner
Beginner
Avatar

Joined: 07 Sep 11
Location: USA
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote Lord Jim Quote  Post ReplyReply Direct Link To This Post Posted: 12 Sep 11 at 3:18PM
Dear Andrew:

One more thing: if you look in the sample program you'll see a routine called "ByteSwap". In addition to reversing the byte pairs in the DrawHTMLTextBox return string, it also prepends an "N" character to the first hex block in the <stack></stack> frame. I noticed that sometimes multiple hex blocks will appear in the frame, and that all would have an "N" as the first character, except the very first one. If I don't add that character, only the first call will work: subsequent calls will fail with an RTE.

Best regards,

Jim K.
Back to Top
Lord Jim View Drop Down
Beginner
Beginner
Avatar

Joined: 07 Sep 11
Location: USA
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote Lord Jim Quote  Post ReplyReply Direct Link To This Post Posted: 18 Oct 11 at 2:17PM
Reference my previous issues, the revision 8.12 beta is working very well for me now. The only issue I have is that when attempting to use DrawHTMLTextBox as across multiple pages I still need to modify the return string, or DrawHTMLTextBox will crash. Currently I'm wrapping DrawHTMLTextBox with the following VB function, and I don't appear to have any problems.

'=========================================================================================================
' This function is a workaround to accommodate some issues in QuickPDF 8.12 beta's DrawHTMLTextBox function:
'
' 1. Rip out the characters in the <stack> frame between 52 and 85, but only if the length of the frame
'    is greater than 66 characters. If this not done, DrawHTMLTextBox fails.
'=========================================================================================================

Private Function ByteSwap(strVal As String) As String

    Dim intPos As Integer

    intPos = InStr(strVal, "</stack>")

    If intPos > 66 Then
        strVal = Mid$(strVal, 1, 51) & Mid$(strVal, 93, Len(strVal))
    End If
    
    ByteSwap = strVal

End Function

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: 19 Oct 11 at 7:51AM
I have found the problem with the DrawHTMLTextBox function and you no longer need to fix the <stack> string manually.

Thanks for the feedback and help on this issue.  This bug fix will be included in the upcoming 8.12 Final that is due out today or tomorrow.
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