open pdf file in new window asp.net c# : How to edit and delete text in pdf file online SDK software project winforms windows html UWP pil-handbook0-part1504

Python Imaging Library Overview
PIL1.1.3|March12,2002|FredrikLundh,MatthewEllis
Introduction
ThePythonImagingLibraryaddsimageprocessingcapabilitiestoyourPython
interpreter.
Thislibraryprovidesextensivefileformatsupport,anefficientinternalrepresentation,
andfairlypowerfulimageprocessingcapabilities.
Thecoreimagelibraryisdesignedforfastaccesstodatastoredinafewbasicpixel
formats.Itshouldprovideasolidfoundationforageneralimageprocessingtool.
Let'slookatafewpossibleusesofthislibrary:
Image Archives
ThePythonImagingLibraryisidealforforimagearchivalandbatchprocessing
applications.Youcanusethelibrarytocreatethumbnails,convertbetweenfileformats,
printimages,etc.
Thecurrentversionidentifiesandreadsalargenumberofformats.Writesupportis
intentionallyrestrictedtothemostcommonlyusedinterchangeandpresentationformats.
Image Display
ThecurrentreleaseincludesTkPhotoImageandBitmapImageinterfaces,aswellasa
WindowsDIBinterfacethatcanbeusedwithPythonWin.ForXandMacdisplays,youcan
useJackJansen'simglibrary.
Fordebugging,there'salsoashowmethodintheUnixversionwhichcallsxvtodisplaythe
image.
Image Processing
Thelibrarycontainssomebasicimageprocessingfunctionality,includingpointoperations,
filteringwithasetofbuilt-inconvolutionkernels,andcolourspaceconversions.
Thelibraryalsosupportsimageresizing,rotationandarbitraryaffinetransforms.
There'sahistogrammethodallowingyoutopullsomestatisticsoutofanimage.Thiscan
beusedforautomaticcontrastenhancement,andforglobalstatisticalanalysis.
How to edit and delete text in pdf file online - delete, remove text from PDF file in C#.net, ASP.NET, MVC, Ajax, WinForms, WPF
Allow C# developers to use mature APIs to delete and remove text content from PDF document
delete text pdf; how to delete text from a pdf
How to edit and delete text in pdf file online - VB.NET PDF delete text library: delete, remove text from PDF file in vb.net, ASP.NET, MVC, Ajax, WinForms, WPF
VB.NET Programming Guide to Delete Text from PDF File
how to erase pdf text; delete text from pdf preview
Tutorial
Using the Image Class
ThemostimportantclassinthePythonImagingLibraryistheImageclass,definedinthe
modulewiththesamename.Youcancreateinstancesofthisclassinseveralways;either
byloadingimagesfromfiles,processingotherimages,orcreatingimagesfromscratch.
Toloadanimagefromafile,usetheopenfunctionintheImagemodule.
>>> import Image
>>> im = Image.open("lena.ppm")
Ifsuccessful,thisfunctionreturnsanImageobject.Youcannowuseinstanceattributes
toexaminethefilecontents.
>>> print im.format, im.size, im.mode
PPM (512, 512) RGB
Theformatattributeidentifiesthesourceofanimage.Iftheimagewasnotreadfroma
file,itissettoNone.Thesizeattributeisa2-tuplecontainingwidthandheight(in
pixels).Themodeattributedefinesthenumberandnamesofthebandsintheimage,and
alsothepixeltypeanddepth.Commonmodesare"L"(luminance)forgreyscaleimages,
"RGB"fortruecolourimages,and"CMYK"forpre-pressimages.
Ifthefilecannotbeopened,anIOErrorexceptionisraised.
OnceyouhaveaninstanceoftheImageclass,youcanusethemethodsdefinedbythis
classtoprocessandmanipulatetheimage.Forexample,let'sdisplaytheimagewejust
loaded:
>>> im.show()
(Thestandardversionofshowisnotveryefficient,sinceitsavestheimagetoa
temporaryfileandcallsthexvutilitytodisplaytheimage.Ifyoudon'thavexvinstalled,
itwon'tevenwork.Whenitdoesworkthough,itisveryhandyfordebuggingandtests.)
Thefollowingsectionsprovideanoverviewofthedifferentfunctionsprovidedinthis
library.
Reading and Writing Images
ThePythonImagingLibrarysupportsawidevarietyofimagefileformats.Toreadfiles
fromdisk,usetheopenfunctionintheImagemodule.Youdon'thavetoknowthefile
formattoopenafile.Thelibraryautomaticallydeterminestheformatbasedonthe
contentsofthefile.
Tosaveafile,usethesavemethodoftheImageclass.Whensavingfiles,thename
becomesimportant.Unlessyouspecifytheformat,thelibraryusesthefilenameextension
todiscoverwhichfilestorageformattouse.
Example:ConvertfilestoJPEG
C# PDF File & Page Process Library SDK for C#.net, ASP.NET, MVC
in Field Data. Field: Insert, Delete, Update Field. File Permissions. Password: Open Document. Edit Digital Signatures. Highlight Text. Add Text. Add Text Box. Drawing
remove text from pdf; delete text pdf document
VB.NET PDF Page Delete Library: remove PDF pages in vb.net, ASP.
Free PDF edit control and component for deleting PDF Easy to delete PDF page in .NET WinForms application Enable specified pages deleting from PDF in Visual
how to delete text in a pdf acrobat; delete text pdf file
import os, sys
import Image
for infile in sys.argv[1:]:
outfile = os.path.splitext(infile)[0] + ".jpg"
if infile != outfile:
try:
Image.open(infile).save(outfile)
except IOError:
print "cannot convert", infile
Asecondargumentcanbesuppliedtothesavemethodwhichexplicitlyspecifiesafile
format.Ifyouuseanon-standardextension,youmustalwaysspecifytheformatthisway:
Example:CreateJPEGThumbnails
import os, sys
import Image
for infile in sys.argv[1:]:
outfile = os.path.splitext(infile)[0] + ".thumbnail"
if infile != outfile:
try:
im = Image.open(infile)
im.thumbnail((128, 128))
im.save(outfile, "JPEG")
except IOError:
print "cannot create thumbnail for", infile
Itisimportanttonoteisthatthelibrarydoesn'tdecodeorloadtherasterdataunlessit
reallyhasto.Whenyouopenafile,thefileheaderisreadtodeterminethefileformat
andextractthingslikemode,size,andotherpropertiesrequiredtodecodethefile,but
therestofthefileisnotprocesseduntillater.
Thismeansthatopeninganimagefileisafastoperation,whichisindependentofthefile
sizeandcompressiontype.Here'sasimplescripttoquicklyidentifyasetofimagefiles:
Example:IdentifyImageFiles
import sys
import Image
for infile in sys.argv[1:]:
try:
im = Image.open(infile)
print infile, im.format, "%dx%d" % im.size, im.mode
except IOError:
pass
Cutting, Pasting and Merging Images
TheImageclasscontainsmethodsallowingyoutomanipulateregionswithinanimage.To
extractasub-rectanglefromanimage,usethecropmethod.
Example:Copyingasubrectanglefromanimage
C# PDF Text Extract Library: extract text content from PDF file in
Advanced Visual Studio .NET PDF edit SDK, built on .NET framework 2.0 and compatible Able to extract and get all and partial text content from PDF file.
delete text from pdf acrobat; acrobat remove text from pdf
C# PDF Page Delete Library: remove PDF pages in C#.net, ASP.NET
BestC#.NET PDF edit control for deleting PDF pages in Visual Advanced component and library able to delete PDF page in to remove a range of pages from PDF file.
delete text from pdf; how to delete text from a pdf reader
box = (100, 100, 400, 400)
region = im.crop(box)
Theregionisdefinedbya4-tuple,wherecoordinatesare(left,upper,right,lower).The
PythonImagingLibraryusesacoordinatesystemwith(0,0)intheupperleftcorner.Also
notethatcoordinatesrefertopositionsbetweenthepixels,sotheregionintheabove
exampleisexactly300x300pixels.
Theregioncouldnowbeprocessedinacertainmannerandpastedback.
Example:Processingasubrectangle,andpastingitback
region = region.transpose(Image.ROTATE_180)
im.paste(region, box)
Whenpastingregionsback,thesizeoftheregionmustmatchthegivenregionexactly.In
addition,theregioncannotextendoutsidetheimage.However,themodesoftheoriginal
imageandtheregiondonotneedtomatch.Iftheydon't,theregionisautomatically
convertedbeforebeingpasted(seethesectiononColourTransformsbelowfordetails).
Here'sanadditionalexample:
Example:Rollinganimage
def roll(image, delta):
"Roll an image sideways"
xsize, ysize = image.size
delta = delta % xsize
if delta == 0: return image
part1 = image.crop((0, 0, delta, ysize))
part2 = image.crop((delta, 0, xsize, ysize))
image.paste(part2, (0, 0, xsize-delta, ysize))
image.paste(part1, (xsize-delta, 0, xsize, ysize))
return image
Formoreadvancedtricks,thepastemethodcanalsotakeatransparencymaskasan
optionalargument.Inthismask,thevalue255indicatesthatthepastedimageisopaque
inthatposition(thatis,thepastedimageshouldbeusedasis).Thevalue0meansthat
thepastedimageiscompletelytransparent.Valuesin-betweenindicatedifferentlevelsof
transparency.
ThePythonImagingLibraryalsoallowsyoutoworkwiththeindividualbandsofan
multi-bandimage,suchasanRGBimage.Thesplitmethodcreatesasetofnewimages,
eachcontainingonebandfromtheoriginalmulti-bandimage.Themergefunctiontakesa
modeandatupleofimages,andcombinesthemintoanewimage.Thefollowingsample
swapsthethreebandsofanRGBimage:
Example:Splittingandmergingbands
r, g, b = im.split()
im = Image.merge("RGB", (b, g, r))
VB.NET PDF File Compress Library: Compress reduce PDF size in vb.
size, images size reducing can help to reduce PDF file size effectively will also take up too much space, glyph file unreferenced can Delete unimportant contents
remove text watermark from pdf; how to edit and delete text in pdf file online
C# PDF metadata Library: add, remove, update PDF metadata in C#.
Evaluation library and components provide varieties of functionalities to edit and update PDF metadata in Remove and delete metadata from PDF file.
delete text pdf acrobat; how to delete text in pdf file online
Geometrical Transforms
TheImageclasscontainsmethodstoresizeandrotateanimage.Theformertakesatuple
givingthenewsize,thelattertheangleindegreescounter-clockwise.
Example:Simplegeometrytransforms
out = im.resize((128, 128))
out = im.rotate(45) # degrees counter-clockwise
Torotatetheimagein90degreesteps,youcaneitherusetherotatemethodorthe
transposemethod.Thelattercanalsobeusedtoflipanimagearounditshorizontalor
verticalaxis.
Example:Transposinganimage
out = im.transpose(Image.FLIP_LEFT_RIGHT)
out = im.transpose(Image.FLIP_TOP_BOTTOM)
out = im.transpose(Image.ROTATE_90)
out = im.transpose(Image.ROTATE_180)
out = im.transpose(Image.ROTATE_270)
There'snodifferenceinperformanceorresultbetweentranspose(ROTATE)and
correspondingrotateoperations.
Amoregeneralformofimagetransformationscanbecarriedoutviathetransform
method.Seethereferencesectionfordetails.
Colour Transforms
ThePythonImagingLibraryallowsyoutoconvertimagesbetweendifferentpixel
representationsusingtheconvertfunction.
Example:Convertingbetweenmodes
im = Image.open("lena.ppm").convert("L")
Thelibrarysupportstransformationsbetweeneachsupportedmodeandthe"L"and"RGB"
modes.Toconvertbetweenothermodes,youmayhavetouseanintermediateimage
(typicallyan"RGB"image).
Image Enhancement
ThePythonImagingLibraryprovidesanumberofmethodsandmodulesthatcanbeused
toenhanceimages.
Filters
TheImageFiltermodulecontainsanumberofpre-definedenhancementfiltersthatcan
beusedwiththefiltermethod.
Example:Applyingfilters
VB.NET PDF File Split Library: Split, seperate PDF into multiple
Split PDF file into two or multiple files in ASP.NET webpage online. Support to break a large PDF file into smaller files in .NET WinForms.
pdf text remover; how to delete text from pdf reader
VB.NET PDF File Merge Library: Merge, append PDF files in vb.net
Append one PDF file to the end of another one in VB.NET. Free .NET framework library download and VB.NET online source code samples.
how to copy text out of a pdf; how to erase in pdf text
import ImageFilter
out = im.filter(ImageFilter.DETAIL)
PointOperations
Thepointmethodcanbeusedtotranslatethepixelvaluesofanimage(e.g.image
contrastmanipulation).Inmostcases,afunctionobjectexpectingoneargumentcanbe
passedtothethismethod.Eachpixelisprocessedaccordingtothatfunction:
Example:Applyingpointtransforms
# multiply each pixel by 1.2
out = im.point(lambda i: i * 1.2)
Usingtheabovetechnique,youcanquicklyapplyanysimpleexpressiontoanimage.You
canalsocombinethepointandpastemethodstoselectivelymodifyanimage:
Example:Processingindividualbands
# split the image into individual bands
source = im.split()
R, G, B = 0, 1, 2
# select regions where red is less than 100
mask = source[R].point(lambda i: i  100 and 255)
# process the green band
out = source[G].point(lambda i: i * 0.7)
# paste the processed band back, but only where red was  100
source[G].paste(out, None, mask)
# build a new multiband image
im = Image.merge(im.mode, source)
Notethesyntaxusedtocreatethemask:
imout = im.point(lambda i: expression and 255)
Pythononlyevaluatestheportionofalogicalexpressionasisnecessarytodeterminethe
outcome,andreturnsthelastvalueexaminedastheresultoftheexpression.Soifthe
expressionaboveisfalse(0),Pythondoesnotlookatthesecondoperand,andthus
returns0.Otherwise,itreturns255.
Enhancement
Formoreadvancedimageenhancement,usetheclassesintheImageEnhancemodule.
Oncecreatedfromanimage,anenhancementobjectcanbeusedtoquicklytryout
differentsettings.
Youcanadjustcontrast,brightness,colourbalanceandsharpnessinthisway.
Example:Enhancingimages
import ImageEnhance
enh = ImageEnhance.Contrast(im)
enh.enhance(1.3).show("30% more contrast")
Image Sequences
ThePythonImagingLibrarycontainssomebasicsupportforimagesequences(alsocalled
animationformats).SupportedsequenceformatsincludeFLI/FLC,GIF,andafew
experimentalformats.TIFFfilescanalsocontainmorethanoneframe.
Whenyouopenasequencefile,PILautomaticallyloadsthefirstframeinthesequence.
Youcanusetheseekandtellmethodstomovebetweendifferentframes:
Example:Readingsequences
import Image
im = Image.open("animation.gif")
im.seek(1) # skip to the second frame
try:
while 1:
im.seek(im.tell()+1)
# do something to im
except EOFError:
pass # end of sequence
Asseeninthisexample,you'llgetanEOFErrorexceptionwhenthesequenceends.
Notethatmostdriversinthecurrentversionofthelibraryonlyallowyoutoseektothe
nextframe(asintheaboveexample).Torewindthefile,youmayhavetoreopenit.
Thefollowingiteratorclassletsyoutousethefor-statementtoloopoverthesequence:
Example:Asequenceiteratorclass
class ImageSequence:
def __init__(self, im):
self.im = im
def __getitem__(self, ix):
try:
if ix:
self.im.seek(ix)
return self.im
except EOFError:
raise IndexError # end of sequence
for frame in ImageSequence(im):
# ...do something to frame...
Postscript Printing
ThePythonImagingLibraryincludesfunctionstoprintimages,textandgraphicson
Postscriptprinters.Here'sasimpleexample:
Example:DrawingPostscript
import Image
import PSDraw
im = Image.open("lena.ppm")
title = "lena"
box = (1*72, 2*72, 7*72, 10*72) # in points
ps = PSDraw.PSDraw() # default is sys.stdout
ps.begin_document(title)
# draw the image (75 dpi)
ps.image(box, im, 75)
ps.rectangle(box) 
# draw centered title
ps.setfont("HelveticaNarrow-Bold", 36)
w, h, b = ps.textsize(title)
ps.text((4*72-w/2, 1*72-h), title) 
ps.end_document()
More on Reading Images
Asdescribedearlier,theopenfunctionoftheImagemoduleisusedtoopenanimagefile.
Inmostcases,yousimplypassitthefilenameasanargument:
im = Image.open("lena.ppm")
Ifeverythinggoeswell,theresultisanImageobject.Otherwise,anIOErrorexceptionis
raised.
Youcanuseafile-likeobjectinsteadofthefilename.Theobjectmustimplementread,
seekandtellmethods,andbeopenedinbinarymode.
Example:Readingfromanopenfile
fp = open("lena.ppm", "rb")
im = Image.open(fp)
Toreadanimagefromstringdata,usetheStringIOclass:
Example:Readingfromastring
import StringIO
im = Image.open(StringIO.StringIO(buffer))
Notethatthelibraryrewindsthefile(usingseek(0))beforereadingtheimageheader.In
addition,seekwillalsobeusedwhentheimagedataisread(bytheloadmethod).Ifthe
imagefileisembeddedinalargerfile,suchasatarfile,youcanusetheContainerIOor
TarIOmodulestoaccessit.
Example:Readingfromatararchive
import TarIO
fp = TarIO.TarIO("Imaging.tar", "Imaging/test/lena.ppm")
im = Image.open(fp)
ControllingtheDecoder
Somedecodersallowyoutomanipulatetheimagewhilereadingitfromafile.Thiscan
oftenbeusedtospeedupdecodingwhencreatingthumbnails(whenspeedisusuallymore
importantthanquality)andprintingtoamonochromelaserprinter(whenonlyagreyscale
versionoftheimageisneeded).
Thedraftmethodmanipulatesanopenedbutnotyetloadedimagesoitascloselyas
possiblematchesthegivenmodeandsize.Thisisdonebyreconfiguringtheimage
decoder.
Example:Readingindraftmode
im = Image.open(file)
print "original =", im.mode, im.size
im.draft("L", (100, 100))
print "draft =", im.mode, im.size
Thisprintssomethinglike:
original = RGB (512, 512)
draft = L (128, 128)
Notethattheresultingimagemaynotexactlymatchtherequestedmodeandsize.To
makesurethattheimageisnotlargerthanthegivensize,usethethumbnailmethod
instead.
Concepts
ThePythonImagingLibraryhandlesrasterimages,thatis,rectanglesofpixeldata.
Bands
Animagecanconsistofoneormorebandsofdata.ThePythonImagingLibraryallowsyou
tostoreseveralbandsinasingleimage,providedtheyallhavethesamedimensionsand
depth.
Togetthenumberandnamesofbandsinanimage,usethegetbandsmethod.
Mode
Themodeofanimagedefinesthetypeanddepthofapixelintheimage.Thecurrent
releasesupportsthefollowingstandardmodes:
1(1-bitpixels,blackandwhite,storedas8-bitpixels)
·
L(8-bitpixels,blackandwhite)
·
P(8-bitpixels,mappedtoanyothermodeusingacolourpalette)
·
RGB(3x8-bitpixels,truecolour)
·
RGBA(4x8-bitpixels,truecolourwithtransparencymask)
·
CMYK(4x8-bitpixels,colourseparation)
·
YCbCr(3x8-bitpixels,colourvideoformat)
·
I(32-bitintegerpixels)
·
F(32-bitfloatingpointpixels)
·
PILalsosupportsafewspecialmodes,includingRGBX(truecolourwithpadding)andRGBa
(truecolourwithpremultipliedalpha).
Youcanreadthemodeofanimagethroughthemodeattribute.Thisisastringcontaining
oneoftheabovevalues.
Size
Youcanreadtheimagesizethroughthesizeattribute.Thisisa2-tuple,containingthe
horizontalandverticalsizeinpixels.
Coordinate System
ThePythonImagingLibraryusesaCartesianpixelcoordinatesystem,with(0,0)inthe
upperleftcorner.Notethatthecoordinatesrefertotheimpliedpixelcorners;thecentre
ofapixeladdressedas(0,0)actuallyliesat(0.5,0.5):
Documents you may be interested
Documents you may be interested