Jump to content

Pull specific page from 50-page PDF based on field


mddarfus

Recommended Posts

I'm almost sorry to ask this, as I know the answer will be simple... but I can't seem to remember, or find the exact syntax I need in the maunals or forum responses...

 

I'm looking to return a single PDF page based on a field in my database. The 50-page PDF resource has been added into my FusioPro document resources already. I just need the proper syntax to say something like:

 

If (Field("signtype") == "Sale Pending")

return Resource("Sign.pdf") page number 1

 

If (Field("signtype") == "Sold")

return Resource("Sign.pdf") page number 2

 

If (Field("signtype") == "For Sale")

return Resource("Sign.pdf") page number 3

 

etc...etc...etc...

 

I just can't figure out how to pull certain pages from the one 50-page PDF?

 

It's a Monday for sure!

Link to comment
Share on other sites

Something like this:

var myResource = Resource("Sign.pdf");
switch (Field("signtype"))
{
   case "Sale Pending":
       myResource.pagenumber = 1;
       break;
   case "Sold":
       myResource.pagenumber = 2;
       break;
   case "For Sale":
       myResource.pagenumber = 3;
       break;
   // etc.
}
return myResource;

Or, if you want to be a bit more succinct:

var pages = [
   "Sale Pending",
   "Sold",
   "For Sale",
   //etc.
];
var myResource = Resource("signtype");
myResource.pagenumber = pages.indexOf(Field("signtype")) + 1;
return myResource;

Edited by Dan Korn
expanded pages array to facilitate adding more entries
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...