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 - What is the return code of replaceimage function?
  FAQ FAQ  Forum Search   Register Register  Login Login

What is the return code of replaceimage function?

 Post Reply Post Reply
Author
Message
kk aw View Drop Down
Team Player
Team Player
Avatar

Joined: 02 Feb 10
Location: Malaysia
Status: Offline
Points: 36
Post Options Post Options   Thanks (0) Thanks(0)   Quote kk aw Quote  Post ReplyReply Direct Link To This Post Topic: What is the return code of replaceimage function?
    Posted: 21 Jan 14 at 6:04PM
What is the return code of the replaceimage function?  It is not stated in the documentation.
Back to Top
Rowan View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 10 Jan 09
Status: Offline
Points: 398
Post Options Post Options   Thanks (0) Thanks(0)   Quote Rowan Quote  Post ReplyReply Direct Link To This Post Posted: 22 Jan 14 at 3:19AM
If the return code is not stated in the documentation then it can be presumed to be zero (0) for failure and one (1) for success.
Back to Top
kk aw View Drop Down
Team Player
Team Player
Avatar

Joined: 02 Feb 10
Location: Malaysia
Status: Offline
Points: 36
Post Options Post Options   Thanks (0) Thanks(0)   Quote kk aw Quote  Post ReplyReply Direct Link To This Post Posted: 22 Jan 14 at 4:41AM
Thanks Rowan.  

My development code for converting embedded images in bmp format to jpg, gif or png is given below. The image replacement function is always returning 0.  Any ideas what I have missed?

I am using version 9.16 of the QuickPDF library.  I use the Imagelib TMultiImage component for the conversion.  The images saved to file are correct.

procedure TMainform.ConvertImage1Click(Sender: TObject);
var
  i,j,n: Integer;
  ImgID, nImgID: Integer;
  ImgCount: Integer;
  ImgName1, ImgName2: string;
  ImgType: Integer;
  ImgConverted: Integer;
  FPrivdir: string;
  FileExt: string;
  FFileName: string;
  retval: Integer;
begin
  Screen.Cursor := crHourGlass;
  FPrivdir:= sm.slashAdd(LmdSysInfo1.TempPath);
  FileExt:= sm.locase(ElcomboBox1.Text);
  ImgConverted:= 0;
  try
    ImgCount := Qp.FindImages;
    j:= ImgCount;
    imgId := QP.GetImageID(j);
    while j > 0 do
      begin
        qp.SelectImage(ImgID);
        ImgType := Qp.ImageType;
        if ImgType = 2 then
          begin
            ImgName1 := FPrivdir + 'PdfImage.bmp';
            ImgName2 := FPrivdir + Format('PdfImage.%s',[FileExt]);
            MultiImage1.ImageName:= '';
            QP.SaveImageToFile(Imgname1);
            MultiImage1.ImageName:= Imgname1;
            If sm.EqualIC(FileExt,'jpg') then
              MultiImage1.SaveAsJpg(ImgName2)
            else if sm.EqualIC(FileExt,'gif') then
              MultiImage1.SaveAsGIF(Imgname2)
            else if sm.EqualIC(FileExt,'png') then
              MultiImage1.SaveAsPNG(Imgname2);
            nImgID:= qp.AddImageFromFile(ImgName2,0);
            retval:= qp.ReplaceImage(ImgID, nImgID);
            If retval = 0 then
              ShowMessage('Image not replaced');
            retval:= qp.ClearImage(ImgID);
            If retval = 0 then
              ShowMessage('Image not cleared');
            Inc(ImgConverted);
          end;
        Dec(j);
        imgId := QP.GetImageID(j);
      end;
    Screen.Cursor := crDefault;
    If ImgConverted > 0 then
      begin
        ShowMessage(Format('%d Embedded images successfully converted',[ImgConverted]));
        FFileName:= FSelectedFile;
        n:= sm.posIC('.pdf', FFileName);
        System.Insert('[IC]',FFileName, n);
        Qp.SaveToFile(FFileName);
      end
    else
      ShowMessage('No image to convert');
  finally
    Screen.Cursor := crDefault;
  end;
end;

Back to Top
jpbro View Drop Down
Senior Member
Senior Member


Joined: 29 Mar 11
Status: Offline
Points: 77
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 09 Jul 15 at 10:36PM
I have the same problem with QPDF 10.16 - ReplaceImage is always returning 0. Did you ever find a solution for this?
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