On Sat, May 02, 2009 at 08:46:08PM +1200, Kai-Cheung Leung wrote: > Thanks a lot. However where can I get the API reference manual for the > PDFedit script language?
Scripting API reference (I don't how much complete and up-to-date because I wasn't involved in GUI/scripting development very much) should be available through standard help (F1 - scripting.html page). If you are asking about the language itself then it is based on ECMAScript which should be basically the same as JavaScript (http://en.wikipedia.org/wiki/ECMAScript) I hope that this will help you a bit. > > Cheers, > > Kaicheung > > > Quoting Michal Hocko <[email protected]>: > > > 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 -- Michal Hocko ------------------------------------------------------------------------------ The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your production scanning environment may not be a perfect world - but thanks to Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 Series Scanner you'll get full speed at 300 dpi even with all image processing features enabled. http://p.sf.net/sfu/kodak-com _______________________________________________ Pdfedit-support mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/pdfedit-support
