Print Page | Close Window

this.exportAsFDF(); BUT EXPORT 1 page out of many?

Printed From: Foxit's Planet PDF Forum
Category: Lets Talk PDF
Forum Name: JavaScript
Forum Description: Discussions relating to the use of JavaScript within PDF.
URL: http://forums.planetpdf.com/forum_posts.asp?TID=1967
Printed Date: 14 Dec 2019 at 7:49pm
Software Version: Web Wiz Forums 11.10 - http://www.webwizforums.com


Topic: this.exportAsFDF(); BUT EXPORT 1 page out of many?
Posted By: 20GT
Subject: this.exportAsFDF(); BUT EXPORT 1 page out of many?
Date Posted: 13 Mar 2016 at 3:33am
Hi I've created a print page with 21 checkboxes in my PDF.
I know i can use  .exportAsFDF(); in a button to export the PDf data from the whole form but;
I want to limit the export data to just one page. Is that possible? 


http://postimage.org/">
http://postimage.org/ - forum image hosting






Replies:
Posted By: Rob Lyman
Date Posted: 15 Mar 2016 at 8:09pm
The problem you're facing is that PDF effectively regards the entire PDF to be a single form; even though it treats pages individually in other aspects, it regards all pages to be part of a single form.

Fortunately, there are a couple of form features you can use to restrict your FDF output to a single page:

1.) exportAsFDF() takes an optional argument 'aFields': this an array of field names to include in the FDF. If you supply just the names of the fields on the single page, the FDF should only include those fields.

2.) Then your only problem is knowing what fields are on the page. The quickest solution is to just hardcode the names.

3.) If you need to dynamically determine the set of fields, you can use the 'page' property of the 'field' object. In the simple case, this will just be the number of the page the field is on. However, a field can actually appear on multiple pages; in that case, the 'page' property will be an array of page numbers the field appears on. A robust solution would check for this. (However, if you know for a fact that none of your fields appear on multiple pages, you could leave this out.)

So given the page number, you'd need a small bit of code to search the PDF for all fields with that page number, then put the field names into an array to supply to exportAsFDF().

Hope this helps!


-------------
Rob Lyman
Software Engineer
http://www.datalogics.com


Posted By: 20GT
Date Posted: 15 Mar 2016 at 11:16pm
thanks 
my script (eh hmmm someone else's script)

var flds=["P40.1.b","P40.1.n","P41.1.b","P41.1.n","P42.1.b","P42.1.n","P43.1.b","P43.1.n","P44.1.b","P44.1.n","P45.1.b","P45.1.n","P46.1.b","P46.1.n","P47.1.b","P47.1.n","P48.1.b","P48.1.n","P49.1.b","P49.1.n","P50.1.b","P50.1.n","P51.1.b","P51.1.n","P52.1.b","P52.1.n","P53.1.b","P53.1.n","P54.1.b","P54.1.n","P55.1.b","P55.1.n","P56.1.b","P56.1.n","P57.1.b","P57.1.n","P58.1.b","P58.1.n","P59.1.b","P59.1.n","P60.1.b","P60.1.n","P61.1.b","P61.1.n","P62.1.b","P62.1.n"];
this.exportAsFDF({aFields:flds});


How to find all the fields in a PDF
(CTRL J)Paste the code provided into the text field at the bottom of the screen, select all of it with the mouse and press Ctrl+Enter. 
The script will run and the field names will be printed out to the same console window, after the code.

for (var i=0; i<this.numFields; i++) { 
var f = this.getField(this.getNthFieldName(i)); 
if (f==null) continue; 
console.println(f.name); 
}



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.10 - http://www.webwizforums.com
Copyright ©2001-2017 Web Wiz Ltd. - https://www.webwiz.net