IIXC_Image.Save Error

PDF-XChange Editor SDK for Developers

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Paul - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
jeffp
User
Posts: 923
Joined: Wed Sep 30, 2009 6:53 pm

IIXC_Image.Save Error

Post by jeffp »

I have a situation where I need to Insert a IIXC_Page into an IIXC_Image, but I need to produce the Page with the CreateFromHBITMAP call.

I can load the .bmp directly using IIXC_Image.Load and then save it without issue (Case 1 below). But my Case 2 below gives and error. Please take a look at the code below and let me know what I'm missing in Case 2.

Code: Select all


procedure TMyIMG.Test;
var
  hr: Integer;
  APageCount: Cardinal;
  AInput, AOutput, AOutput2, ADir: String;
  ADoc: IIXC_Image;
  APage: IIXC_Page;
  B: TBitmap;
begin
  ADir := ExtractFilePath(Application.ExeName) + 'Outputs\';
  AInput := ADir + 'DrawPage1.bmp';
  AOutput := ADir + 'Test.tif';
  AOutput2 := ADir + 'Test2.tif';

  //CASE 1
  INST_IXC.CreateEmptyImage(ADoc);
  ADoc.Load(PChar(AInput), 0);
  hr := ADoc.Save(PChar(AOutput), CreationDisposition_Overwrite); //THIS WORKS
  ADoc := nil;

  //CASE 2
  INST_IXC.CreateEmptyImage(ADoc);
  B := TBitmap.Create;
  try
    B.LoadFromFile(AInput);
    INST_IXC.Page_CreateFromHBITMAP(B.Handle, varNull, APage);
    ADoc.InsertPage(APage, 0);
  finally
    B.Free;
  end;
  ADoc.Get_PagesCount(APageCount);
  msgbox(APageCount); //This is correct
  hr := ADoc.Save(PChar(AOutput2), CreationDisposition_Overwrite); //THIS FAILS. hr returns -2113732588
  ADoc := nil;

end;

jeffp
User
Posts: 923
Joined: Wed Sep 30, 2009 6:53 pm

Re: IIXC_Image.Save Error

Post by jeffp »

I think I see my mistake. After creating the IIXC_Page I needed this.

APage.Set_FmtInt(FP_ID_FORMAT, FMT_TIFF_ID);

to define the file type.

I guest IIXC_Image.Load will automatically define this based on the file extension.

--Jeff
User avatar
Will - Tracker Supp
Site Admin
Posts: 6815
Joined: Mon Oct 15, 2012 9:21 pm

Re: IIXC_Image.Save Error

Post by Will - Tracker Supp »

Hi Jeff,

Thanks for the posts - Is the issue solved now?
If posting files to this forum, you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded.
Thank you.

Best regards

Will Travaglini
Tracker Support (Europe)
Tracker Software Products Ltd.
http://www.tracker-software.com
jeffp
User
Posts: 923
Joined: Wed Sep 30, 2009 6:53 pm

Re: IIXC_Image.Save Error

Post by jeffp »

Yes. The first was was but..

How can I pass a Windows HDIB into

INST_IXC.Page_CreateFromHBITMAP(HDIB, varNull, Result);

And get it to work.

I can get

INST_IXC.Page_CreateFromHBITMAP(TBitmap.Handle, varNull, Result);

To work, but it seems the conversion of a Windows HDib is a bit different.

Also, when is the next build due out. I thought it was going to be soon, but the end of June??

--Jeff
Sasha - PDF-XChange
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: IIXC_Image.Save Error

Post by Sasha - PDF-XChange »

Hello Jeff,

Please read this topic:
http://stackoverflow.com/questions/1420 ... om-hbitmap
About the release - we don't know the specific date yet.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ