Print Page | Close Window

Bug fix - If you have 18.11 source code.

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=4048
Printed Date: 25 Apr 25 at 12:32PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Bug fix - If you have 18.11 source code.
Posted By: swb1
Subject: Bug fix - If you have 18.11 source code.
Date Posted: 16 Apr 25 at 10:43PM
unit DebenuPDFLibraryFontRasterizer has a bug that can cause an infinite loop when rendering some PDFs
I DO NOT KNOW IF THIS IS THE EXTACT RIGHT THING TO DO!!! However, it fixed a problem I was having with a very small number of documents, and I know it does nothing that would break the vast majority that were already working. 

I have solved it in my library by adding an else/break condition in the function GetW2DictCount:

  function GetW2DictCount: Integer;
  begin
    Result := 0;
    Obj := Font.FindValueByKeyName('W2', True);
    if (Obj is TPDFArray) and (TPDFArray(Obj).Count > 1) then
    begin
      WArray := TPDFArray(Obj);
      WX := 0;
      while WX < (WArray.Count - 1) do
      begin
        if WArray.Item[WX] is TPDFNumeric then
        begin
          if WArray.Item[WX + 1] is TPDFNumeric then
          begin
            WX := WX + 5;
            Inc(Result);
          end
          else if WArray.Item[WX + 1] is TPDFArray then
          begin
            Inc(Result, TPDFArray(WArray.Item[WX + 1]).Count);
            Inc(WX, 2);
          end
          // -------------------
          // swb 4-16-2025 if WX is never inc'd it will loop infinitely.
          else
          begin
            break;
          end;
          // -------------------
        end
        else if WArray.Item[WX + 1] is TPDFArray then
        begin
          Inc(Result, TPDFArray(WArray.Item[WX + 1]).Count div 3);
          Inc(WX, 2);
        end;
      end;
    end;
  end;



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk