On Tue, Jul 08, 2008 at 10:52:11AM +0300, Igor Stirbu wrote:
> Hello Michal,
[...]
> First I tried to write the script because I was unaware how to integrate
> with the app. After I failed I searched the web and found the patch for
> multiple page metrics. Then I made the patch for multiple page tm
> because my script failed.
>
> >
> > However your script:
> >> function zoom()
> >> {
> >> f = loadPdf("/home/istirbu/test.pdf");
> >> pg = f.getFirstPage();
> >> for(; f.hasNextPage(pg); pg = f.getNextPage(pg))
> >> {
> >> pg.setTransformMatrix([1.3,0,0,1.3,-90,-115]);
> >> }
> >> f.unloadPdf();
> >> }
> >
> > doesn't work properly in some cases:
> > * if document has only one page, for loop doesn't perform at all
> > (because 1st page doesn't have any next page).
> > - I would suggest simpler
> > for (i=f.getPage(1); i<= f.getPageCount(); ++i)
> >
> > - or do {} while(f.hasNextPage) if you insist on iterator
> > approach
>
> Yeah, well, if there is only one page then I probably wouldn't use
> the script (I have few documents that have a lot of pages). But
> your advice is correct.
>
> > * I am also not sure whether unloadPdf saves changes
> > (src/gui/qspdf.cc:65 says that CPdf instance is simply dropped thus
> > no changes are saved - but I maybe I am missing something from
> > scripting POV).
> > - I would call f.save() before f.unloadPdf()
>
> Well, you just made me realize that I've been struggling for a couple
> of days and the solution was just a few keystrokes away. I've added
> the f.save() and my script did it's job.
> The method 'save()' is not listed among the methods of Pdf class and
I was able to find it in Help (F1)->scripting.html#Pdf.save
> CObject is the only class Pdf is inheriting so I didn't know I can
> call it. What did I miss?
QSPdf inherits from QSCObject only because of scripting. Besides that
QSPdf provides wrapper for CPdf (kernel non gui class which implements
manipulation with pdf in document scope), which means that all CPdf
methods which should be exported to scripting are present in QSPdf.
>
> Another thing I did not manage to run the script from command line,
> ie transmit the pdf as a parameter. So if this is my current function,
> how can it be called from outside with a file name parameter?
Scripting usage without gui is possible but it is little bit pain in
current implementation (as I have found out recently when I wanted to
implement batch mode document merge).
But, anyway, you can look into delinearize.qs (delivered with PDFedit)
how it is done there, put your script file under ~/.pdfedit/ and run it
by pdfedit -s YOUR_FILE parameters
Or you can avoid scripting and put this simple code directly into c++
code using only kernel without gui. Let me know if you are interested in
this approach.
--
Michal Hocko
-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Pdfedit-support mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pdfedit-support