Answered
Hi, all
In my code, the method insertPages() has been executed for hundreds of times, and the screen was always winking crazily when program run insertPages().
How could i stop the screen refreshment? part of my js as follows,
... var tempPDF = app.newDoc(); for(var i = 0; i < iPageCount; i++) { var iPadPageNo = fnPadZeros(i + 1, iPageCount.toString().length); var tempNewPDF = app.openDoc({ cPath: sTempPngFolderPath + sBaseFileName + "_Page_" + iPadPageNo + ".png", bUseConv: true, bHidden: true }); // tempNewPdfPath = sTempPdfFolderPath + sBaseFileName + iPadPageNo + ".pdf"; tempNewPDF.saveAs({ cPath: tempNewPdfPath }); // tempPDF.insertPages({ nPage: tempPDF.numPages - 1, cPath: tempNewPdfPath }); // tempNewPDF.closeDoc(true); } tempPDF.saveAs({ cPath: sReleasedPdfFolderPath + sBaseFileName + ".pdf" }); tempPDF.closeDoc(true); console.println( sBaseFileName + ".pdf - Created Successfully!"); ...
Thanks
- gavin
1) Saving the newly created image files can add a lot of space to your drive, especially since they could be very large. Try using the existing path for the newly created file (tempNewPDF.path), then closing the doc without saving. I don't know if this will work because the file has a ".tmp" extension.
2) The blinking migth be reduced or go away if all the files are opened as hidden. For the "tempPDF" file, Save and close it first, then reopen as hidden.
3) There are a couple of totally different strategies for creating an image PDF. Either of these might improve the process. For both situations it would be best to start off with a PDF that's already has the correct number of blank pages.
a) Create a Button field on each page, that is the size of the page and setup to display an image.
fld.buttonPosition = position.iconOnly. You can also set the scaling and postion parameters if you want. In your loop use the fld.buttonImportIcon() function to load the images. At the end you can flatten the PDF to get rid of the button objects. but this is optional
b) Use the doc.addWatermarkFromFile() function to place the images on each page. This technique has to be used carefully. Watermarking is non-blocking and so it can cause a timing problem that will crash Acrobat. You'll also need to acquire and rename the OCG each time the watermark is applied. You'll find code and an example in this article.
http://www.acrobatusers.com/tutorials/2006/create_use_layers
Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]
The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]
Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]
Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script