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 - PDF Viewer / Editor
  FAQ FAQ  Forum Search   Register Register  Login Login

PDF Viewer / Editor

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


Joined: 07 Oct 11
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote pshay543 Quote  Post ReplyReply Direct Link To This Post Topic: PDF Viewer / Editor
    Posted: 25 Apr 12 at 1:35AM
Hi,
 
I'm looking for a way to display the PDF in a viewer/editor so the user can make changes.  I'm not looking to write a full PDF editor but if it would display the pdf page in a way that the graphics on the page are their own "element" and the end user could click a graphic and remove it from the page or replace it with another graphic.  Also, it would be nice if the user could just drag the image around.  I really do not care about editing text. 
 
I assume with QuickPDF library I can look at each page and read all the attributes for the image (size, position),  text with formatting,  etc.  And place these elements on a Rich View control of some type to accomplish this. 
 
I have only used this component to merge and split PDF files. Now I need the ability to add the above mentioned features.
 
Would this be the right approach to do this ?   How would forms be handled for filling in information? 
 
It would be nice if there was a viewer with QP that allowed this type of stuff.  I know I can render the page and then display it as a graphic but I need the elements seperated to be selectable.
 
How are form fields handled when displaying for a user to fill out the information? 
 
Any help would be appreciated or if there is a known viewer / editor available that works with Quick PDF I would be interested. 
 
 
Thank you,
Paul Shay
 
 
 
 
Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3530
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 25 Apr 12 at 6:30PM
Hi Paul!

In the sample-section there's
code for a viewer, too.
Try the search function...

Cheers, Ingo

Back to Top
edvoigt View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 Mar 11
Location: Berlin, Germany
Status: Offline
Points: 111
Post Options Post Options   Thanks (0) Thanks(0)   Quote edvoigt Quote  Post ReplyReply Direct Link To This Post Posted: 25 Apr 12 at 8:52PM
Hi Paul,

the problem is editing. So I say nothing about how to render.

With QP you may build PDFs or modify existing PDFs. But modifying is here only a drawing over. Generally it is very difficult to find out which part inside the PDF is for which visible part on screen. And modifying inside the PDF is no easy game.


So I did a small and dirty study to go another way. The idea is to build a PDF-page over a descriptionlist of objects. If we would have a such list, we could interpret it to build a PDF. If we want to correct something, we change the list and make a fresh PDF.

Because we store for our objects the coordinates, we may calc back (over the used scale for rendering) from mouseposition in image to coordinates and find out, on which object the mouse is pointing.

So we create a baseobject for all entries in our list.

Here is may source, but beware it is only a study, fare from use.

First the objects:

type
  TMyPaintObj = class(TObject) // the base for all kind of PDF-content
  private
    x0, y0,
    x1, y1: double;            // area, in which the object is to paint
  public
    procedure SetData(ax0, ay0, ax1, ay1: double); virtual;
    procedure Paint(QP: TQuickPDF); virtual; // only for inheritance
  end;

  TMyColorObj = class(TMyPaintObj)
  private
    C, M, Y, K: double;
  public
    procedure SetData(aC, aM, aY, aK: double); override;
    procedure Paint(QP: TQuickPDF); override;
  end;

  TMyLineObj = class(TMyPaintObj)
  private
  public
    procedure SetData(ax0, ay0, ax1, ay1: double); override;
    procedure Paint(QP: TQuickPDF); override;
  end;

  TMyBoxObj = class(TMyPaintObj)
  private
  public
    procedure SetData(ax0, ay0, ax1, ay1: double); override;
    procedure Paint(QP: TQuickPDF); override;
  end;

  TMyCircleObj = class(TMyPaintObj)
  private
    r1: double;
  public
    procedure SetRadius(ax0, ay0, ar1: double);
    procedure Paint(QP: TQuickPDF); override;
  end;

// our list-object, it represents all content
  TDrawList = class(TObjectList) // items = TMyPaintObj
    function GetMyPaintObj(aindex: integer): TMyPaintObj;
    procedure SetMyPaintObj(aindex: integer; const Value: TMyPaintObj);
  public
    ItemIndex: integer;
    property items[aindex: integer]: TMyPaintObj read GetMyPaintObj write SetMyPaintObj; default;
    constructor Create; virtual;
    destructor Destroy; override;
    procedure Paint(QP: TQuickPDF);
  end;


The implementation looks like this:


procedure TMyPaintObj.SetData(ax0, ay0, ax1, ay1: double);
begin
  x0 := ax0; y0 := ay0;
  x1 := ax1; y1 := ay1;
end;

procedure TMyPaintObj.Paint(QP: TQuickPDF); // only for inheritance
begin
end;

procedure TMyColorObj.SetData(aC, aM, aY, aK: double);
begin
  C := aC; M := aM; Y := aY; K := aK;
end;

procedure TMyColorObj.Paint(QP: TQuickPDF);
begin
  QP.SetLineColorCMYK(C, M, Y, K);
end;

procedure TMyLineObj.SetData(ax0, ay0, ax1, ay1: double);
begin
  inherited SetData(ax0, ay0, ax1, ay1);
end;

procedure TMyLineObj.Paint(QP: TQuickPDF);
begin
  QP.DrawLine(x0, y0, x1, y1);
end;

procedure TMyBoxObj.SetData(ax0, ay0, ax1, ay1: double);
begin
  inherited SetData(ax0, ay0, ax1, ay1);
end;

procedure TMyBoxObj.Paint(QP: TQuickPDF);
begin
  QP.DrawBox(x0, y0, x1-x0, y1-y0, 2);
end;

procedure TMyCircleObj.SetRadius(ax0, ay0, ar1: double);
begin
  inherited SetData(ax0, ay0, 0, 0);
  r1 := ar1;
end;

procedure TMyCircleObj.Paint(QP: TQuickPDF);
begin
  QP.DrawCircle(x0, y0, r1, 2);
end;

// in the same manner you have to construct more objects for fonts and text
// and all other things you need

constructor TDrawList.Create;
begin
  inherited Create;
  ItemIndex := -1;
end;

destructor TDrawList.Destroy;
begin
  inherited Destroy;
end;

function TDrawList.GetMyPaintObj(aindex: integer): TMyPaintObj;
begin
  if (aindex<0) or (aindex>=count)
  then Result := nil
  else Result := inherited Items[aindex] as TMyPaintObj;
end;

procedure TDrawList.SetMyPaintObj(aindex: integer; const Value: TMyPaintObj);
begin
  inherited Items[aindex] := Value;
end;

// this small code make our list to be a PDF-page
procedure TDrawList.Paint(QP: TQuickPDF);
var
  j: integer;
begin
  for j:=0 to Count-1
  do Items[j].Paint(QP); // every object paints itself
end;


If you did read till here, you know it looks as a lot of work, but it may be a way.


Cheers,
Werner
Back to Top
pshay543 View Drop Down
Beginner
Beginner


Joined: 07 Oct 11
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote pshay543 Quote  Post ReplyReply Direct Link To This Post Posted: 26 Apr 12 at 1:44PM
Werner,
Thank you for sharing the code. I may try to go down this route using your code as an example. Originally I was going to look at purchasing TRichView and ScaleRichview addon and place all the items of the PDF page in the richview / scalerichview component. Manipulate them and then read them off the richview page and place them back into the PDF page. This may work but I am not sure how hard it will be to add the components to the Rich Editor and then get them back in the right position to place on the PDF page. Also, the two components together are $500.00 and I don't want to (and can't afford to) spend that right now.
I appreciate you sharing the code and your thoughts on this.
I still am not sure how I would handle form fields. I just need to play with the form fields in quick pdf a little more to see how they look in a PDF file and what information can be gained from them to determine positioning, style, etc.
Thank you,
Paul Shay
Back to Top
edvoigt View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 Mar 11
Location: Berlin, Germany
Status: Offline
Points: 111
Post Options Post Options   Thanks (0) Thanks(0)   Quote edvoigt Quote  Post ReplyReply Direct Link To This Post Posted: 26 Apr 12 at 2:10PM
Hi Paul,

if you think about something in direction to RTF, so I advise you to a very nice open-source-program. It is made by Marek Jedlinski and named keynote. And there is a work based on it, called keynote-nf, made by Daniel Prado Velasko. The source is hosted at http://code.google.com/p/keynote-nf/ .

Inside this program works with RTF and images and a lot of other things are allowed too. May be it helps at building the big part outside PDF.


Cheers,

Werner
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