Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Friday, June 29, 2007 11:51:02 AM(UTC)
dlucchese

Groups: Registered
Posts: 11


Hi

I'm currently try to delete pages in PDF documents. It seems like L_DeletePage always deletes the last page in addition of the page I asked to delete. For exemple, on a 7 pages document, if I call L_DeletePage( 'c:\scan.pdf', 1, 0, nil ), page 1 is deleted but page 7 too, and I get a 5 pages document as a result.

I tried to provide a valid SaveOptions structure with pagenumber set to the page to delete with no effect.

I use full version 15, and here is my code:

procedure TLTPage.DeletePage;
var
  _saveOptions: pSAVEFILEOPTION;
begin
  _saveOptions := PageCollection.SaveOptions;
  _saveOptions.PageNumber :=  index + 1;
  // Delete page in the file
  L_DeletePage( PageCollection.Filename, index + 1, 0, _saveOptions);
  // Indicate the alteration in the page
  f_Alteration := f_Alteration + [ altDeleted ];
end;

I put a break point in the L_DeletePage function and I'm sure it's called just one time.

One thing I worry about: in the help file it's written the function is supported by TIFF, PCX and Winfax file formats. Is it outdated or is it true it doesn't work with PDF files?


 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Sunday, July 1, 2007 10:36:19 PM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,328

Was thanked: 1 time(s) in 1 post(s)

Hello,

The L_DeletePage function works only with PDF files that originally created using LEADTOOLS SDK.

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
#3 Posted : Monday, July 2, 2007 8:55:30 AM(UTC)
dlucchese

Groups: Registered
Posts: 11


It was created with LeadTools.  The first operation I make is rebuilding the file with Leadtools. That works fine. Then I'm able to insert and replace pages. To  be sure, I even change the file extension that way I can keep the original file for backup.

All works fine, but the deletepage operation deletes the requested page plus the last one. Any idea?
 
#4 Posted : Tuesday, July 3, 2007 12:54:40 AM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,328

Was thanked: 1 time(s) in 1 post(s)

Hello,

I checked the L_DeletePage function on my side and it works correctly. It only removes one page.
The problem might be related to the build number of the LEADTOOLS v15 DLLs that you use. What is the build number Ltkrn15u.dll and ltfil15u.dll DLLs on your machine?

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
#5 Posted : Tuesday, July 3, 2007 4:07:25 AM(UTC)
dlucchese

Groups: Registered
Posts: 11


For Ltkrn15u.dll: 15.0.0.8
ltfil15u.dll:           15.0.0.15
 
#6 Posted : Tuesday, July 3, 2007 4:58:47 AM(UTC)
dlucchese

Groups: Registered
Posts: 11


Hint
I made one more test: I processed a TIF file with the same code, and it worked fine. The problem seems to be in my PDF file or in the PDF writer. I can send you an example of a PDF I built with this code if you want. Here is the code to convert a PDF to Leadtools format:

const
  // Purkinje PDF file extension
  LTOBJ_PURKINJE_PDF_EXT    = '.PPDF';
  // TIF file extension
  LTOBJ_PURKINJE_TIF_EXT    = '.TIF';
  // File format when saving image documents
  IMAGE_SAVE_FORMAT = FILE_RAS_PDF_JPEG_422;
  // loss rate when saving images
  IMAGE_SAVE_Q_LOSS = 25;


// Check if the file can be updated by Leadtools, if not make the conversion to PPDF
// -----------------------------------------------------------------------------
//
procedure TLTPageCollection.ConvertIfNeeded;
begin
  // If it's not a PPDF or TIF file, we must first convert the file
  if  ( uppercase( ExtractFileExt( FileName ) ) <> LTOBJ_PURKINJE_PDF_EXT ) and
      ( uppercase( ExtractFileExt( FileName ) ) <> LTOBJ_PURKINJE_TIF_EXT ) then
  begin
    _ConvertCurrentFile;
  end;
end;



// Convert a file into a PPDF file, that can easily be manipulated with Leadtools API
// -----------------------------------------------------------------------------
//
procedure TLTPageCollection._ConvertCurrentFile;
var
  _ret: integer;
  _newFilename: widestring;
  _bitmapList: HBITMAPLIST;
begin
  // build the new filename
  _newFilename := ExtractFilePath( FileName ) +
                  ExtractFileNameNoExtension( FileName ) + LTOBJ_PURKINJE_PDF_EXT;

  // indicate we changed the file extension
  f_IsFileExtensionChanged := true;               

  L_LoadBitmapList( FileName, @_bitmapList, 0, ORDER_BGRORGRAY, nil, @f_FileInfo );
  try
    _ret := L_SaveBitmapList( @_newFilename[1], _bitmapList, IMAGE_SAVE_FORMAT, 24, IMAGE_SAVE_Q_LOSS, SaveOptions );
    // once the new file is saved, it's the new current file
    if _ret = SUCCESS then
    begin
      f_Filename := _newFilename;
    end;
  finally
    // Free the bitmaps in memory
    L_DestroyBitmapList( _bitmapList );
  end;

end;

 
#7 Posted : Thursday, July 5, 2007 11:29:59 AM(UTC)
dlucchese

Groups: Registered
Posts: 11


Hi

Excuse-me to insist, but it's very important for me to know what to do with this issue. Rebuilding my PDF each time a page is removed would make me lose image quality. On your side are you able to delete a single page, located in the middle of a PDF document built with Leadtools, without losing pages at the end of the document ?

Cheers

David Lucchese
 
#8 Posted : Saturday, July 7, 2007 11:58:22 PM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,328

Was thanked: 1 time(s) in 1 post(s)

Hello,

Can you please send me the sample PDF file?
Note: If you want to send any file, please put it in a ZIP or RAR file to reduce the size of the file.

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
#9 Posted : Tuesday, July 10, 2007 5:24:34 AM(UTC)
dlucchese

Groups: Registered
Posts: 11


Hi

In fact it the problem was solved when I upgraded with the patch: LIC - API - 7_3_2007.zip
and all went good after that.

Thanks
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2020, Yet Another Forum.NET
This page was generated in 0.081 seconds.