Print Page | Close Window

Incorrect PDF when JPEG has color space

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=2462
Printed Date: 29 Apr 25 at 9:18AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Incorrect PDF when JPEG has color space
Posted By: Darlock
Subject: Incorrect PDF when JPEG has color space
Date Posted: 27 Nov 12 at 3:58PM
Hi!
  I have a JPEG image with embeded color space (color profile). When I add the image to the PDF document via Adobe Acrobat - the PDF looks OK. When I add the image using QuickPDF library (see code below) and open the resulting file via Adobe Acrobat afterwards - the image's colors have changed as if there was no color profile.

procedure TForm1.btn1Click(Sender: TObject);
var
...
const
...
begin
  FPictureStream.Clear;
  FPictureStream.LoadFromFile(vFileName);

  FPDFLib.NewPage;
  FPDFLib.DeletePages(1, 1);

  // Page Properties
  FPDFLib.SetOrigin(1);
  FPDFLib.SetMeasurementUnits(1);
  FPDFLib.SetPageDimensions(210, 270);

  // Add image
  vGrProperties.x := 10;
  vGrProperties.y := 10;
  vGrProperties.w := 60;
  vGrProperties.h := 80;

  vRes := FPDFLib.AddImageFromStream(FPictureStream, 0);
  vIXR := FPDFLib.ImageVerticalResolution;
  vIYR := FPDFLib.ImageHorizontalResolution;
  case FPDFLib.ImageResolutionUnits of
    0, 1 : begin
      vResolutionFactorX := 1;
      vResolutionFactorY := 1;
    end;
    2 :  begin
      vResolutionFactorX := 1/vIXR * 25.4;
      vResolutionFactorY := 1/vIYR * 25.4;
    end;

    3 : begin
      vResolutionFactorX := 1/vIXR * 10;
      vResolutionFactorY := 1/vIYR * 10;
    end;
  end;
  vWidth := FPDFLib.ImageWidth * vResolutionFactorX;
  vHeight := FPDFLib.ImageHeight * vResolutionFactorY;
  vRes := FPDFLib.DrawImage(vGrProperties.x, vGrProperties.y, vWidth, vHeight);
  Assert(vRes > 0, cnstPlaceGraphicErr);

   ...

  if FPDFLib.SaveToFile(vFileName) = 0 then
    raise Exception.Create(format(cnstUnableSaveFile, [vFileName]));
end;
----------------------------------------------
I have an test project on Delphi with testing image, but I don't see how to attach file here



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