﻿

# itextsharp pdf to image c# : Add image field to pdf form control software system web page windows html console book30-part1777

5.7 Higher-dimensionalarrays
271
>>> a a = = t[1:-1:2, 1:-1]
>>> a
array([[ 8.,
9., 10., 11.],
[ 0.,
0., 22., 23.]])
>>> a[:,:] = = -99
>>> a
array([[-99., -99., -99., , -99.],
[-99., -99., -99., , -99.]])
>>> t t # # is s t t changed d to? yes!
array([[ 1.,
0.,
0.,
4.,
5.,
6.],
[ 7., , -99., -99., , -99., , -99., , 12.],
[ 13., , 14., 15., 16., 17., 18.],
[ 19., -99., -99., , -99., , -99., , 24.],
[ 25., , 26., 27., 28., 29., 30.]])
5.7.3Arraycomputing
TheoperationsonvectorsinSection5.1.3canquitestraightforwardlybe
extendedtoarraysofanydimension.Considerthedeﬁnitionofapplying
afunctionf(v)toavectorv:weapplythefunctiontoeachelementv
i
inv.Foratwo-dimensionalarrayAwithelementsA
i,j
,i=0,...,m,
j=0,...,n,thesamedeﬁnitionyields
f(A)=(f(A
0,0
),...,f(A
m−1,0
),f(A
1,0
),...,f(A
m−1,n−1
)).
For anarraywithanyrank,f(B)meansapplyingtoeacharray
entry.
TheasteriskoperationfromSection5.1.3isalsonaturallyextendedto
arrays:A∗BmeansmultiplyinganelementinAbythecorresponding
element in B,i.e.,element t (i,j)in A∗B isA
i,j
B
i,j
.Thisdeﬁnition
naturallyextendstoarraysofanyrank,providedthetwoarrayshave
thesameshape.
thearray.Compoundexpressionsinvolvingarrays,e.g.,exp(−A
2
)∗A+1,
work asfor r vectors. . One can infact t just imagine that allthe array
elementsarestoredaftereachotherinalongvector(thisisactually
thewaythearrayelementsarestoredinthecomputer’smemory),and
thearrayoperationscantheneasilybedeﬁnedintermsofthevector
operationsfromSection5.1.3.
Remark. Readers with knowledge e of f matrix computations mayget
confusedbythemeaningofAinmatrixcomputingandAinarray
computing.Theformerisamatrix-matrixproduct,whilethelattermeans
squaringallelementsofA.Whichruletoapply,dependsonthecontext,
i.e.,whetherwearedoinglinearalgebraorvectorizedarithmetics.In
mathematicaltypesetting, AcanbewrittenasAA,while thearray
computingexpressionAcanbe alternativelywrittenasA∗A.Ina
program,A*AandA**2areidenticalcomputations,meaningsquaring
Add image field to pdf form - C# PDF Field Edit Library: insert, delete, update pdf form field in C#.net, ASP.NET, MVC, Ajax, WPF
Online C# Tutorial to Insert, Delete and Update Fields in PDF Document
change font size pdf form reader; chrome save pdf with fields
Add image field to pdf form - VB.NET PDF Field Edit library: insert, delete, update pdf form field in vb.net, ASP.NET, MVC, Ajax, WPF
How to Insert, Delete and Update Fields in PDF Document with VB.NET Demo Code
272
5 Arraycomputingandcurveplotting
allelements(arrayarithmetics).WithNumPyarraysthematrix-matrix
productisobtainedbydot(A, A).Thematrix-vectorproductAx,where
xisavector,iscomputedbydot(A, x).However,withmatrixobjects
(seeSection5.7.5)A*Aimpliesthemathematicalmatrixmultiplication
AA.
We shall leave thissubject of notational confusionbetweenarray
computingandlinearalgebraheresincethisbookwillnotfurtherunder-
standingandtheconfusionisseldomseriousinprogramcodeifonehas
agoodoverviewofthemathematicsthatistobecarriedout.
5.7.4Two-dimensionalarraysandfunctionsoftwovariables
Givenafunctionoftwovariables,say
def f(x, , y):
return sin(sqrt(x**2 + + y**2))
wecanplotthisfunctionbywriting
from scitools.std d import sin, sqrt, linspace, , ndgrid, , mesh
x = = y y = = linspace(-5, 5, , 21) ) # # coordinates s in n x x and d y y direction
xv, yv = = ndgrid(x, , y)
z = = f(xv, yv)
mesh(xv, yv, z)
Therearetwonewthingshere:(i)thecalltondgrid,whichisnecessary
totransformone-dimensionalcoordinatearraysinthexandydirection
intoarraysvalidforevaluatingfoveratwo-dimensionalgrid;and(ii)
theplotfunctionwhosenamenowismesh,whichisoneoutofmany
plotfunctionsfortwo-dimensionalfunctions.Anotherplottypeyoucan
tryoutis
surf(xv, yv, z)
Morematerialonvisualizingf(x,y)functionsisfoundinthesection
VisualizingScalarFieldsintheEasyviztutorial.Thistutorialcanbe
reachedthroughthecommandpydoc scitools.easyvizinaterminal
5.7.5Matrixobjects
Thissectiononlymakessenseifyouarefamiliarwithbasiclinearalgebra
andthe matrixconcept.Thearrayscreatedsofarhavebeenoftype
ndarray.NumPyalsohasamatrixtypecalledmatrixormatforone-
andtwo-dimensionalarrays.One-dimensionalarraysarethenextended
rowvectororacolumnvector:
6
C# PDF insert image Library: insert images into PDF in C#.net, ASP
best pdf form creator; convert pdf to editable form
VB.NET PDF insert image library: insert images into PDF in vb.net
Add images to any selected PDF page in VB.NET. attributes adjust functionalities, such as resize image by zooming Insert images into PDF form field in VB.NET.
pdf create fillable form; add image field to pdf form
5.7 Higher-dimensionalarrays
273
>>> import numpy y as np
>>> x1 1 = np.array([1, , 2, , 3], , float)
>>> x2 2 = np.matrix(x1)
# or mat(x1)
>>> x2
# row vector
matrix([[ 1., , 2., 3.]])
>>> x3 3 = mat(x).transpose()
# column vector
>>> x3
matrix([[ 1.],
[ 2.],
[ 3.]])
>>> type(x3)
<class ’numpy.matrixlib.defmatrix.matrix’>
>>> isinstance(x3, np.matrix)
True
Aspecialfeatureof matrixobjectsisthatthemultiplicationoperator
representsthematrix-matrix,vector-matrix,ormatrix-vectorproductas
weknowfromlinearalgebra:
>>> A A = = eye(3)
# identity y matrix
>>> A
array([[ 1., , 0., , 0.],
[ 0., , 1., , 0.],
[ 0., , 0., , 1.]])
>>> A A = = mat(A)
>>> A
matrix([[ 1., , 0., 0.],
[ 0., , 1., 0.],
[ 0., , 0., 1.]])
>>> y2 2 = x2*A
# vector-matrix x product
>>> y2
matrix([[ 1., , 2., 3.]])
>>> y3 3 = A*x3
# matrix-vector r product
>>> y3
matrix([[ 1.],
[ 2.],
[ 3.]])
One shouldnote herethat themultiplicationoperator betweenstan-
dardndarrayobjectsisquitediﬀerent,asthenextinteractivesession
demonstrates.
>>> A*x1
# no o matrix-array product!
Traceback (most recent t call l last):
...
ValueError: matrices s are not t aligned
>>> # # try array*array y product:
>>> A A = = (zeros(9) + + 1).reshape(3,3)
>>> A
array([[ 1., , 1., , 1.],
[ 1., , 1., , 1.],
[ 1., , 1., , 1.]])
>>> A*x1
# [A[0,:]*x1, , A[1,:]*x1, A[2,:]*x1]
array([[ 1., , 2., , 3.],
[ 1., , 2., , 3.],
[ 1., , 2., , 3.]])
>>> B B = = A A + + 1
>>> A*B
# element-wise product
array([[ 2., , 2., , 2.],
[ 2., , 2., , 2.],
[ 2., , 2., , 2.]])
>>> A A = = mat(A); ; B B = = mat(B)
VB.NET PDF Form Data Read library: extract form data from PDF in
a full-featured PDF software, it should have functions for processing text, image as well DLLs: Read and Extract Field Data in VB.NET. Add necessary references:
convert word document to editable pdf form; build pdf forms
C# PDF Form Data Read Library: extract form data from PDF in C#.
PDF software, it should have functions for processing text, image as well as C#.NET Project DLLs: Read and Extract Field Data in C#. Add necessary references:
add forms to pdf; change pdf to fillable form
274
5 Arraycomputingandcurveplotting
>>> A*B
# matrix-matrix x product
matrix([[ 6., , 6., 6.],
[ 6., , 6., 6.],
[ 6., , 6., 6.]])
behavesquitesimilartomatricesandvectorsinMATLAB.Nevertheless,
matrixcannotbeusedforarraysoflargerdimensionthantwo.
5.8Summary
5.8.1Chaptertopics
Thischapterhasintroducedcomputingwitharraysandplottingcurve
datastoredinarrays.TheNumericalPythonpackagecontainslotsof
functionsfor arraycomputing,includingthe oneslistedinthe table
below.Plottinghasbeendonewithtoolsthatcloselyresemblethesyntax
ofMATLAB.
Construction
Meaning
array(ld)
copylistdataldtoanumpyarray
asarray(d)
zeros(n)
makeafloatvector/arrayoflengthn,withzeros
zeros(n, int)
makeanintvector/arrayoflengthnwithzeros
zeros((m,n))
makeatwo-dimensionalfloatarraywithshape(m,‘n‘)
zeros_like(x)
makearrayofsame shapeandelementtypeasx
linspace(a,b,m)
uniformsequenceofmnumbersin[a,b]
a.shape
tuplecontaininga’sshape
a.size
totalnoofelementsina
len(a)
lengthofaone-dim.arraya(sameasa.shape[0])
a.dtype
thetypeofelementsina
a.reshape(3,2)
returnareshapedas3×2array
a[i]
vectorindexing
a[i,j]
two-dim.arrayindexing
a[1:k]
slice:referencedatawithindices1,...,‘k-1‘
a[1:8:3]
slice:referencedatawithindices1,4,...,‘7‘
b = a.copy()
copyanarray
sin(a), exp(a), , ...
numpyfunctionsapplicabletoarrays
c = concatenate((a, b))
ccontainsawithbappended
c = where(cond, a1, a2)
c[i] = a1[i]ifcond[i],elsec[i] ] = = a2[i]
isinstance(a, ndarray)
isTrueifaisanarray
Array computing. WhenweapplyaPythonfunctionf(x)toaNu-
mericalPythonarrayx,theresultisthesameasifweapplyftoeach
elementinxseparately.However,whenfcontainsifstatements,these
areingeneralinvalidifanarrayxentersthebooleanexpression.We
thenhavetorewritethefunction,oftenbyapplyingthewherefunction
fromNumericalPython.
VB.NET PDF Form Data fill-in library: auto fill-in PDF form data
PDF Page. Image: Copy, Paste, Cut Image in Page. Fill-in Field Data. Field: Insert, Delete, Update Field. Images. Redact Pages. Annotation & Drawing. Add Sticky Note
change font size pdf fillable form; add an image to a pdf form
C# PDF Form Data fill-in Library: auto fill-in PDF form data in C#
Following C# sample code can help you have a quick evaluation of it. C#.NET Demo Code: Auto Fill-in Field Data to PDF in C#.NET. Add necessary references:
change font size in pdf fillable form; add fillable fields to pdf
5.8 Summary
275
Plottingcurves. Sections5.3.1and5.3.2provideaquickoverviewof
howtoplotcurveswiththeaidofMatplotlib.Thesameexamplescoded
withtheEasyvizplottinginterfaceappearinSection5.3.3.
Making movies. Each frame in n a a movie e must t be a hardcopy of f a
plotinPNGformat.Theseplotﬁlesshouldhavenamescontaininga
tmp_0001.png,tmp_0002.png.Havingtheplotﬁleswithnamesonthis
form,wecanmakeananimatedGIFmovieintheﬁlemovie.gif,with
twoframespersecond,by
os.system(’convert -delay 50 tmp_*.png g movie.gif’)
Alternatively,wemaycombinetheplotﬁlestoaFlashvideo:
os.system(’ffmpeg -r r 5 5 -i tmp_%04d.png g -vcodec c flv movie.flv’)
Terminology. Theimportanttopicsinthischapterare
•arraycomputing
•vectorization
•plotting
•animations
5.8.2Example:Animatingafunction
Problem. Inthischapter’ssummarizingexampleweshallvisualizehow
thetemperaturevariesdownwardintheearthasthesurfacetemperature
oscillatesbetweenhighdayandlownightvalues.Onequestionmaybe:
Whatisthetemperaturechange10mdowninthegroundifthesurface
temperaturevariesbetween2Cinthenightand15Cintheday?
Letthezaxispointdownwards,towardsthecenteroftheearth,andlet
z=0correspondtotheearth’ssurface.Thetemperatureatsomedepth
zinthegroundattimetisdenotedbyT(z,t).Ifthesurfacetemperature
hasaperiodicvariationaroundsomemeanvalueT
0
,accordingto
T(0,t)=T
0
+Acos(ωt),
onecanﬁnd,fromamathematicalmodelforheatconduction,thatthe
temperatureatanarbitrarydepthis
T(z,t)=T
0
+Ae
−az
cos(ωt − az), a =
ω
2k
.
(5.13)
The parameterk reﬂects the ground’s ability to conduct heat (k is called
the thermal diﬀusivity or the heat conduction coeﬃcient).
C# PDF Image Extract Library: Select, copy, paste PDF images in C#
Scan image to PDF, tiff and various image formats. Get image information, such as its location, zonal information Able to edit, add, delete, move, and output PDF
changing font in pdf form; chrome save pdf form
VB.NET PDF Image Extract Library: Select, copy, paste PDF images
multiple types of image from PDF file in VB.NET, like XObject Image, XObject Form, Inline Image DLLs for PDF Image Extraction in VB.NET. Add necessary references
adding signature to pdf form; cannot edit pdf form
276
5 Array computing and curve plotting
The task is to make an animation of how the temperature proﬁle in the
ground, i.e.,T as a function ofz, varies in time. Letω correspond to a
time period of 24 hours. The mean temperatureT
0
is taken as 10 C, and
the maximum variationA is assumed to be 10 C. The heat conduction
coeﬃcientk may be set as 1mm
2
/s(whichis10
−6
m
2
/sinproperSI
units).
Solution. ToanimateT(z, t)intime,weneedtomakealoopoverpoints
in time, and in each pass in the loop we must save a plot ofT, as a
function ofz, to ﬁle. The plot ﬁles can then be combined to a movie.
The algorithm becomes
• for t
i
=iΔt, i = 0, 1, 2. . . , n:
– plot the curve y(z) = T(z, t
i
)
– store the plot in a ﬁle
• combine all the plot ﬁles into a movie
It can be wise to make a generalanimate function where we just feed
in some f(x,t) function and make all the plot ﬁles. If animate has
arguments for setting the labels on the axis and the extent of they axis,
we can easily useanimate also for a functionT(z,t) (we just usez as the
name for thex axis andT as the name for they axis in the plot). Recall
that it is important to ﬁx the extent of the y axis in a plot when we
make animations, otherwise most plotting programs will automatically
ﬁt the extent of the axis to the current data, and the tick marks on the
yaxiswilljumpupanddownduringthemovie.Theresultisawrong
visual impression of the function.
The names of the plot ﬁles must have a common stem appended
with some frame number, and the frame number should have a ﬁxed
number of digits, such as 0001, 0002, etc. (if not, the sequence of the
plot ﬁles will not be correct when we specify the collection of ﬁles with
an asterisk for the frame numbers, e.g., as intmp*.png). We therefore
include an argument toanimate for setting the name stem of the plot ﬁles.
By default, the stem istmp_, resulting in the ﬁlenamestmp_0000.png,
tmp_0001.png, tmp_0002.png,andsoforth.Otherconvenientarguments
for theanimate function are the initial time in the plot, the time lag
Δtbetweentheplotframes,andthecoordinatesalongthe xaxis.The
animate function then takes the form
def animate(tmax, dt, x, function, ymin, ymax, t0=0,
xlabel=’x’, ylabel=’y’, filename=’tmp_’):
t = t0
counter = 0
while t <= tmax:
y = function(x, t)
plot(x, y, ’-’,
axis=[x[0], x[-1], ymin, ymax],
title=’time=%2d h’ % (t/3600.0),
xlabel=xlabel, ylabel=ylabel,
savefig=filename + ’%04d.png’ % counter)
savefig(’tmp_%04d.pdf’ % counter)
5.8 Summary
277
t += dt
counter += 1
The T (z,t) function is easy to implement, but we need to decide
whether the parameters AωT
0
, and k shall be arguments to the
Python implementation ofT (z,t) or if they shall be global variables.
Since theanimate function expects that the function to be plotted has
only two arguments, we must implementT(z,t) asT(z,t) in Python
and let the other parameters be global variables (Sections 7.1.1 and 7.1.2
explain this problem in more detail and present a better implementation).
def T(z, t):
# T0, A, k, and omega are global variables
a = sqrt(omega/(2*k))
return T0 + A*exp(-a*z)*cos(omega*t - a*z)
Suppose we plotT(z,t) atn points forz∈ [0,D ]. We make such plots
fort∈ [0,t
max
]with a time lagΔtbetween the them. The frames in the
# set T0, A, k, omega, D, n, tmax, dt
z = linspace(0, D, n)
animate(tmax, dt, z, T, T0-A, T0+A, 0, ’z’, ’T’)
We have here set the extent of they axis in the plot as [T
0
−A, T
0
+A],
which is in accordance with the T(z, t) function.
The call toanimate above creates a set of ﬁles with names of the form
tmp_*.png.OutoftheseﬁleswecancreateananimatedGIFmovieor
avideo in, e.g., Flash format by running operating systems commands
with convert and avconv (or ffmpeg):
os.system(’convert -delay 50 tmp_*.png movie.gif’)
os.system(’avconv -r 5 -i tmp_%04d.png -vcodec flv movie.flv’)
See Section 5.3.5 for how to create videos in other formats.
It now remains to assign proper values to all the global variables in
the program:n,D,T0,A,omega,dt,tmax, andk. The oscillation period
is 24 hours, andω is related to the period P of the cosine function
byω = 2π/P (realize thatcos(t2π/P ) has periodP). We then express
P=24has24·60·60sandcompute ωas2π/P ≈7 ·10−5 s−1.Thetotal
simulation time can be 3 periods, i.e.,t
max
=3P. TheT(z,t) function
decreases exponentially with the depthz so there is no point in having
the maximum depthD larger than the depth whereT is visually zero,
say 0.001. We have thate−aD = 0.001 whenD =−a−1ln 0.001, so we
can use this estimate in the program. The proper initialization of all
parameters can then be expressed as follows:
k = 1E-6
# thermal diffusivity (in m*m/s)
P = 24*60*60.
# oscillation period of 24 h (in seconds)
omega = 2*pi/P
dt = P/24
# time lag: 1 h
5.8 Summary
279
¯z = z/D
¯
T=
T− T
0
A
¯
t= ωt
We now insertz =¯zD andt =
¯
t/ωintheexpressionfor T(z, t)andget
T = T
0
+Ae
−b¯z
cos(
¯
or
¯
T(¯z,
¯
t) =
T− T
0
A
=e
−b¯z
cos(
¯
t− b¯z) .
We see that
¯
to the independent dimensionless variables¯z and
¯
t.Itiscommonpractice
at this stage of the scaling to just drop the bars and write
T(z, t) = e
−bz
cos(t − bz) .
(5.14)
This function is much simpler to plot than the one with lots of physical
parameters, because now we know thatT varies between1 and 1,t
varies between 0 and 2π for one period, andz varies between 0 and 1.
The scaled temperature has only one parameter b in addition to the
independent variable. That is, the shape of the graph is completely
determined by b.
In our previous movie example, we used speciﬁc values forD,ω, and
k,whichthenimpliesacertain b= D
ω/(2k)(6.9).However,wecan
now run diﬀerentb values and see the eﬀect on the heat propagation.
Diﬀerentb values will in our problems imply diﬀerent periods of the
surface temperature variation and/or diﬀerent heat conduction values in
the ground’s composition of rocks. Note that doublingω andk leaves
the same b - it is only the fraction ω/k that inﬂuences the value of b.
We can reuse theanimate function also in the scaled case, but we
need to make a newT(z,t) function and, e.g., a main program whereb
can be read from the command line:
def T(z, t):
return exp(-b*z)*cos(t - b*z) # b is global
b = float(sys.argv[1])
n = 401
z = linspace(0, 1, n)
animate(3*2*pi, 0.05*2*pi, z, T, -1.2, 1.2, 0, ’z’, ’T’)
movie(’tmp_*.png’, encoder=’convert’, fps=2,
output_file=’tmp_heatwave.gif’)
os.system(’convert -delay 50 tmp_*.png movie.gif’)
Running the program, found as the ﬁleheatwave_scaled.py, for dif-
ferentb values shows thatb governs how deep the temperature variations
on the surfacez = 0 penetrate. A largeb makes the temperature changes
conﬁned to a thin layer close to the surface, while a smallb leads to