Print Page | Close Window

Problem with Tiff compression

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=3866
Printed Date: 23 Apr 24 at 8:09AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Problem with Tiff compression
Posted By: haka
Subject: Problem with Tiff compression
Date Posted: 02 Dec 20 at 8:25AM
Hello. I have been using the following code for a long time and now I have a problem with version 18.11.
The file size is 1 MB, if text is added. Without text the compression works and the file is about 13 KB small.
procedure pdfTest(AWriteText: boolean);
var LOcrText: string;
    LPDF    : TDebenuPDFLibrary;
begin
  LPDF := TDebenuPDFLibrary.Create;
  LPDF.UnlockKey('your key');
  try
    LPDF.SetPDFAMode(2);
    LPDF.SetMeasurementUnits(1);
    LPDF.SetPageSize('A4');
    LPDF.CompressImages(1);
    LPDF.AddImageFromFile('g:\temp\test.tif', 1); // use Windows Paint, draw a line for example and save as Tiff
    LPDF.FitImage(0, LPDF.PageHeight, LPDF.PageWidth, LPDF.PageHeight, 1, 1, 0);  //or  LPDF.DrawScaledImage((...

    { if AWriteText is true or just one of the three lines is executed, the file size is > 1000 kB }
    { if AWriteText is false the file size is only ~ 13 kB  }
    if AWriteText then begin
      LOcrText := 'this is only a test test';
      LPDF.SetTextMode(3); // Invisible text
      LPDF.SetTextSize(6);
      LPDF.DrawTextBox(5, LPDF.PageHeight-5, LPDF.PageWidth-10, LPDF.PageHeight-10, LOcrText, 1);
    end;

    LPDF.SaveToFile('g:\temp\test.pdf');
  finally
    LPDF.Free;
  end;
end;


Greetings and thanks for suggestions,
Harald



Replies:
Posted By: Sopracenery
Date Posted: 27 Dec 20 at 8:49AM
Hi,
I can confirm this issue.

It has probably to do with the PDF-A mode.
You can bypass this by switching on PDF-A mode after TIF and text is drawn:

LPDF.FitImage(0, LPDF.PageHeight, LPDF.PageWidth, LPDF.PageHeight, 1, 1, 0);  //or  LPDF.DrawScaledImage((...
LPDF.DrawTextBox(5, LPDF.PageHeight-5, LPDF.PageWidth-10, LPDF.PageHeight-10, LOcrText, 1);
LPDF.SetPDFAMode(2);

Regards
Martin


Posted By: haka
Date Posted: 27 Dec 20 at 4:21PM
Good tip, it solves the poblem.
Thank you.



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