BLANK PDF after script export for iPAD. Any ideas from the experts?

Please see my applescript here… there is a bunch of this this script does, but I’m only really concerned with the PDF that gets exported upon completion. When I view on a iPAD it’s blank using this script but works fine if I export direct from InDesign without the script. Surely there is a simple reason for this?

try
set FlashFlow_prefs to (path to preferences folder as string) & “FlashFlow_prefs.txt” as alias → Place the “FlashFlow_prefs.txt” text file in the active users Library/Preferences folder
on error
display dialog “Can’t find ‘FlashFlow_prefs.txt’ in the active users preferences folder!” with icon 0
error number -128
end try

set the_content to read FlashFlow_prefs → Read the contents of the text file

set client_list to {} → Create an empty list

repeat with i from 1 to count of paragraphs of the_content
copy paragraph i of the_content to end of client_list → copy each paragraph of the text file onto the end of the ‘client_list’
end repeat

tell application “Adobe InDesign CS5.5”
set preset_list to the name of every PDF export preset
if preset_list does not contain “fagantest” then
my create_Preset()
end if
try
set the_container to (file path of document 1 as string)
on error
display dialog “This document needs to be saved before file export can be performed” with icon 1
error number -128
end try
set export_result to button returned of (display dialog “Where would you like to export the files to?” buttons {“same as document”, “Choose a folder”})
if export_result = “same as document” then
set export_path to the_container
else if export_result = “Choose a folder” then
set export_path to (choose folder) as string
end if
set doc_name to name of document 1
if doc_name ends with “.indd” then set doc_name to text 1 thru -6 of doc_name

set the_pages to every page of document 1

set page_name_list to name of every page of document 1
set unix_list to {}
repeat with this_page_no in page_name_list
	copy this_page_no & {ASCII character 10} to end of unix_list
end repeat
set new_string to do shell script "echo " & quoted form of (text 1 thru -2 of (unix_list as string)) & " | sort -f"
set new_list to (paragraphs of new_string)
set range_list to ""
repeat with my_page in new_list
	set section_name to name of applied section of page my_page of document 1
	set i to section_name & my_page
	set range_list to range_list & (i & ",")
end repeat

repeat with this_page in the_pages
	set section_name to name of applied section of this_page
	set page_name to name of this_page
	set i to section_name & page_name
	if i contains ":" then
		set myoffset to offset of ":" in i
		set page_number to text (myoffset + 1) thru end of i as string
	else
		set page_number to i
	end if
	tell JPEG export preferences to set properties to {export resolution:150, JPEG Quality:maximum, JPEG export range:export range, Page String:i}
	export document 1 format JPG to (export_path & "page" & page_number & ".jpg") without showing options
end repeat

set PDF_export_range to text 1 thru -2 of range_list

set original_PDF_export_prefs to properties of PDF export preferences
tell metadata preferences of document 1 to set document title to "download.pdf"

tell PDF export preferences
	set use security to true
	set disallow changing to true
	set disallow copying to true
	set disallow document assembly to true
	set disallow extraction for accessibility to true
	set disallow form fill in to true
	set disallow notes to true
	set disallow hi res printing to false
	set page range to PDF_export_range
end tell

export document 1 format PDF type to (export_path & "download.pdf") using PDF export preset "web_files" without showing options
set properties of PDF export preferences to original_PDF_export_prefs

end tell

tell application “Finder”
try
set Large_Folder to make new folder at (export_path as alias) with properties {name:“Large”}
on error
set Large_Folder to export_path & “Large” as alias
end try

set indd_jpeg_list to every file of (export_path as alias) whose name begins with "page" and name ends with ".jpg"
set target_length_large to 1403
set target_length_small to 584

repeat with this_indd_jpeg in indd_jpeg_list
	set original_name to name of this_indd_jpeg
	--set myoffset to offset of "_page" in original_name
	--set partname1 to text 1 thru myoffset in original_name as text
	--set partname2 to text myoffset thru (count of original_name) in original_name as text
	set the_small_path to export_path & original_name as string
	set the_large_path to (Large_Folder as string) & original_name as string
	tell application "Image Events"
		launch
		set this_image to open (this_indd_jpeg as alias)
		scale this_image to size target_length_large
		save this_image as JPEG in file the_large_path with icon
		scale this_image to size target_length_small
		save this_image as JPEG in file the_small_path with icon
		close this_image
	end tell
	--delete this_indd_jpeg
end repeat

end tell

tell application “Adobe InDesign CS5.5”
set the_query to display dialog “Would you like to upload your files now?” buttons {“No”, “Yes”} default button “Yes” with icon 1
if button returned of the_query is “Yes” then
set the_client to choose from list client_list
display dialog "Your files are about to be uploaded to " & the_client & return & “This may take some time so please be patient, I’ll let you know when I’m finished!” giving up after 180 with icon 1
else
display dialog “Export complete” with icon 1
tell application “Finder”
activate
open (export_path as alias)
end tell
end if
end tell

if button returned of the_query is “Yes” then
my upload_files(the_client, export_path)
tell application “Adobe InDesign CS5.5”
activate
display dialog “Upload Complete!” with icon 1
end tell
end if

on upload_files(the_client, export_path)
with timeout of 1800 seconds → try uploading for 30 minutes before giving up
try
do shell script “ncftpput -R -u ‘xxx’ -p xxxx clientnewsletter.com.au public_html/flash/” & (the_client as string) & space & quoted form of POSIX path of export_path
on error theError
display dialog “An error has occured uploading files!” & return & theError
error number -128
end try
end timeout
end upload_files

on create_Preset()
tell application “Adobe InDesign CS5.5”
tell PDF export preferences
set acrobat compatibility to acrobat 4
set color bitmap compression to auto compression
set color bitmap quality to maximum
set color bitmap sampling DPI to 150
set color bitmap sampling to bicubic downsample
set grayscale bitmap compression to auto compression
set grayscale bitmap quality to maximum
set grayscale bitmap sampling DPI to 72
set grayscale bitmap sampling to bicubic downsample
set monochrome bitmap compression to CCIT4
set monochrome bitmap sampling DPI to 72
set monochrome bitmap sampling to bicubic downsample
set Gray tile size to 128
–set threshold to compress color to 72
set threshold to compress gray to 72
set threshold to compress monochrome to 72
set compress text and line art to true
set color tile size to 128
set include slug with PDF to false
set OC Registry to “”
set output condition name to “”
set output condition to “”
set bleed bottom to 0.0
set bleed inside to 0.0
set bleed outside to 0.0
set bleed top to 0.0
set simulate overprint to false
set use document bleed with PDF to false
set PDF X profile to use no profile
set standards compliance to none
set bleed marks to false
set compression type to Compress Structure
set color bars to false
set crop marks to false
set PDF color space to unchanged color space
set applied flattener preset to flattener preset id 127 of application “Adobe InDesign CS5.5”
set generate thumbnails to false
set include ICC profiles to Include None
set crop images to frames to true
set ignore spread overrides to false
set include bookmarks to false
set include hyperlinks to false
set include structure to false
set export nonprinting objects to false
set omit bitmaps to false
set omit EPS to false
set omit PDF to false
set optimize PDF to true
set export layers to false
set export which layers to export visible printable layers
set page information marks to false
set PDF mark type to default
set printer mark weight to p25pt
set page marks offset to 2.116666666667
set export reader spreads to false
set registration marks to false
set subset fonts below to 100
set export guides and grids to false
end tell
make new PDF export preset with properties {name:“fagantest”}
end tell
end create_Preset

If I export direct from indesign it works as expected on my ipad, but using this script it won’t work. It’s blank and the is random gibberish in the header/title. Any ideas?

Hi. I haven’t evaluated your code at all, but it sounds like your problem could stem from the name’s length. If the exported name is overly long, the resultant PDF may be nonfunctional, split into two files, or be named with gibberish. Try naming the files with a short, arbitrary name and see if the issue persists.