...well, I guess I know what was going wrong with my code: QSPdfOperator doesn't have a copy constructor (and for some reason, it seems to be needed for passing objects between C++ and QSA sides).

Now I am dealing with a "funny" thing: 
I am extending QSPage somehow:

void QSPage::f() {
    boost::shared_ptr<PdfOperator> op(...);
    libs::Rectangle bbox = op->getBBox();
    printf(" [ %f , %f , %f , %f ] \n", bbox.xleft, bbox.yleft, bbox.xright, bbox.yright);


The thing is, I am getting two different results depending on _when_ I invoke that function:
If I run pdfedit and open some PDF file, and execute the following (into the script console):
  p = document.getPage(5);
then I can obtain something like:
  [ 393.760000 , 734.615000 , 495.829000 , 744.668000 ]
but if I run pdfedit and open the same PDF file and before executing those lines, first I change the current page (on the GUI) to the fifth page (the page I am processing), then I obtain this:
  [ 393.760000 , 784.615000 , 495.829000 , 794.668000 ]
The difference is on the y-axis (50 units more). Why? How can I simulate it? The problem is that the real values are those last ones... I already noticed that this whole thing is too tied to GUI, but I don't see any point in which some 'current GUI page'-dependent code could mess up the results :(

Any help?

Thanks in advance.

On Sunday, February 3, 2013, Alejandro Ramos Encinosa wrote:
Hello guys.

I am still on my looong way to code some automated redaction tool.
So far, I am able to redact simple texts (i.e., simple/single 'Tj' operators). But now I face the fact that there are some texts to whom I can't apply the same technique: complex 'Tj' operators. I was looking deeply into 'pdfedit' source and I found a piece of code that do what I need, except for the fact that it is too tied to GUI (or at least, that's what I reach to understand) :(
I "sweep" a bit and now I have, in one hand, a QSA script with the right functionality, and in the other hand, some C++ code extending somehow the current 'pdfedit' version. But there is something left: the QSA part needs all the involved QSPdfOperators, but I don't know how to ...return them? emit them? from the C++ code (where I have a collection of the involved PdfOperators --note the lack of 'QS' preffix). How can I just create a new instance of a QSPdfOperator having a PdfOperator? I tried this:
BaseCore *bc = new BaseCore();
boost::shared_ptr<PdfOperator> textOp;
return QSPdfOperator(textOp, bc);

but I got:

error: no matching function for call to ‘gui::QSPdfOperator::QSPdfOperator(gui::QSPdfOperator)’
note: candidates are:
note: gui::QSPdfOperator::QSPdfOperator(boost::shared_ptr<pdfobjects::PdfOperator>, gui::BaseCore*)
note:   candidate expects 2 arguments, 1 provided

What is wrong? I am missing something for sure, but I don't know what it is :(
Could you help me, please?

Thanks in advance.
Best regards.

On Wednesday, December 26, 2012, Jozef M. wrote:
Dne 12/24/2012 11:52 PM, Alejandro Ramos Encinosa napsal(a):
> Well, I just realize that there is a "flatten" tool that:
> - ask for an existing (PDF) file path; and then
> - ask for an output (PDF) file path; and then
> - save into the second file the last version of every object into the
> first file.
> So, this seems to do what I need, but not in the way I expected to: do
> I really need to save the current changes, and then invoke the flatten
> tool with the file path? Am I really unable to just process the
> current (in-memory) document?
> Any way, all I need now is to know how to script my goal:
> - open a PDF file;
> - make some texts replacements;
> - (optionally) draw lines/rects at fixed positions;
> - save the document ensuring that it will contain just one revision.
> The only way I know so far for achieving this, is to save first the
> document with new revisions and then pass its path to the flatten
> tool, but even this way, I don't know how to write an script for all
> this. Any help?

Hi Ale,

regarding scripting see

regarding flattening, that is how it is done, if you know c++ it should
be pretty simple, probably not effective though.


> In the meanwhile, I will look deep into the code trying to find a way
> to use a shortcut.
> On 12/23/12, Alejandro Ramos Encinosa <arencinosa@gmail.com> wrote:
>> Hi all.
>> As far as I've read, once we save all changes, a new revision is created.
>> My goal is to "rewrite" the current content instead of creating a new
>> revision into the document: lets say I "spellcheck" the content of the
>> document, I need then to be able to save the changes in a way in which
>> the wrong words are no longer into the final PDF. Is there any way in
>> which I can accomplish it?
>> In the case in which the current pdfedit implementation doesn't cover
>> such functionality, what should I modify to get the expected result?
>> Thanks in advance.
>> --
>> Ale

LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
Pdfedit-support mailing list