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 - Bug with comments in pdfs
  FAQ FAQ  Forum Search   Register Register  Login Login

Bug with comments in pdfs

 Post Reply Post Reply
Author
Message Reverse Sort Order
ukobsa View Drop Down
Senior Member
Senior Member


Joined: 29 May 06
Location: Germany
Status: Offline
Points: 115
Post Options Post Options   Thanks (0) Thanks(0)   Quote ukobsa Quote  Post ReplyReply Direct Link To This Post Topic: Bug with comments in pdfs
    Posted: 07 Apr 09 at 4:18AM
Hi,

if there are comments in a pdf then reading data can go wrong:

TPDFStructure.SmartDecode checks for whitespace and comments but it ignores that after a comment there may be additional whitespace:


trailer
<< /ID
% ReportLab generated PDF document -- digest (http://www.reportlab.com)
[(4\264\331\222\333\020\213K\351^\240\316\000\203\255\301) (4\264\331\222\333\020\213K\351^\240\316\000\203\255\301)]

/Info 7 0 R
/Root 6 0 R
/Size 18 >>


in this sample the trailer is not read correct as after the first comment and start of ID data there is additional whitespace

Fix:

procedure SkipWhitespace;
begin
    // Read all whitespace
    while (X < L) and IsWhitespace(Source[X]) do Inc(X);

    // is next char the start sign for a comment, then ignore entire line
    if (X < L) and (Source[X] = '%') then
    begin
      while (X < L) and (Source[X] <> #10) and (Source[X] <> #13) do Inc(X);
      if (Source[X] = #13) and (Source[X + 1] = #10) then
        Inc(X, 2)
      else
        Inc(X);

      // UKO 2009-04-07 after a comment recheck for white space!
      SkipWhitespace;
    end;
end;


same should be done on TPDFType1Decoder.Tokenize: also adjust the SkipWhiteSpace procedure


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