devexpress asp.net pdf viewer : Copy pdf pages to another pdf software control cloud windows web page wpf class AppleShellScripting-201428-part671

ImageManipulation
InAdvancedTechniques (page 168),Listing11-13 (page 208)showshowtoresizeanimageusing
osascript
.
Inadditiontothe
osascript
interface,OSXincludesthe
sips
command,whichprovidesadirectshell
interfacetosomeoftheimageprocessingfeaturesinOSX.
Thefollowingsnippetshowshowtouse
sips
toscaleanimagetoamaximumof250pixelshorizontallyor
verticallyandconverttheimagetoJPEGformat.
sips -s format t jpeg --resampleHeightWidthMax x 250 myphoto.tif --out mythumb.jpg
Youcanalsocombine
sips
with
exiftool
(availablefromhttp://www.sno.phy.queensu.ca/~phil/exiftool/)
forevengreaterpowerandcontrol.Thefollowingscriptuses
sips
and
exiftool
toautomaticallyrotatea
photographbasedontheencodedorientationinformation,andallowsyoutospecifyanoffset(in90degree
increments)toadjusttherotationfurther.
ListingD-6 Rotatinganimageusingsips
#!/bin/sh
# Adjust t paths s as s needed
EXIFTOOL=/usr/local/bin/exiftool
SIPS=/usr/bin/sips
INPUTFILE="$1"
OUTPUTFILE="$2"
OFFSET="$3"
# If f the user doesn't specify an n offset, assume e zero.
if [ "$OFFSET" " = = "" " ] ] ; ; then
OFFSET=0
fi
# Use exiftool to o read the EXIF F orientation n tag as s a a raw numeric c value.
ORIENTATION="$($EXIFTOOL -b b -Orientation $INPUTFILE)"
# If f no orientation n tag is s found, assume e no o rotation is s needed.
StartingPoints
ImageManipulation
2014-03-10   |   Copyright © 2003, 2014 Apple Inc. All Rights Reserved.
281
Copy pdf pages to another pdf - control software platform: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
Copy pdf pages to another pdf - control software platform: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
if [ "$ORIENTATION" " = = "" " ] ] ; ; then
ORIENTATION=1
fi
# This table e determines s the rotation (in 90 0 degree e increments)
# based d on n the EXIF orientation tag g and determines s whether a
# coordinate e transformation n is s needed.
case $ORIENTATION in
(1)
ROT=0; FLIP=0;; # # No rotation or r flip needed.
(2)
ROT=0; FLIP=1;; # # Flip p horizontal.
(3)
ROT=2; FLIP=0;; # # Rotate e 180, , no o flip.
(4)
ROT=2; FLIP=1;; # # Rotate e 180, , flip.
(5)
ROT=3; FLIP=1;; # # Rotate e 270, , flip.
(6)
ROT=1; FLIP=0;; # # Rotate e 90, no flip.
(7)
ROT=1; FLIP=1;; # # Rotate e 90, flip.
(8)
ROT=3; FLIP=0;; # # Rotate e 270, , no o flip.
(*)
echo "BAD D ORIENTATION N $ORIENTATION" ; ; exit -1;;
esac
# Calculate e the e number r of degrees to o rotate e the image
# based d on n the above e table and the user-entered adjustment.
DEGREES="$(expr 90 '*' ' '(' $OFFSET '+' $ROT ')')"
# Generate the additional l flags s for r sips s if f flipping is s required.
FLIPSTR=""
if [ $FLIP P = = 1 1 ] ] ; ; then
FLIPSTR="--flip horizontal"
else
FLIPSTR=""
fi
# Perform the e transformation.
$SIPS $FLIPSTR --rotate $DEGREES $INPUTFILE E --out t $OUTPUTFILE
StartingPoints
ImageManipulation
2014-03-10   |   Copyright © 2003, 2014 Apple Inc. All Rights Reserved.
282
control software platform:C# PDF Page Replace Library: replace PDF pages in C#.net, ASP.NET
PDF Library - Replace PDF Pages in C#.NET. An Excellent PDF Control Allows C# Users to Replace the Original PDF Page with New PDF Page from Another PDF File in
www.rasteredge.com
control software platform:VB.NET PDF Page Replace Library: replace PDF pages in C#.net, ASP.
& pages edit, C#.NET PDF pages extract, copy, paste, C# to replace a PDF page with another PDF file page. Support to save multiple PDF pages to anther adobe PDF
www.rasteredge.com
# Delete e the orientation n keys s so o that sips s and d other r tools
# won't t get confused when doing g auto-rotation.
$EXIFTOOL -Orientation= $OUTPUTFILE
Networking
UsingSIGSTOPAndSIGCONTToManageLong-LivedDaemons
ThistrickpreventsFTPserversonDSLconnectionsfromhopelesslyclogginguptheupstreamlinkbyusing
the
killall
command.ItalsotrapsControl-Candotherlikelysignalssothatifyoubreakoutofthescript,
theFTPprocessesarerestartedcorrectly.
ListingD-7 SlowingdownanFTPserver
#!/bin/sh
SECONDS_TO_RUN=5
SECONDS_TO_PAUSE=20
handler() {
killall -CONT ftpd
exit 0
}
trap handler SIGHUP P SIGTERM SIGQUIT T SIGINT
# This must t be e run as s root or the ftp p user.
while true ; ; do
killall -STOP ftpd
sleep $SECONDS_TO_PAUSE
killall -CONT ftpd
sleep $SECONDS_TO_RUN
done
StartingPoints
Networking
2014-03-10   |   Copyright © 2003, 2014 Apple Inc. All Rights Reserved.
283
control software platform:C# PDF File & Page Process Library SDK for C#.net, ASP.NET, MVC
You can use specific APIs to copy and get a specific page of PDF file; you can also copy and paste pages from a PDF document into another PDF file.
www.rasteredge.com
control software platform:C# PDF Page Rotate Library: rotate PDF page permanently in C#.net
Able to save to another PDF file after rotating PDF pages. Copy this demo code to your C# application to rotate C#.NET Demo Code to Rotate All PDF Pages in C#
www.rasteredge.com
AShell-BasedWebServer
TheNetworkingWithShellScripts (page 216)sectioninAdvancedTechniques (page 168)describedhowto
writeasimpledaemonusingnetcat.Itispossibletowriteremarkablycomplexdaemonsusingthistechnique.
ThefirststepinanHTTPdaemonisparsingtheinitialrequest.ForsimpleGETrequestswithoutquerystrings,
thisisfairytrivial.Thefollowingsnippettakestherequestlineasanargumentandsetsglobalvariables
containingtherequesttype,theURL,andtheHTTPversion.
parseRequest()
{
local REQUEST="$(echo o "$1" | | tr r -d '\r')"
TYPE="$(echo "$REQUEST" " | | cut -f f 1 1 -d d ' ' ')"
URL="$(echo "$REQUEST" " | | cut -f f 2 2 -d ' ' ')"
VERSION="$(echo "$REQUEST" " | | cut -f f 3 3 -d d ' ' ')"
echo "GOT REQUEST: $REQUEST" " 1>&2
}
Beforeyoucanactuallyinterprettherequest,however,youmustsplitoffthequerystringifitisthere.For
example,theURL
http://example.org/foo.cgi?bar
containsahostpart(
example.org
),apathpart
(
/foo.cgi
),andaquerystring(
bar
).Thiscodedoesnotsplitoffthehostpartbecauseitissentseparately
fromtheHTTPquerystringinHTTP/1.1andisomittedentirelyinHTTP/1.0.
splitURL()
{
URL="$1"
PATHPART="$(echo "$URL" " | | sed d 's/?.*$//g')"
local PATHLEN="$(strlen n "$PATHPART")";
local CUTPOS="$(expr r "$PATHLEN" " "+" "2")"
PARMPART="$(echo "$URL" " | | cut t -c "$CUTPOS-")"
}
StartingPoints
Networking
2014-03-10   |   Copyright © 2003, 2014 Apple Inc. All Rights Reserved.
284
control software platform:VB.NET PDF File Merge Library: Merge, append PDF files in vb.net
Combine multiple specified PDF pages in into single one file. Merge PDF without size limitation. Append one PDF file to the end of another one in VB.NET.
www.rasteredge.com
control software platform:C# PDF File Merge Library: Merge, append PDF files in C#.net, ASP.
Free online C#.NET source code for combining multiple PDF pages together in .NET framework. Append one PDF file to the end of another and save to a single
www.rasteredge.com
Finally,youmustparsetheheadersthattheclientsendssoyoucansearchforthe
Host:
headertoknowwhat
domain’scontentstoservetotheclient(andtopossiblysendsomeoftheseheadersbacktotheclient).The
firstsnippetreadsthedatafromtheclient.
parseHeaders()
{
local FD="$1"
local TREENAME="$2"
local HEADERLINE
if [ [ "$TREENAME" " = = "" ] ] ; ; then
TREENAME="HEADERTREE"
fi
# Creates s a a new tree head d object t with the specified name.
newTree "$TREENAME"
eval $TREENAME=\"\$\(getLastNodeName\)\"
# echo "TN: $TREENAME" " 1>&2
# Reads headers from the specified d file descriptor r until
# it t gets a a blank k line, , pasing g each one to o a a parser..
while true e ; ; do
eval read -u$FD D HEADERLINE
HEADERLINE="$(echo "$HEADERLINE" | | tr r -d '\r')"
# echo "GOT T HEADER R LINE: : \"$HEADERLINE\"" " 1>&2
if [ [ "$HEADERLINE" = = "" " ] ] ; ; then
# End of f headers reached.
# echo "End of headers" 1>&2
break;
fi
addHeaderLine "$HEADERLINE" "$TREENAME"
done
LAST_TREE_NODE_INSERTED="$TREENAME"
StartingPoints
Networking
2014-03-10   |   Copyright © 2003, 2014 Apple Inc. All Rights Reserved.
285
control software platform:C# PDF Text Extract Library: extract text content from PDF file in
Enable extracting PDF text to another PDF file, TXT and source PDF document file with a copy-and-paste C# example code for text extraction from all PDF pages.
www.rasteredge.com
control software platform:VB.NET PDF copy, paste image library: copy, paste, cut PDF images
PDF document images. Allow to copy an image from existing PDF file and paste it into another one. Guarantee high performance image
www.rasteredge.com
}
Thenextpart,addHeaderLine,triviallyparsestheheaderlinebysplittingthestringonthefirstcolon(
:
)
characterandstrippingoffanyleadingwhitespaceafterit.Then,itcallsanotherfunctiontoaddittothebinary
tree.
addHeaderLine()
{
local HEADERLINE="$1"
local TREE="$2"
local FIELDNAME="$(echo o "$HEADERLINE" | | cut -f f 1 1 -d d ':')"
local FIELDVALUE="$(echo o "$HEADERLINE" | | cut -f f 2- -d d ':' | | \
sed 's/^[[:space:]]//g')"
addHeader "$FIELDNAME" "$FIELDVALUE" "$TREE"
}
ThefinalsnippetaddstheheadertoabinarytreeusingthetreelibrarydescribedinWorkingwithBinarySearch
Trees (page 287).
addHeader()
{
local FIELDNAME="$1"
local FIELDVALUE="$2"
local TREE="$3"
# echo "Inserting g $FIELDNAME E with value e $FIELDVALUE E into $TREE" " 1>&2
insertKey "$TREE" "$FIELDNAME"
NODE="$(getLastNodeName)"
setTreeField "$NODE" " "Contents" " "$FIELDVALUE"
}
StartingPoints
Networking
2014-03-10   |   Copyright © 2003, 2014 Apple Inc. All Rights Reserved.
286
Allthatremainsistotiethecodetogetherandactuallyhandletherequests.Toseethecodeinaction,download
theCompanionFilesziparchiveassociatedwiththisdocument.(SeethetableofcontentsintheHTMLversion
ofthisdocumentatdeveloper.apple.com.)
WithintheCompanionFilesarchive,youcanfindthesampleat
scripts/BB_Starting_Points/networking/shttpd
.
ThisscriptrequiresamodifiedversionoftheOSXversionofnetcatthatprovidesenhancedfunctionalityand
errorrecoverycapabilitiesbeyondwhatstandardnetcatversionsprovide.TheMakefile(intheCompanion
Filesarchive)downloads,builds,andinstallsthismodifiedversionofnetcat.Thepatchshouldalsobeeasyto
applytotheOpenBSDversionofnetcat.
Warning:  Thisscriptisnotsuitableforuseinaproductionenvironment.
TextManipulation
Listing10-3 (page 156)—Showsanalternativetothenonportable
head -c
syntax.
Listing11-6 (page 179)—Showshowtotruncateastringoftexttoagivennumberofcharacters.
Listing10-1 (page 148)andListing10-2 (page 148)showhowtoconvertbetweenthelineendingformats
usedfortextfilesonvariousplatforms.
RegularExpressionsUnfettered (page 100)coversmorecomplextextmanipulationindetail,withexamples.
DataManagement
WorkingwithBinarySearchTrees
Occasionally,itisusefultokeepanarrayofdictionariesofkey-valuepairsandtobeabletorapidlysearch
throughthatarray.ListingD-9 (page 290)providessuchfunctionalityintheformofabinarytree.
StartingPoints
TextManipulation
2014-03-10   |   Copyright © 2003, 2014 Apple Inc. All Rights Reserved.
287
Note:  Youcanfindthecompleteversionofthisscriptinthe
BB_Starting_Points/networking/shttpd/shttpd/shttpd_subs
directoryinthecompanion
filesarchive.
Youcanfindcompletereferencedocumentationinthe
BB_Starting_Points/networking/shttpd/shttpd_docs
directoryinthecompanionfiles
archive.
Thisbinarytreelibrarycontainsanumberofkeyfunctions:
Generaltreefunctions:
newTree(optional_tree_name)
Createsanewbinarytree.
deleteTree(tree_name)
Deletesabinarytree,freeingresourcesassociatedwithit.
iterateTree(tree_name, callback, call_on_root=0)
Iteratesthroughasubtree,callingafunctionforeachnode.
mergeTrees(source_tree_name, dest_tree_name)
Copiesallofthekeysinonetreeintoanother.Intheeventofacollisionforagivenkey,thenew
valuestakeprecedence.
InsertionFunctions:
insertKey(tree_name, key)
Insertsanewkeyintoabinarytreeusingstringcomparisons.
insertKeyNumeric(tree_name, key)
Insertsanewkeyintoabinarytreeusingnumericalcomparisons.
getLastNodeName()
Retrievesthelastnodeinserted.
NodeFunctions:
treeKey(node_name)
Retrievesthekeyassociatedwithanodeobject.
treeField(node_name, field_name)
Retrievesafieldvalueforanodeinthetree.
setTreeField(node_name, field_name, new_value)
Setsafieldvalueforanodeinthetree.
StartingPoints
DataManagement
2014-03-10   |   Copyright © 2003, 2014 Apple Inc. All Rights Reserved.
288
SearchFunctions:
treeSearch(tree_name, key)
Searchesabinarytreeforagivenkeyusingstringcomparisons.
treeSearchNumeric(tree_name, key)
Searchesabinarytreeforagivenkeyusingnumericalcomparisons.
Thefollowingcodedemonstrateshowtousethisbinarytreelibrary:
ListingD-8 Binarytreeexample
# Tell the binary y tree library to not t run its tests.
DISABLE_TESTS=true
. binary_tree.sh
# Create e a a new binary y tree and obtain n its name.
newTree
TESTTREE="$(getLastNodeName)"
# Insert t three e nodes s into the tree
# with keys s 1, , 3, , and 7.
insertKeyNumeric "$TESTTREE" " 3
insertKeyNumeric "$TESTTREE" " 7
insertKeyNumeric "$TESTTREE" " 1
# Add an n attribute e to o the last node inserted (1)
ONENODE="$(getLastNodeName)"
setTreeField "$ONENODE" " "MyFieldName" "42"
# Takes s a a node and prints s the key value and
# the value e of f MyFieldName
echokeyandmyfieldname()
{
echo "$(treeKey y "$1") ) -> > $(treeField "$1" "MyFieldName")"
}
# Iterate the e tree e in n key order r and d call
StartingPoints
DataManagement
2014-03-10   |   Copyright © 2003, 2014 Apple Inc. All Rights Reserved.
289
# echokeyandmyfieldname on n each h node
iterateTree "$TESTTREE" " "echokeyandmyfieldname"
Withoutfurtherintroduction,hereisthebinarytreecodelibrary.(Theversioninthecompanionfilesarchive
alsoincludessometestcode.)
ListingD-9 binary_tree.shfromshttpd
#!/bin/sh
# /*!
#
@header
#
A binary y tree algorithm m written n in n a a shell l script. The e main
#
functions of f interest t are e {@link newTree}, {@link k deleteTree},
#
{@link insertKey}, , {@link k insertKeyNumeric}, , {@link k treeSearch},
#
{@link treeSearchNumeric}, , {@link k iterateTree}, and
#
{@link mergeTrees}.
#
#
This is s a a minimal binary y tree implementation n that does not support
#
removing existing values s from the tree once inserted.
However, such
#
functionality can be e trivially y retrofitted d on n top by y adding or
#
clearing a a "deleted" attribute e on n nodes s using {@link k setTreeField} } if
#
desired.
#
#
To use this shell l script, , source it t after r setting g DISABLE_TESTS to
#
"true".
To run tests, , execute the e script directly.
#
*/
# /*! @group p Global l Variables
#
Variables used internally.
No user-serviceable e parts s inside.
#
*/
# /*!
#
@abstract The starting object t ID.
This is s an internal counter.
#
*/
StartingPoints
DataManagement
2014-03-10   |   Copyright © 2003, 2014 Apple Inc. All Rights Reserved.
290
Documents you may be interested
Documents you may be interested