devexpress asp.net pdf viewer : Add or remove pages from pdf SDK Library service wpf .net asp.net dnn AppleShellScripting-201420-part657

echo "Done."
ThisexamplepassesajobnumberorprocessIDargumenttothe
jobs
builtintotellitwhichjobyouwantto
findoutinformationabout.Jobnumbersbeginwithapercent(%)signandarenormallyfollowedbyanumber.
Inthecase,however,asecondpercentsignisused.The
%%
jobisoneofanumberofspecialjob“numbers”
thattheshellprovides.Ittellsthe
jobs
builtintooutputinformationaboutthelastcommandthatwasexecuted
inthebackground.Theresultofthis
jobs
commandisastatusstringliketheoneshownearlier.Thisstringis
passedasaseriesofargumentstothe
jobidfromstring
subroutine,whichthenprintsthejobIDbyitself.
Theoutputofthissubroutine,inturn,isstoredintoeitherthevariable
DP3
or
DP7
.
ThisexamplealsodemonstrateshowtowaitforajobbasedonprocessIDusingaspecialshellvariable,
$!
,
whichcontainstheprocessIDofthelastcommandexecuted.Thisvalueisstoredintothevariable
DP5
.Process
IDsaregenerallypreferredoverjobIDswhenusingthe
jobs
commandinscripts(asopposedtohand-entered
useofthe
jobs
command).
Finally,thescriptendswithaseriesofcallstothe
wait
builtin.Thesecommandstelltheshelltowaitfora
childprocesstoexit.Whenachildprocessexits,theshellreapstheprocess,storesitsexitstatusinthe
$?
variable,andreturnscontroltothescript..
Likethe
jobs
command,the
wait
builtincantakeajobIDorprocessID.IfyouspecifyajoborprocessID,
theshelldoesnotreturncontroltothescriptuntilthespecifiedjoborprocessexits.IfnoprocessorjobIDis
specified,the
wait
builtinreturnsassoonasthefirstchildexits.
AjobIDconsistsofapercentsignfollowedbythejobnumber(obtainedfromeitherthevariable
DP3
or
DP7
).
AprocessIDisjustthenumberitself.
C Shell Note:  TheCshelldoesnotallowyoutoquerythelastjoborwaitforasinglejoborprocess
ID.Youcan,however,waitforalloutstandingjobstofinishbyrunningthe
wait
builtinwithno
arguments.
Thefinalexampleshowshowtoexecutealimitednumberofconcurrentjobsinwhichtheorderofjob
completionisnotimportant.
#!/bin/bash
MAXJOBS=3
spawnjob()
AdvancedTechniques
BackgroundJobsandJobControl
2014-03-10   |   Copyright © 2003, 2014 Apple Inc. All Rights Reserved.
201
Add or remove pages from pdf - SDK Library service:C# PDF Page Extract Library: copy, paste, cut PDF pages in C#.net, ASP.NET, MVC, Ajax, WinForms, WPF
Easy to Use C# Code to Extract PDF Pages, Copy Pages from One PDF File and Paste into Others
www.rasteredge.com
Add or remove pages from pdf - SDK Library service:VB.NET PDF Page Extract Library: copy, paste, cut PDF pages in vb.net, ASP.NET, MVC, Ajax, WinForms, WPF
Detailed VB.NET Guide for Extracting Pages from Microsoft PDF Doc
www.rasteredge.com
{
echo $1 | bash
}
clearToSpawn()
{
local JOBCOUNT="$(jobs -r | grep -c .)"
if [ $JOBCOUNT -lt $MAXJOBS ] ; then
echo 1;
return 1;
fi
echo 0;
return 0;
}
JOBLIST=""
COMMANDLIST='ls
echo "sleep 3"; sleep 3; echo "sleep 3 done"
echo "sleep 10"; sleep 10 ; echo "sleep 10 done"
echo "sleep 1"; sleep 1; echo "sleep 1 done"
echo "sleep 5"; sleep 5; echo "sleep 5 done"
echo "sleep 7"; sleep 7; echo "sleep 7 done"
echo "sleep 2"; sleep 2; echo "sleep 2 done"
'
IFS="
"
for COMMAND in $COMMANDLIST ; do
while [ `clearToSpawn` -ne 1 ] ; do
sleep 1
done
AdvancedTechniques
BackgroundJobsandJobControl
2014-03-10   |   Copyright © 2003, 2014 Apple Inc. All Rights Reserved.
202
SDK Library service:VB.NET PDF Password Library: add, remove, edit PDF file password
manipulations. Open password protected PDF. Add password to PDF. Change PDF original password. Remove password from PDF. Set PDF security level. VB
www.rasteredge.com
SDK Library service:VB.NET PDF Page Delete Library: remove PDF pages in vb.net, ASP.
can simply delete a single page from a PDF document using VB.NET or remove any page Add necessary references: How to VB.NET: Delete Consecutive Pages from PDF.
www.rasteredge.com
spawnjob $COMMAND &
LASTJOB=$!
JOBLIST="$JOBLIST $LASTJOB"
done
IFS=" "
for JOB in $JOBLIST ; do
wait $JOB
echo "Job $JOB exited with status $?"
done
echo "Done."
Mostofthecodehereisstraightforward.Itisworthnoting,however,thatinthesubroutine
clearToSpawn
,
the
-r
flagmustbepassedtothe
jobs
builtintorestrictoutputtocurrentlyrunningjobs.Withoutthisflag,
the
jobs
builtinwouldotherwisereturnalistthatincludedcompletedjobs,thusmakingthecountofrunning
jobsincorrect.
Warning:  Whileitistemptingtoputthewhileloopinsidethe
clearToSpawn
subroutine,ifyoudo
so,theprogramwillwaitforever.Thestatusofjobsdoesnotgetupdatedbytheshelluntilscript
executionreturnstothemainbodyoftheprogram.
The
-c
flagto
grep
causesittoreturnthenumberofmatchinglinesratherthanthelinesthemselves,andthe
periodcausesittomatchonanynonblanklines(thosecontainingatleastonecharacter).Thus,the
JOBCOUNT
variablecontainsthenumberofcurrentlyrunningjobs,whichis,inturn,comparedtothevalue
MAXJOBS
to
determinewhetheritisappropriatetostartanotherjobornot.
AdvancedTechniques
BackgroundJobsandJobControl
2014-03-10   |   Copyright © 2003, 2014 Apple Inc. All Rights Reserved.
203
SDK Library service:C# PDF Page Delete Library: remove PDF pages in C#.net, ASP.NET
Ability to remove a range of pages from PDF file. Add necessary references: Demo Code: How to Delete Consecutive Pages from PDF in C#.NET.
www.rasteredge.com
SDK Library service:C# PDF Password Library: add, remove, edit PDF file password in C#
String outputFilePath = Program.RootPath + "\\" Output.pdf"; // Remove the password. doc.Save(outputFilePath); C# Sample Code: Add Password to Plain PDF
www.rasteredge.com
C Shell Note:  ACshellversionofthisscriptisincludedintheaccompanyingCompanionFiles
download.Toobtainthisarchive,seethewebversionofthisdocumentathttp://developer.apple.com/.
Application Scripting Withosascript
OSXprovidesapowerfulapplicationscriptingenvironmentcalledAppleScript.WithAppleScript,youcan
launchanapplication,tellarunningapplicationtoperformvarioustasks,queryarunningapplicationinvarious
ways,andsoon.Shellscriptprogrammerscanharnessthispowerthroughthe
osascript
tool.
Note:  Althoughthissectiondescribesuseof
osascript
forexecutingAppleScriptforapplication
scripting,the
osascript
toolprovidesacommand-lineinterfacetoanyscriptinglanguagewith
aninterpreterthatconformstotheOpenScriptingArchitecture(OSA).Forexample,ifyouinstall
thethird-partyJavaScriptOSAfreewarepackage,youcanuse
osascript
toexecuteJavaScript
code.
The
osascript
toolexecutesaprograminthespecifiedlanguageandprintstheresultsviastandardoutput.
Ifnoprogramfileisspecified,itreadstheprogramfromstandardinput.
Thefirstexampleisfairlystraightforward.Itopensthefile
poem.txt
inthedirectoryabovethedirectorywhere
thescriptislocated:
Listing
11-11
OpeningafileusingAppleScriptandosascript:07_osascript_simple.sh
#!/bin/sh
POEM="$PWD/../poem.txt"
cat << EOF | osascript -l AppleScript
launch application "TextEdit"
tell application "TextEdit"
open "$POEM"
end tell
EOF
AdvancedTechniques
ApplicationScriptingWithosascript
2014-03-10   |   Copyright © 2003, 2014 Apple Inc. All Rights Reserved.
204
SDK Library service:C# PDF Digital Signature Library: add, remove, update PDF digital
Image: Insert Image to PDF. Image: Remove Image from Redact Text Content. Redact Images. Redact Pages. Annotation & Highlight Text. Add Text. Add Text Box. Drawing
www.rasteredge.com
SDK Library service:C# PDF remove image library: remove, delete images from PDF in C#.
Image: Insert Image to PDF. Image: Remove Image from Redact Text Content. Redact Images. Redact Pages. Annotation & Highlight Text. Add Text. Add Text Box. Drawing
www.rasteredge.com
Youshouldnoticethatthepathtothefile
poem.txt
isspecifiedasanabsolutepathhere.Thisiscrucialwhen
workingwith
osascript
.Becausethecurrentworkingdirectoryofalaunchedapplicationisalwaystheroot
ofthefilesystem(the
/
directory)ratherthantheshellscript’sworkingdirectory,ascriptmustpassanabsolute
pathtoAppleScriptratherthanapathrelativetothescript’sworkingdirectory.
Thenextexampleshowshowtoqueryanapplication.Inthiscase,itlaunchesTextEdit,openstwofiles,asks
TextEditforalistofopendocuments,andusesthatlisttohelpitaskTextEdittoreturnthefirstparagraphof
textinthedocumentthatcorrespondswiththe
poem.txt
file.
Listing
11-12
WorkingwithafileusingAppleScriptandosascript:08_osascript_para.sh
#!/bin/sh
# Get an absolute path for the poem.txt file.
POEM="$PWD/../poem.txt"
# Get an absolute path for the script file.
SCRIPT="$(which $0)"
if [ "x$(echo $SCRIPT | grep '^\/')" = "x" ] ; then
SCRIPT="$PWD/$SCRIPT"
fi
# Launch TextEdit and open both the poem and script files.
cat << EOF | osascript -l AppleScript > /dev/null
launch application "TextEdit"
tell application "TextEdit"
open "$POEM"
end tell
set myDocument to result
return number of myDocument
EOF
cat << EOF | osascript -l AppleScript > /dev/null
launch application "TextEdit"
tell application "TextEdit"
open "$SCRIPT"
AdvancedTechniques
ApplicationScriptingWithosascript
2014-03-10   |   Copyright © 2003, 2014 Apple Inc. All Rights Reserved.
205
SDK Library service:C# PDF bookmark Library: add, remove, update PDF bookmarks in C#.
Help to add or insert bookmark and outline into PDF file in .NET framework. Ability to remove and delete bookmark and outline from PDF document.
www.rasteredge.com
SDK Library service:C# PDF metadata Library: add, remove, update PDF metadata in C#.
Add metadata to PDF document in C# .NET framework program. Remove and delete metadata from PDF file. Also a PDF metadata extraction control.
www.rasteredge.com
end tell
set myDocument to result
return number of myDocument
EOF
# Tell the shell not to mangle newline characters, tabs, or whitespace.
IFS=""
# Ask TextEdit for a list of open documents.
From this, we can
# obtain a document number that corresponds with the poem.txt file.
# This query returns a newline-deliminted list of open files. Each
# line contains the file number, followed by a tab, followed by the
# filename
DOCUMENTS="$(cat << EOF | osascript -l AppleScript
tell application "TextEdit"
documents
end tell
set myList to result
-- Store the result of "documents" message into
variable "myList"
set myCount to count myList -- Store the number of items in myList into myCount
set myRet to ""
-- Create an empty string variable called "myRet"
(* Loop through the myList array and build up a string in the myRet variable
containing one line per entry in the form:
number tab_character name
*)
repeat with myPos from 1 to myCount
set myRet to myRet & myPos & "\t" & name of item myPos of myList & "\n"
end repeat
return myRet
AdvancedTechniques
ApplicationScriptingWithosascript
2014-03-10   |   Copyright © 2003, 2014 Apple Inc. All Rights Reserved.
206
SDK Library service:VB.NET PDF remove image library: remove, delete images from PDF in
Image: Insert Image to PDF. Image: Remove Image from Redact Text Content. Redact Images. Redact Pages. Annotation & Highlight Text. Add Text. Add Text Box. Drawing
www.rasteredge.com
SDK Library service:VB.NET PDF metadata library: add, remove, update PDF metadata in
Add permanent metadata to PDF document in VB .NET framework program. Remove and delete metadata content from PDF file in Visual Basic .NET application.
www.rasteredge.com
EOF
)"
# Determine the document number that corresponds with the poem.txt
# file.
DOCNUMBER="$(echo $DOCUMENTS | grep '[[:space:]]poem\.txt' | grep -v ' poem\.txt'
| head -n 1 | sed 's/\([0-9][0-9]*.\).*/\1/')"
SECOND_DOCNUMBER="$(echo $DOCUMENTS | grep '[[:space:]]poem\.txt' | grep -v '
poem\.txt' | tail -n 1 | sed 's/\([0-9][0-9]*.\).*/\1/')"
if [ $DOCNUMBER -ne $SECOND_DOCNUMBER ] ; then
echo "WARNING: You have more than one file named poem.txt open.
Using the"
1>&2
echo "most recently opened file." 1>&2
echo "DOCNUMBER $DOCNUMBER != $SECOND_DOCNUMBER"
fi
echo "DOCNUMBER: $DOCNUMBER"
if [ "x$DOCNUMBER" != "x" ] ; then
# Query poem.txt by number
FIRSTPARAGRAPH="$(cat << EOF | osascript -l AppleScript
tell application "TextEdit"
paragraph 1 of document $DOCNUMBER
end tell
EOF
)"
echo "The first paragraph of poem.txt is:"
echo "$FIRSTPARAGRAPH"
fi
# Query poem.txt by name
FIRSTPARAGRAPH="$(cat << EOF | osascript -l AppleScript
tell application "TextEdit"
paragraph 1 of document "poem.txt"
end tell
AdvancedTechniques
ApplicationScriptingWithosascript
2014-03-10   |   Copyright © 2003, 2014 Apple Inc. All Rights Reserved.
207
EOF
)"
echo "The first paragraph of poem.txt is:"
echo "$FIRSTPARAGRAPH"
Thisscriptillustratesthreeveryimportantconcepts.
Itshowshowtorefertoadocumentbynumberandhowtoiteratethroughalistofdocuments,associating
thenamewithaparticulardocumentnumber.
ItdemonstratesalimitationinAppleScript—specifically,thatyoucannotalwaysuniquelyidentifya
particulardocumentwithagivennameiftwoopenfileshavethesamename.Whenwritingscripts,you
shouldcarefullyavoidopeningtwofileswiththesamenameusingthesameapplication.
Itdemonstrateshowtoreferenceadocumentbyitsname.Theresultsfromthe
documents
messageare
transient;documentnumberschangeasnewwindowsareopenedandoldwindowsareclosed.Thus,you
shouldgenerallyaddressdocumentsusingtheirnamesratherthanusingdocumentnumbersunlessyou
areverycareful.
ThefinalexampleshowshowtomanipulateimagesusingshellscriptsandAppleScript.Itscalestheimageto
beascloseto320x480or480x320(dependingontheorientationoftheimage)aspossible.
Listing
11-13
ResizinganimageusingImageEventsandosascript:09_osascript_images.sh
#!/bin/sh
# Get an absolute path for the poem.txt file.
MAXLONG=480
MAXSHORT=320
URL="http://images.apple.com/macpro/images/design_smartdesign_hero20080108.png"
FILE="$PWD/my design_smartdesign_hero20080108.png"
OUTFILE="$PWD/my design_smartdesign_hero20080108-mini.png"
if [ ! -f "$FILE" ] ; then
curl "$URL" > "$FILE"
fi
AdvancedTechniques
ApplicationScriptingWithosascript
2014-03-10   |   Copyright © 2003, 2014 Apple Inc. All Rights Reserved.
208
# Tell the shell not to mangle newline characters, tabs, or whitespace.
IFS=""
# Obtain image information
DIM="$(cat << EOF | osascript -l AppleScript
tell application "Image Events"
launch
set this_image to open "$FILE"
copy dimensions of this_image to {W, H}
close this_image
end tell
return W & H
EOF
)"
W="$(echo "$DIM" | sed 's/ *, *.*//' )"
H="$(echo "$DIM" | sed 's/.* *, *//' )"
echo WIDTH: $W HEIGHT: $H
if [ $W -gt $H ] ; then
LONG=$W
SHORT=$H
else
LONG=$H
SHORT=$W
fi
# echo "LONG: $LONG SHORT: $SHORT"
# echo "MAXLONG: $MAXLONG MAXSHORT: $MAXSHORT"
NEWLONG=$LONG
NEWSHORT=$SHORT
# NEWSCALE=1
AdvancedTechniques
ApplicationScriptingWithosascript
2014-03-10   |   Copyright © 2003, 2014 Apple Inc. All Rights Reserved.
209
if [ $NEWLONG -gt $MAXLONG ] ; then
# Long direction is too big.
NEWLONG="$(echo "scale=20; $LONG * ($MAXLONG/$LONG)" | bc | sed 's/\..*//')";
NEWSHORT="$(echo "scale=20; $SHORT * ($MAXLONG/$LONG)" | bc | sed 's/\..*//')";
NEWSCALE="$(echo "scale=20; ($MAXLONG/$LONG)" | bc)";
fi
# echo "PART 1: NEWLONG: $NEWLONG NEWSHORT: $NEWSHORT"
if [ $NEWSHORT -gt $MAXSHORT ] ; then
# Short direction is till too big.
NEWLONG="$(echo "scale=20; $LONG * ($MAXSHORT/$SHORT)" | bc | sed 's/\..*//')";
NEWSHORT="$(echo "scale=20; $SHORT * ($MAXSHORT/$SHORT)" | bc | sed 's/\..*//')";
NEWSCALE="$(echo "scale=20; ($MAXSHORT/$SHORT)" | bc)";
fi
# echo "PART 2: NEWLONG: $NEWLONG NEWSHORT: $NEWSHORT"
if [ $W -gt $H ] ; then
NEWWIDTH=$NEWLONG
NEWHEIGHT=$NEWSHORT
else
NEWHEIGHT=$NEWLONG
NEWWIDTH=$NEWSHORT
fi
echo "DESIRED WIDTH: $NEWWIDTH NEW HEIGHT: $NEWHEIGHT (SCALE IS $NEWSCALE)"
cp "$FILE" "$OUTFILE"
DIM="$(cat << EOF | osascript -l AppleScript
tell application "Image Events"
launch
AdvancedTechniques
ApplicationScriptingWithosascript
2014-03-10   |   Copyright © 2003, 2014 Apple Inc. All Rights Reserved.
210
Documents you may be interested
Documents you may be interested