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 - AppendToFile, incremental updates
  FAQ FAQ  Forum Search   Register Register  Login Login

AppendToFile, incremental updates

 Post Reply Post Reply
Author
Message
mhnejmles View Drop Down
Beginner
Beginner


Joined: 10 Feb 17
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote mhnejmles Quote  Post ReplyReply Direct Link To This Post Topic: AppendToFile, incremental updates
    Posted: 10 Feb 17 at 1:55AM
So, has anyone been working with incremental updates lately? I've been trying to make it work in the latest 13.11 version but to no avail. Every pdf file I append goes corrupted and is unusable in most PDF viewers.

Even such a simple code like:

var
  PDF: TDebenuPDFLibrary;
  res: Integer;
begin
  PDF:= TDebenuPDFLibrary.Create;
  PDF.UnlockKey(const_key);
  res:= PDF.LoadFromFile(input_file, '');
  res:= PDF.AppendToFile(input_file);
  PDF.Free;
end;

ends up destroying the pdf file. And no changes were made to it. Direct Access functions work fine but you have less functionality in it. So have anyone else encountered this?
Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 10 Feb 17 at 8:21AM
Hi mhnejmles,

you should put your code into a try/finally structure to be more save.
What's inside input_file?
It should be always the same name.
Please read the description regarding AppendToFile (then you'll know while corruption can appear):
http://www.debenu.com/docs/pdf_library_reference/AppendToFile.php
Here you can read about incremental updates:
http://www.debenu.com/kb/incremental-updates/

Cheers and welcome here,
Ingo

Cheers,
Ingo

Back to Top
mhnejmles View Drop Down
Beginner
Beginner


Joined: 10 Feb 17
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote mhnejmles Quote  Post ReplyReply Direct Link To This Post Posted: 10 Feb 17 at 5:58PM
Hi,
thanks for the reply

Sorry, was working really late last night and I didn't have the strength to write everything down here. I am working with the 13.11 Delphi version of QuickPDFLibrary in Delphi Berlin 10.1.

I did go through the description and sample code based on the knowledge base topic about incremental updates to PDFs already.

I will elaborate more on the details....

So I basically copied the code structure from the sample. I was also trying to do some more with it but I came to the conclusion there might be a bug. So let's say I have a pdf file with a filepath. It's a simple pdf file I generated from a Word through Adobe PDF printer with some text in it. I wanna try to append some changes to the file. So I create a new form and a simple code:

unit Unit1;
interface
uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, DebenuPDFLibrary, Vcl.StdCtrls;
Const QPDFLicKey='licensekey';
type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
  public
    { Public declarations }
  end;
function QuickPDFLib_AppendToPDF(filepath: String): Boolean;
var
  Form1: TForm1;
implementation
{$R *.dfm}
function QuickPDFLib_AppendToPDF(filepath: String): Boolean;
var PDF: TDebenuPDFLibrary;
begin
  result:= false;
  PDF:= TDebenuPDFLibrary.Create;
  PDF.UnlockKey(QPDFLicKey);
  if PDF.LoadFromFile(filepath ,'') > 0 then
    begin
      if PDF.AppendToFile(filepath) > 0 then
        result:= true;
    end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
  res: boolean;
begin
  res:= QuickPDFLib_AppendToPDF('C:\pdf_work\test_pdf.pdf');
  if res then
    ShowMessage('Success!!')
  else
    ShowMessage('Fail!!');
end;
end.

And when I use the button, 'Success' message appears. But when I open the pdf file:

- in adobe reader, it gives me error 14, that the file is corrupted
- in google chrome, the file won't load
- tried MS Edge, the file did load there surprisingly

the code is just basic load and append nothing more when I do the same thing using Direct Access(DA) there is no problém, the pdf file saves fine. Problem is that DA doesnt have a lot of the usual functionality.
At first I tried to do some more stuff with it, like add an embedded file, merge 2 documents together and the result file came out alright when I use SaveToFile function. But whenever I use AppendToFile, the result file gets corrupted.
Note: the filepath always stays the same, so I am appending to the same file I open. If you don't give it the same file then the library throws an exception. I can upload the files somewhere if deemed neccessary. But I was kinda curious whether anyone else has encountered this.

Hope it is somewhat understandable,
mhnejmles

Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 11 Feb 17 at 10:20PM
if you wanna tell about an error this is the wrong place here...
Try the official support pages in this case.

Cheers,
Ingo

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