Print Page | Close Window

CopyPageRanges corrupts original document

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=1254
Printed Date: 04 Apr 26 at 4:48AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: CopyPageRanges corrupts original document
Posted By: JanN
Subject: CopyPageRanges corrupts original document
Date Posted: 21 Oct 09 at 10:59AM
Hi,

I have used the following code. Please have a look at the comments.

------
var
  pdf: TQuickPDF0716;
  id: Integer;
begin
  pdf := TQuickPDF0716.Create;
  pdf.UnlockKey(';-)');
  pdf.LoadFromFile('c:\temp\x.pdf');
  id := pdf.SelectedDocument;
  pdf.SaveToFile('c:\temp\x1.pdf'); // this file is okay and fits the original file

  pdf.NewDocument;
  pdf.CopyPageRanges(id, '1');

  pdf.SelectDocument(id);
  pdf.SaveToFile('c:\temp\x2.pdf'); // !!!this file is corrupt!!!

  pdf.Free;
------

I believe it's a bug in the library. Or have I missed something? Confused




Replies:
Posted By: JanN
Date Posted: 23 Oct 09 at 10:04AM
Could anybody please quickly run my code with another test file and confirm my result? That would already help me a lot. Thanks in advance! :)


Posted By: Rowan
Date Posted: 27 Oct 09 at 5:38AM
Hi Jan,

Try the code listed below, does it work for you?

------
var
  pdf: TQuickPDF0716;
  id1: Integer;
  id2: Integer;
begin
  pdf := TQuickPDF0716.Create;
  pdf.UnlockKey(';-)');
  id1 := pdf.LoadFromFile('c:\temp\x.pdf');
  pdf.SelectDocument(id1);
  pdf.SaveToFile('c:\temp\x1.pdf'); // this file is okay and fits the original file

  id2 := pdf.NewDocument;
  pdf.SelectDocument(id2);
  pdf.CopyPageRanges(id, '1');
  pdf.SaveToFile('c:\temp\x2.pdf'); // !!!this file is corrupt!!!

  pdf.Free;
------

Cheers,
- Rowan.


Posted By: JanN
Date Posted: 27 Oct 09 at 9:25AM
Hi Rowan,

Thanks for your reply.

Be careful with "id1 := LoadFromFile()". That function only returns success or error. Wink But the following code works.

------
var
  pdf: TQuickPDF0716;
  id1, id2: Integer;
begin
  pdf := TQuickPDF0716.Create;
  pdf.UnlockKey(';-)');
  pdf.LoadFromFile('c:\temp\x.pdf');
  id1 := pdf.SelectedDocument;
  pdf.SaveToFile('c:\temp\x1.pdf');

  id2 := pdf.NewDocument;
  pdf.SelectDocument(id2);
  pdf.CopyPageRanges(id1, '1');
  pdf.SaveToFile('c:\temp\x2.pdf');

  pdf.Free;
end
------


But... I need to be able to call CopyPageRanges and afterwards work again with the original document. Something like that:

------
var
  pdf: TQuickPDF0716;
  id1, id2, id3, pc: Integer;
begin
  pdf := TQuickPDF0716.Create;
  pdf.UnlockKey('');
  pdf.LoadFromFile('c:\temp\x.pdf');
  pc := pdf.PageCount;
  id1 := pdf.SelectedDocument;

  // 1. saving original document is okay
  pdf.SaveToFile('c:\temp\x1.pdf');

  // 2. saving original document is okay
  pdf.SaveToFile('c:\temp\x2.pdf');

  // Saving copy 1 is okay
  id2 := pdf.NewDocument;
  pdf.SelectDocument(id2);
  pdf.CopyPageRanges(id1, '1-' + IntToStr(pc));
  pdf.DeletePages(1, 1);
  pdf.SaveToFile('c:\temp\x3.pdf');

  // Saving copy 2 is okay
  id3 := pdf.NewDocument;
  pdf.SelectDocument(id3);
  pdf.CopyPageRanges(id1, '1-' + IntToStr(pc));
  pdf.DeletePages(1, 1);
  pdf.SaveToFile('c:\temp\x4.pdf');

  // 3. Saving original document -> corrupt file
  pdf.SelectDocument(id1);
  pdf.SaveToFile('c:\temp\x5.pdf');

  pdf.Free;
end;

------

Can you reproduce that error?



Posted By: JanN
Date Posted: 30 Oct 09 at 8:56AM
Same behaviour using latest version 7.17... Cry


Posted By: JanN
Date Posted: 03 Nov 09 at 9:48AM
Hi Rowan,

Sorry for being impatient. But I need the CopyPageRanges function in a current project. Do you already have an idea why that happens? Can you estimate how long it will take to provide a patch (if it's a bug)?


Posted By: Ingo
Date Posted: 03 Nov 09 at 11:47AM
Hi Jan!

It depends on the point of view...
Perhaps this kind of work isn't possible or
QuickPDF doesn't offer this piece of functionality you need or
there's a buggy QuickPDF-function.
If you think that the last point is the right one that you should post your problem on the official support site.
Rowan visited this user-user-forum from time to time but not in a regulary way.

Cheers, Ingo



Posted By: JanN
Date Posted: 03 Nov 09 at 11:55AM
Moin Ingo!

I already chose that way (support site). But Rowan asked me to continue the case here. But I'll give it another try.



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