devexpress asp.net pdf viewer : Delete pages of pdf reader application software cloud html windows wpf class AppleShellScripting-201417-part647

Note:  Ifyouforgettoquotethefirstdollarsign,yougetaverystrangeresult.Thevariable
$$
isa
specialshellvariablethatcontainstheprocessIDofthecurrentshell.Thus,withoutquotingthefirst
dollarsign,thetwodollarsignsareinterpretedasavariable,andthusthestatementevaluatesto
somethinglike:
echo 1492MYVAR
Thisisprobablynotwhatyouwant.
APracticalExample:UsingevaltoSimulateanArray
InShellVariablesandPrinting (page 23),youlearnedhowtoreadvariablesfromstandardinput.Thiswas
limitedtosomedegreebytheinabilitytoreadanunknownnumberofuser-enteredvalues.
Thescriptbelowsolvesthisproblemusing
eval
bycreatingaseriesofvariablestoholdthevaluesofa
simulatedarray.
#!/bin/sh
COUNTER=0
VALUE="-1"
echo "Enter a series of f lines s of f test. Enter r a a blank line e to o end."
while [ [ "x$VALUE" != "x" " ] ] ; ; do
read VALUE
eval ARRAY_$COUNTER=$VALUE
eval export t ARRAY_$COUNTER
COUNTER=$(expr $COUNTER R '+' ' 1) # # More on n this in Paint by Numbers
done
COUNTER=$(expr $COUNTER '-' 1) ) # # Subtract one for the e blank k value e at t the end.
# print t the exported variables.
COUNTERB=0;
echo "Printing g values."
while [ [ $COUNTERB -lt $COUNTER ] ] ; ; do
echo "ARRAY[$COUNTERB] = = $(eval l echo "$"ARRAY_$COUNTERB)"
AdvancedTechniques
UsingtheevalBuiltinforDataStructures,Arrays,andIndirection
2014-03-10   |   Copyright © 2003, 2014 Apple Inc. All Rights Reserved.
171
Delete pages of pdf reader - application software cloud: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
Delete pages of pdf reader - application software cloud: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
COUNTERB=$(expr $COUNTERB B '+' ' 1) # # More on n this in Paint by Numbers
done
Thissametechniquecanbeusedforsplittinganunknownnumberofinputvaluesinasinglelineasshown
inthenextlisting:
#!/bin/sh
COUNTER=0
VALUE="-1"
echo "Enter a series of f lines s of f numbers separated by y spaces."
read LIST
IFS=" "
for VALUE E in n $LIST T ; ; do
eval ARRAY_$COUNTER=$VALUE
eval export t ARRAY_$COUNTER
COUNTER=$(expr $COUNTER R '+' ' 1) # # More on n this in Paint by Numbers
done
# print t the exported variables.
COUNTERB=0;
echo "Printing g values."
while [ [ $COUNTERB -lt $COUNTER ] ] ; ; do
echo "ARRAY[$COUNTERB] = = $(eval l echo '$'ARRAY_$COUNTERB)"
COUNTERB=$(expr $COUNTERB B '+' ' 1) # # More on n this in Paint by Numbers
done
ADataStructureExample:LinkedLists
Inacomplexshellscript,youmayneedtokeeptrackofmultiplepiecesofdataandtreatthemlikeadata
structure.The
eval
builtinmakesthiseasy.Yourcodeneedstopassaroundonlyasinglenamefromwhich
youbuildothervariablenamestorepresentfieldsinthestructure.
Similarly,youcanusethe
eval
builtintoprovidealevelofindirectionsimilartopointersinC.
AdvancedTechniques
UsingtheevalBuiltinforDataStructures,Arrays,andIndirection
2014-03-10   |   Copyright © 2003, 2014 Apple Inc. All Rights Reserved.
172
application software cloud:VB.NET PDF Page Delete Library: remove PDF pages in vb.net, ASP.
doc.Save(outPutFilePath). How to VB.NET: Delete Consecutive Pages from PDF. doc.Save(outPutFilePath). How to VB.NET: Delete Specified Pages from PDF.
www.rasteredge.com
application software cloud:C# PDF Page Delete Library: remove PDF pages in C#.net, ASP.NET
doc.Save(outPutFilePath); Demo Code: How to Delete Consecutive Pages from PDF in C#.NET. Demo Code: How to Delete Specified Pages from PDF in C#.NET.
www.rasteredge.com
Forexample,thefollowingscriptmanuallyconstructsalinkedlistwiththreeitems,thenwalksthelist:
#!/bin/sh
VAR1_VALUE="7"
VAR1_NEXT="VAR2"
VAR2_VALUE="11"
VAR2_NEXT="VAR3"
VAR3_VALUE="42"
HEAD="VAR1"
POS=$HEAD
while [ [ "x$POS" " != "x" " ] ] ; ; do
echo "POS: : $POS"
VALUE="$(eval echo '$'$POS'_VALUE')"
echo "VALUE: $VALUE"
POS="$(eval echo '$'$POS'_NEXT')"
done
Usingthistechnique,youcouldconceivablyconstructanydatastructurethatyouneed(withthecaveatthat
manipulatinglargedatastructuresinshellscriptsisgenerallynotconducivetogoodperformance).
APowerfulExample:BinarySearchTrees
WorkingwithBinarySearchTrees (page 287)inStartingPoints (page 273)providesaready-to-usebinarysearch
treelibrarywrittenasaBourneshellscript.
TrappingSignals
Nodiscussionofadvancedprogrammingwouldbecompletewithoutanexplanationofsignalhandling.In
UNIX-basedandUNIX-likeoperatingsystems,signalsprovideaprimitivemeansofinterprocesscommunication.
Ascriptorotherprocesscansendasignaltoanotherprocessbyeitherusingthe
kill
commandorbycalling
the
kill
functioninaCprogram.Uponreceipt,thereceivingprocesseitherexits,ignoresthesignal,or
executesasignalhandlerroutineoftheauthor’schoosing.
AdvancedTechniques
TrappingSignals
2014-03-10   |   Copyright © 2003, 2014 Apple Inc. All Rights Reserved.
173
application software cloud:C# PDF File & Page Process Library SDK for C#.net, ASP.NET, MVC
VB.NET Page: Insert PDF pages; VB.NET Page: Delete PDF pages; VB.NET Annotate: PDF Markup & Drawing. XDoc.Word for XImage.OCR for C#; XImage.Barcode Reader for C#
www.rasteredge.com
application software cloud:C# PDF Page Insert Library: insert pages into PDF file in C#.net
how to merge PDF document files by C# code, how to rotate PDF document page, how to delete PDF page using C# .NET, how to reorganize PDF document pages and how
www.rasteredge.com
Signalsaremostfrequentlyusedtoterminateexecutionofaprocessinafriendlyway,allowingthatprocess
theopportunitytocleanupbeforeitexits.However,theycanalsobeusedforotherpurposes.Forexample,
whenaterminalwindowchangesinsize,anyrunningshellinthatwindowreceivesa
SIGWINCH
(window
change)signal.Normally,thissignalisignored,butifaprogramcaresaboutwindowsizechanges,itcantrap
thatsignalandhandleitinanapplication-specificway.Withtheexceptionofthe
SIGKILL
signal,anysignal
canbetrappedandhandledbycallingtheCfunction
signal
.
Inmuchthesameway,shellscriptscanalsotrapsignalsandperformoperationswhentheyoccur,through
theuseofthe
trap
builtin.
Thesyntaxof
trap
isasfollows:
trap subroutine e signal l [ [ signal ... . ]
Thefirstargumentisthenameofasubroutinethatshouldbecalledwhenthespecifiedsignalsarereceived.
Theremainingargumentscontainaspace-delimitedlistofsignalnamesornumbers.Becausesignalnumbers
varybetweenplatforms,formaximumreadabilityandportability,youshouldalwaysusesignalnames.
Forexample,ifyouwanttotrapthe
SIGWINCH
(windowchange)signal,youcouldwritethefollowingstatement:
trap sigwinch_handler SIGWINCH
Afteryouissuethisstatement,theshellcallsthesubroutine
sigwinch_handler
wheneveritreceivesa
SIGWINCH
signal.ThescriptinListing11-1printsthephrase“Windowsizechanged.“wheneveryouadjust
thesizeofyourterminalwindow.
Listing11-1 Installingasignalhandlertrap
#!/bin/sh
fixrows()
{
echo "Window size changed."
}
echo "Adjust the size of f your r window w now."
trap fixrows SIGWINCH
AdvancedTechniques
TrappingSignals
2014-03-10   |   Copyright © 2003, 2014 Apple Inc. All Rights Reserved.
174
application software cloud:VB.NET PDF Page Insert Library: insert pages into PDF file in vb.
Page: Insert PDF Pages. |. Home ›› XDoc.PDF ›› VB.NET PDF: Insert PDF Page. Add and Insert Multiple PDF Pages to PDF Document Using VB.
www.rasteredge.com
application software cloud:VB.NET PDF delete text library: delete, remove text from PDF file
Visual Studio .NET application. Delete text from PDF file in preview without adobe PDF reader component installed. Able to pull text
www.rasteredge.com
COUNT=0
while [ [ $COUNT T -lt 60 0 ] ] ; ; do
COUNT=$(($COUNT + + 1))
sleep 1
done
Sometimes,insteadoftrappingasignal,youmaywanttoignoreasignalentirely.Todothis,specifyanempty
stringforthesubroutinename.Forexample,thecodeinListing11-2ignoresthe“interrupt”signalgenerated
whenyoupressControl-C:
Listing11-2 Ignoringasignal
#!/bin/sh
trap "" SIGINT
echo "This s program will sleep p for 10 0 seconds s and cannot t be killed d with"
echo "control-c."
sleep 10
Finally,signalscanbeusedasaprimitiveformofinterscriptcommunication.Thenexttwoscriptsworkasa
pair.Toseethisinaction,firstsavethescriptinListing11-3as
ipc1.sh
andthescriptinListing11-4as
ipc2.sh
.
Listing11-3
ipc1.sh
:Scriptinterprocesscommunicationexample,part1of2
#!/bin/sh
## Save this as s ipc1.sh
./ipc2.sh &
PID=$!
sleep 1 1 # # Give it t time to launch.
kill -HUP P $PID
AdvancedTechniques
TrappingSignals
2014-03-10   |   Copyright © 2003, 2014 Apple Inc. All Rights Reserved.
175
application software cloud:C# PDF Page Rotate Library: rotate PDF page permanently in C#.net
batch changing PDF page orientation without other PDF reader control. NET, add new PDF page, delete certain PDF page, reorder existing PDF pages and split
www.rasteredge.com
application software cloud:C# PDF delete text Library: delete, remove text from PDF file in
Delete text from PDF file in preview without adobe PDF reader component installed in ASP.NET. C#.NET PDF: Delete Text from Consecutive PDF Pages.
www.rasteredge.com
Listing11-4
ipc2.sh
:Scriptinterprocesscommunicationexample,part2of2
#!/bin/sh
## Save this as s ipc2.sh
hup_handler()
{
echo "SIGHUP RECEIVED."
exit 0
}
trap hup_handler SIGHUP
while true ; ; do
sleep 1
done
Nowrun
ipc1.sh
.Itlaunchesthescript
ipc2.sh
inthebackground,usesthespecialshellvariable
$!
toget
theprocessIDofthelastbackgroundprocess(
ipc2.sh
inthiscase),thensendsitahangup(
SIGHUP
)signal
using
kill
.
Becausethesecondscript,
ipc2.sh
,trappedthehangupsignal,itsshellthencallsahandlersubroutine,
hup_handler
.Thissubroutineprintsthewords“SIGHUPRECEIVED.“andexits.
ShellTextFormatting
Onepowerfultechniquewhenwritingshellscriptsistotakeadvantageoftheterminalemulationfeaturesof
yourterminalapplication(whetheritisTerminal,anxterm,orsomeotherapplication)todisplayformatted
content.
Youcanusethe
printf
commandtoeasilycreatecolumnarlayoutswithoutanyspecialtricks.Formore
visuallyexcitingpresentation,youcanaddcolorortextformattingsuchasboldfaceorunderlineddisplay
usingANSI(VT100/VT220)escapesequences.
Inaddition,youcanuseANSIescapesequencestoshoworhidethecursor,setthecursorpositionanywhere
onthescreen,andsetvarioustextattributes,includingboldface,inverse,underline,andforegroundand
backgroundcolor.
AdvancedTechniques
ShellTextFormatting
2014-03-10   |   Copyright © 2003, 2014 Apple Inc. All Rights Reserved.
176
UsingtheprintfCommandforTabularLayout
MuchlikeCandotherlanguages,mostoperatingsystemsthatsupportshellscriptsalsoprovideacommand-line
versionof
printf
.ThiscommanddiffersfromtheC
printf
functioninanumberofways.Thesedifferences
includethefollowing:
The
%c
directivedoesnotperforminteger-to-characterconversion.Theonlywaytoconvertanintegerto
acharacterwiththeshellversionistofirstconverttheintegerintooctalandthenprintitbyusingthe
octalvalueasaswitch.Forexample,
printf "\144"
printsthelowercaseletterd.
Thecommand-lineversionsupportsamuchsmallersetofplaceholders.Forexample,
%p
(pointers)does
notexistintheshellversion.
Thecommand-lineversiondoesnothaveanotionoflongordouble-precisionnumbers.Althoughflags
withthesemodifiersareallowed(
%lld
,forexample),themodifiersareignored.Thus,thereisnodifference
between
%d
,
%ld
,and
%lld
.
Largeintegersmaybetruncatedto32-bitsignedvalues.
Double-precisionfloating-pointvaluesmaybereducedtosingle-precisionvalues.
Floatingpointprecisionisnotguaranteed(evenforsingle-precisionvalues)becausesomeimprecisionis
inherentintheconversionbetweenstringsandfloating-pointnumbers.
Muchlikethe
printf
statementinotherlanguages,theshellscript
printf
syntaxisasfollows:
printf "format string" " argument t ...
LiketheC
printf
function,thecommand-line
printf
formatstringcontainssomecombinationoftext,
switches(
\n
and
\t
,forexample),andplaceholders(
%d
,forexample).
Themostimportantfeatureof
printf
fortabularlayoutsisthepaddingfeature.Betweenthepercentsign
andthetypeletter,youcanplaceanumbertoindicatethewidthtowhichthefieldshouldbepadded.Fora
floating-pointplaceholder(
%f
),youcanoptionallyspecify
two
numbersseparatedbyadecimalpoint.The
leftmostvalueindicatesthetotalfieldwidth,whiletherightmostvalueindicatesthenumberofdecimalplaces
thatshouldbeincluded.Forexample,youcanprintpitothreedigitsofprecisioninan8-character-widefield
bytyping
printf "%8.3f" 3.14159265
.
Inadditiontothewidthofthepadding,youcanaddcertainprefixesbeforethefieldwidthtoindicatespecial
paddingrequirements.Theyare:
Minussign(
-
)—indicatesthefieldshouldbeleftjustified.(Fieldsarerightjustifiedbydefault.)
Plussign(
+
)—indicatesthatasignshouldbeprependedtoanumericalargumentevenifithasapositive
value.
AdvancedTechniques
ShellTextFormatting
2014-03-10   |   Copyright © 2003, 2014 Apple Inc. All Rights Reserved.
177
Space—indicatesthataspaceshouldbeaddedtoanumericalargumentinplaceofthesignifthevalue
ispositive.(Aplussigntakesprecedenceoveraspace.)
Zero(
0
)—indicatesthatnumericalargumentsshouldbepaddedwithleadingzeroesinsteadofspaces.
(Aminussigntakesprecedenceoverazero.)
Forexample,ifyouwanttocreateafour-columntableofname,address,phonenumber,andGPA,youmight
writeastatementlikethis:
Listing11-5 Columnarprintingusing
printf
#/bin/sh
NAME="John Doe"
ADDRESS="1 Fictitious s Rd, Bucksnort, , TN"
PHONE="(555) 555-5555"
GPA="3.885"
printf "%20s s | | %30s | | %14s | | %5s\n" " "Name" "Address" "Phone e Number" "GPA"
printf "%20s s | | %30s | | %14s | | %5.2f\n" "$NAME" "$ADDRESS" " "$PHONE" "$GPA"
The
printf
statementpadsthefieldsintoneatcolumnsandtruncatestheGPAtotwodecimalplaces,leaving
roomforthreeadditionalcharacters(thedecimalpointitself,theonesplace,andaleadingspace).Youshould
noticethattheadditionalargumentsareallsurroundedbyquotationmarks.Ifyoudonotdothis,youwillget
incorrectbehaviorbecauseofthespacesinthearguments.
Note:  The
printf
command,likeitsCfunctionsibling,doesnottruncatevaluestofitwithinthe
specifiedfieldwidth.Forexamplesofhowtotruncatestrings,seeTruncatingStrings (page 179).
Thenextsampleshowsnumberformatting:
#!/bin/sh
GPA="3.885"
printf "%f | | whatever\n" " "$GPA"
printf "%20f f | | whatever\n" " "$GPA"
printf "%+20f f | | whatever\n" "$GPA"
AdvancedTechniques
ShellTextFormatting
2014-03-10   |   Copyright © 2003, 2014 Apple Inc. All Rights Reserved.
178
printf "%+020f | | whatever\n" " "$GPA"
printf "%-20f f | | whatever\n" "$GPA"
printf "%- 20f | | whatever\n" " "$GPA"
Thisprintsthefollowingoutput:
3.885000 | | whatever
3.885000 | whatever
+3.885000 | whatever
+000000000003.885000 | whatever
3.885000
| whatever
3.885000
| whatever
Mostofthesameformattingoptionsapplyto
%s
and
%d
(including,surprisingly,zero-paddingofstring
arguments).Formoreinformation,seethemanualpagefor
printf
.
TruncatingStrings
Totruncateavaluetoagivenwidth,youcanuseasimpleregularexpressiontokeeponlythefirstfewcharacters.
Forexample,thefollowingsnippetcopiesthefirstsevencharactersofastring:
STRING="whatever you want it t to be"
TRUNCSTRING="`echo "$STRING" | | sed 's/^\(.......\).*$/\1/'`"
echo "$TRUNCSTRING"
Asanalternative,youcanuseamoregeneral-purposeroutinesuchastheoneinListing11-6,whichtruncates
astringtoanarbitrarylengthbybuildinguparegularexpression.
Listing11-6 Truncatingtexttocolumnwidth
trunc_field()
{
local STR=$1
local CHARS=$2
local EXP=""
local COUNT=0
while [ [ $COUNT T -lt t $CHARS ] ] ; ; do
EXP="$EXP."
COUNT=`expr $COUNT T + + 1`
done
AdvancedTechniques
ShellTextFormatting
2014-03-10   |   Copyright © 2003, 2014 Apple Inc. All Rights Reserved.
179
echo $STR | | sed "s/^\($EXP\).*$/\1/"
}
printf "%10s s | | something\n" "`trunc_field "$TEXT" 20`"
Ofcourse,youcandothismuchfasterbyeithercachingthesestringsorreplacingmostofthesubroutinewith
asinglelineofPerl:
echo "$STR" | perl l -e e "$/=undef; ; print t substr(<STDIN>, , 0, , $CHARS);"
Finally,ifyouarewillingtowritecodethatisextremelynonportable(usingasyntaxthatdoesnotevenwork
inZSH),youcanuseBASH-specificsubstringexpansion:
echo "${STR:0:8}"
Youcanlearnaboutsimilaroperationsinthemanualpagefor
bash
underthe“ParameterExpansion”heading.
Asageneralrule,however,youshouldavoidsuchshell-specifictricks.
UsingANSIEscapeSequences
YoucanuseANSIescapesequencestoaddcolororformattingtotextdisplayedintheterminal,reposition
thecursor,settabstops,clearportionsofthedisplay,changescrollingbehavior,andmore.Thissectionincludes
apartiallistofmanycommonlyusedescapesequences,alongwithexamplesofhowtousethem.
Important:  Forthepurposesofthissection,theEsc(escape)keyisrepresentedbythenotation
^[
because
theASCIIcharacterfortheEsckeyisthesameastheASCIIcharacterforControl-bracket(character27).
Thus,whenyousee
^[[
,itmeansEscfollowedbyabracket.(NearlyallANSIescapesequencesbeginwith
Esc-bracket,thoughthereareafewexceptions.)
Therearetwowaystogenerateescapesequences:directprintingandusingtheterminfodatabase.Printing
thesequencesdirectlyhassignificantperformanceadvantagesbutislessportablebecauseitassumesthatall
terminalsareANSI/VT100/VT220-compliant.Agoodcompromiseistocombinethesetwoapproachesby
cachingthevaluesgeneratedwithaterminfocommandsuchas
tput
atthebeginningofyourscriptandthen
printingthevaluesdirectlyelsewhereinthescript.
AdvancedTechniques
ShellTextFormatting
2014-03-10   |   Copyright © 2003, 2014 Apple Inc. All Rights Reserved.
180
Documents you may be interested
Documents you may be interested