39
Once you have a PDFDocument object and have done modification onto it (for example add
annotations to page in the document), you can save it back to pdf file.
Related APIs:
void Save(String fileName)
void SaveToStream(Stream stream)
byte[] SaveToBytes()
PDF
Rendering
and
Conversion
RasterEdge Document Imaging SDK supports converting PDF document and pages within to
various image and document types with customized options. You can convert PDF Document to
PNG, JPEG, BMP, and GIF image formats to view as in RasterEdge document WebViewer and
Win form document viewer. You can also convert PDF Document and pages to SVG. SVG is a
vector image format that is supported by HTML5 standard and therefore supported by most of
the up to date web browsers. PDF document can also be converted to tiff file.
Convert
PDFDocument
to
Images
You can convert PDFDocument to raster images collection. This is a bulk operation with
customized options.
Related APIs:
void ConvertToImages(ImageType targetType, int resolution, String directory, String fileName)
void ConvertToImages(ImageType targetType, float zoomValue, String directory, String
fileName)
These methods will automatically convert every page in PDF document to image files, with the
page index append to fileName. Note that, the resolution is default to be 96 dpi for monitor
displaying purpose. You can adjust resolution to enlarge or reduce the size of image file. You
can also specify the zoomValue to adjust image size.You can get the original image with
zoomValue set to be 1.
Convert
É·
PDFPage
to
Image
File
To get full control over the rendering process, you can work with PDFPage object. First, get
specific PDFPage object from pdf document by BasePage GetPage(int index), and then you can
323
render PDFPage object to REImage or other common image formats with customized
parameters.
Related APIs:
REImage CropImage(Rectangle sourceRegion, Size targetSize)
REImage ConvertToImage()
void ConvertToImage(ImageType toType,String filePath)
void ConvertToImage(ImageType toType,int resolution, String filePath)
If you want to zoom in the page with a large factor, say 8x and paint the whole page. This will
cost not only high usage of memory resource but also a considerable amount of time to proceed.
The common practice is to convert part of the page with a zoom in factor at a time. And
CropImage API is designed for this purpose.
Convert
PDFPage
to
Bitmap
In .Net framework Bitmap is a frequently used class in image processing. RasterEdge provide you
with APIs to directly convert PDFPage to Bitmap objects which then can be drew on graphics of
for example win form controls. These APIs returning a Bitmap object are faster than return a
REImage object taking into account that additional operations needed with REImage.
Bitmap GetBitmap()
Bitmap GetBitmap(float zoomValue)
Bitmap GetBitmap(float zoomValue)
Bitmap GetBitmap(Rectangle sourceRectangle, Size targetSize)
Note that the resulting Bitmap cannot be too big to handle due to the restriction of system
memory. Typically if a resulting pdf page magnified with a zoom in factor has a dimension
product over 3000*3000, we recommend you deal with them in partitions.
Bitmap GetBitmap(Rectangle sourceRectangle, Size targetSize) is a good choose
// l
oad
pd
f
docu
m
en
t
P
D
F
D
ocu
m
en
t
doc
=
ne
w
P
D
F
D
ocu
m
en
t(@
"d
:\
s
a
m
p
l
e
.
pd
f
"
);
//
ge
t t
he
firs
t
page
P
D
FPage
page
=
(
P
D
FPage
)
doc
.G
e
t
Page
(
0
);
// t
he
o
ri
gna
l
page
d
im
en
s
i
on
i
n
p
i
xe
l m
ea
s
u
r
ed
i
n
96
dp
i
fl
oa
t
o
ri
gna
lWi
d
t
h
=
page
.G
e
tWi
d
t
h
()
*
96
;
fl
oa
t
o
ri
gna
lH
e
i
gh
t
=
page
.G
e
tH
e
i
gh
t()
*
96
;
//
zoo
m i
n
wit
h
a
f
ac
t
o
r
o
f
8
,
and
d
i
v
i
de
t
he
o
ri
gna
l
p
i
c
t
u
r
e
s
i
n
t
o
64
pa
rtiti
on
s
//
each
pa
rtiti
on
ha
s
a
s
i
ze
o
f t
he
o
ri
gna
l
page
i
n
96
dp
i
//
ge
t t
he
l
e
ft t
op
pa
rt
Bitm
ap
b
m
p
=
page
.G
e
tBitm
ap
(
ne
w
R
ec
t
ang
l
e
(
0
,
0
, (i
n
t)(
o
ri
gna
lWi
d
t
h
/
8
),
(i
n
t)(
o
ri
gna
lH
e
i
gh
t /
8
)),
ne
w
S
i
ze
((i
n
t)
o
ri
gna
lWi
d
t
h
, (i
n
t)
o
ri
gna
lH
e
i
gh
t));
.
148
You can also draw the page directly onto a graphics using the following APIs
Draw(Graphics g, PointF loaction)
void Draw(Graphics g, PointF loaction, Size targetSize )
Convert
PDF
to
SVG
SVG part of HTML5 standard, therefore it can viewed directly using most of the modern
browsers without installing additional plugin or add-on on the end user’s computer.
Related APIs:
PDFDocument.ConvertToVectorImages(ContextType targetType, String directory, String
fileName,RelativeType type);
PDFPage.ConvertToVectorImage(ContextType targetType, String directory, String
fileName,RelativeType type);
SVG file generated can be used in one of the two ways:
1. Svg file can be used as a stand-alone external resource of a web page. In this case the
resources such as font and image files referenced by svg file are mapped by a relative
path with respect to the svg file itself. Choose RelativeType.SVG as input parameter
when you use svg file as an external resource.
2. The content of svg file may be extracted and then embedded into html code in a web
application. If this is the case the resources referenced are mapped through a relative
path to the web project working directory. Choose RelativeType.ASP as input parameter
in this situation.
C# sample code
s
tri
ng
fil
ePa
t
h
=
@
"c
\
s
a
m
p
l
e
.
pd
f
"
;
//
d
ir
ec
t
o
r
y
t
o
s
t
o
r
e
t
he
s
vg
fil
e
and
r
e
s
ou
r
ce
s
s
tri
ng
s
vg
fil
e
Dir
ec
t
o
r
y
=
@
"c
\
s
a
m
p
l
e
\
"
;
// l
oad
pd
f fil
e
t
o
c
r
ea
t
P
D
F
D
ocu
m
en
t
ob
j
ec
t
P
D
F
D
ocu
m
en
t
doc
=
ne
w
P
D
F
D
ocu
m
en
t(fil
ePa
t
h
);
801
//
you
can
conve
rt t
he
w
ho
l
e
docu
m
en
t t
o
a
li
s
t
o
f
s
vg
fil
e
s
//
each
page
o
f t
he
docu
m
en
t i
s
r
ende
r
d
t
o
a
s
vg
fil
e
wit
h
page
i
ndex
//
appended
//t
o
t
he
na
m
e
doc
.
C
onve
rt
To
V
ec
t
o
rIm
age
s(C
on
t
ex
t
Type
.
S
VG,
s
vg
fil
e
Dir
ec
t
o
r
y
,
"Sa
m
p
l
eS
VG
"
,
R
e
l
a
ti
veType
.
S
VG);
//
o
r
you
can
conve
rt
s
pec
ifi
c
page
t
o
s
vg
fil
e
// G
e
t t
he
firs
t
page
o
f
pd
f
docu
m
en
t
and
conve
rt it t
o
s
vg
fil
e
P
D
FPage
page
=
(
P
D
FPage
)
doc
.G
e
t
Page
(
0
);
page
.
C
onve
rt
To
V
ec
t
o
rIm
age
(C
on
t
ex
t
Type
.
S
VG,
s
vg
fil
e
Dir
ec
t
o
r
y
,
"Sa
m
p
l
eS
VG
"
,
R
e
l
a
ti
veType
.
S
VG);
// if
you
w
an
t t
o
e
m
bed
t
he
s
vg
con
t
en
t i
n
t
o
h
tml
code
i
n
you
r w
eb
app
li
ca
ti
on
// t
he
r
e
l
a
ti
ve
pa
t
h
i
s
t
o
you
r w
eb
p
r
o
j
ec
t w
o
r
k
i
ng
d
ir
ec
t
o
r
y
,
change
t
he
//
pa
r
a
m
e
t
e
r
o
f r
e
l
a
ti
ve
t
ype
t
o
A
SP
doc
.
C
onve
rt
To
V
ec
t
o
rIm
age
s(C
on
t
ex
t
Type
.
S
VG,
s
vg
fil
e
Dir
ec
t
o
r
y
,
"Sa
m
p
l
eS
VG
"
,
R
e
l
a
ti
veType
.A
SP
);
Convert
PDF
Document
to
TIFF
You can convert PDF document to TIFF file through the following code.
W
o
r
k
R
eg
i
s
tr
y
.
R
e
s
e
t();// i
nvoke
t
h
i
s
s
t
a
ti
c
m
e
t
hod
on
l
y
once
a
t t
he
beg
i
nn
i
ng
o
f
code
s
:
//l
oad
pd
f
docu
m
en
t
P
D
F
D
ocu
m
en
t
doc
=
ne
w
P
D
F
D
ocu
m
en
t(@
"c
:\
s
a
m
p
l
e
.
pd
f
"
);
//
conve
rt
P
D
F
t
o
T
I
FF
fil
e
and
s
ave
it t
o
s
pec
ifi
ed
fil
e
pa
t
h
doc
.
C
onve
rt
To
D
ocu
m
en
t(D
ocu
m
en
t
Type
.
T
I
FF
, @
"P
D
FToT
I
FF
.tiff
"
);
If
you
need
gene
r
a
t
e
t
he
tiff fil
e
wit
h
a
g
r
ea
t
e
r r
e
s
o
l
u
ti
on
(
o
r
b
i
gge
r
s
i
ze
)
you
can
u
s
e
t
he
f
o
ll
o
wi
ng
code
t
o
gene
r
a
t
e
an
x2
r
e
s
o
l
u
ti
on
tiff.
doc
.
C
onve
rt
To
D
ocu
m
en
t(D
ocu
m
en
t
Type
.
T
I
FF
,
2
.
0
f, @
"
C:\
x2
.tif
"
);
Convert
Other
Document
Types
to
PDF
File
You may also convert Word, Excel and TIFF document to PDF file.
//l
oad
W
o
r
d
docu
m
en
t
DOCXD
ocu
m
en
t
doc
=
ne
w DOCXD
ocu
m
en
t(@
"c
:\
s
a
m
p
l
e
w
o
r
d
.
docx"
);
//// l
oad
Exce
l
docu
m
en
t
//X
LS
XD
ocu
m
en
t
doc
=
ne
w X
LS
XD
ocu
m
en
t(@
"c
:\
s
a
m
p
l
ex
l.
x
l
s
x"
);
//// l
oad
T
iff
docu
m
en
t
//
T
I
FF
D
ocu
m
en
t
doc
=
ne
w
T
I
FF
D
ocu
m
en
t(@
"c
:\
s
a
m
p
l
eT
iff.
x
l
s
x"
);
//
conve
rt
docu
m
en
t t
o
P
D
F
fil
e
and
s
ave
it t
o
s
pec
ifi
ed
fil
e
pa
t
h
doc
.
C
onve
rt
To
D
ocu
m
en
t(D
ocu
m
en
t
Type
.
P
D
F
, @
"pd
fC
onve
rt
ed
.
pd
f
"
);
362
PDF
Annotations
RasterEdge Image enables developers to add annotations to PDF document page for
collaboration purpose. These annotation objects include text, free hand, line, lines, ellipse,
rectangle, rubber stamp, hotspot and embedded image. With PDF dll and Annotation dll
provided by RasterEdge Image, developers can:
x
Add rich annotations to pages in PDF document.
x
Added annotations can be flexibly and easily edited as independent objects
x
Free to resize, move, rotate and reshape annotation on PDF page
x
Adjust the font style of created text annotation on PDF document
x
enable to burn generated image annotations onto the native file format as embedded
images
You can find an online annotation demo at http://www.rasteredge.com/dotnet-imaging/web-
viewer-demo/.
To use functions above, the required assemblies are:
RasterEdge.Imaging.PDF.dll
RasterEdge.Imaging.Annotation.dll
RasterEdge.Imaging.Basic.dll
Sample code:
//
gene
r
a
t
e
t
he
anno
t
a
ti
on
ob
j
ec
t
//
c
r
ea
t
e
a
li
ne
anno
t
a
ti
on
s
t
a
rti
ng
a
t
po
i
n
t (
0
.
0
)
and
end
wit
h
//
po
i
n
t(
100
,
100
).
The
po
s
iti
on
m
ay
be
ad
j
u
s
t
ed
acco
r
d
i
ng
t
o
t
he
r
e
s
o
l
u
ti
on
a
t
//m
ea
s
u
r
e
m
en
t wit
h
t
he
de
f
au
lt r
e
s
o
l
u
ti
on
t
o
be
96
dp
i.
A
nno
t
a
ti
on
H
and
l
e
r
anno
=
A
nno
t
a
ti
on
G
ene
r
a
t
o
r.
Cr
ea
t
eL
i
ne
A
nno
t
a
ti
on
(
ne
w
R
a
s
t
e
r
Edge
.Im
ag
i
ng
.A
nno
t
a
ti
on
.
B
a
s
i
c
.
L
i
nePo
i
n
t(
0
,
0
),
ne
w
R
a
s
t
e
r
Edge
.Im
ag
i
ng
.A
nno
t
a
ti
on
.
B
a
s
i
c
.
L
i
nePo
i
n
t(
100
,
100
));
P
D
F
D
ocu
m
en
t
doc
=
ne
w
P
D
F
D
ocu
m
en
t(@
"c
:\
s
a
m
p
l
e
.
pd
f
"
);
P
D
FPage
page
=
(
P
D
FPage
)
doc
.G
e
t
Page
(
0
);
//
add
t
he
li
ne
anno
t
a
ti
on
on
t
he
pd
f
page
.
page
.A
dd
A
nno
t
a
ti
on
(
anno
);
doc
.
Save
(@
"c
:\
anno
t
a
t
edSa
m
p
l
e
.
pd
f
"
);
See Also Annotation
Create
Barcode
in
PDF
603
RasterEdge Barcode processing dll offers comprehensive functions for developers to generate
and design both 1d & 2d barcode images on PDF file.
Sample Code:
//
gene
r
a
t
e
a
code39
ba
r
code
L
i
nea
r li
nea
rB
a
r
code
=
ne
w
L
i
nea
r();
li
nea
rB
a
r
code
.
Type
=
B
a
r
codeType
.
COD
E39
;
li
nea
rB
a
r
code
.D
a
t
a
=
"123456789"
;
li
nea
rB
a
r
code
.
R
e
s
o
l
u
ti
on
=
96
;
li
nea
rB
a
r
code
.
R
o
t
a
t
e
=
R
o
t
a
t
e
.
R
o
t
a
t
e0
;
// l
oad
pd
f
docu
m
en
t,
you
can
a
l
s
o
l
oad
docu
m
en
t li
ke
tiff, w
o
r
d
,
exce
l,
pp
t
P
D
F
D
ocu
m
en
t
doc
=
ne
w
P
D
F
D
ocu
m
en
t(@
"c
:\
s
a
m
p
l
e
.
pd
f
"
);
//
ge
t t
he
firs
t
page
B
a
s
ePage
page
=
doc
.G
e
t
Page
(
0
);
//
gene
r
a
t
e
r
e
im
age
o
f t
h
i
s
ba
r
code
R
E
Im
age
ba
r
code
Im
age
=
li
nea
rB
a
r
code
.
To
Im
age
();
//
add
ba
r
code
im
age
t
o
t
he
firs
t
page
t
he
t
op
l
e
ft
ve
rt
ex
o
f
ba
r
code
im
age
r
ec
t
ang
l
e
i
s
a
t
po
i
n
t(
100
,
100
)
page
.A
dd
Im
age
(
ba
r
code
Im
age
,
ne
w
Sy
s
t
e
m.Dr
a
wi
ng
.
Po
i
n
t
F
(
100
f,
100
f));
//
s
ave
change
s
t
o
t
he
pd
f
doc
.
Save
(@
"c
:\
s
a
m
p
l
e
.
pd
f
"
);
See Also Barcode Create
Read
Barcode
from
PDF
You can read barcode information from pdf document.
Sample code:
pub
li
c
s
t
a
ti
c
vo
i
d
R
ead
B
a
r
codeF
r
o
m
P
D
F
(s
tri
ng
fil
ena
m
e
, i
n
t
page
I
ndex
)
{
//
gene
r
a
t
e
pd
f
docu
m
en
t
P
D
F
D
ocu
m
en
t
doc
=
ne
w
P
D
F
D
ocu
m
en
t(fil
ena
m
e
);
//
ge
t t
he
page
you
w
an
t t
o
r
ead
ba
r
code
fr
o
m
B
a
s
ePage
page
=
doc
.G
e
t
Page
(
page
I
ndex
);
//
s
e
t r
eade
r
s
e
tti
ng
R
eade
r
Se
tti
ng
s
s
e
tti
ng
=
ne
w
R
eade
r
Se
tti
ng
s();
s
e
tti
ng
.A
ddType
s
To
R
ead
(B
a
r
codeType
.
C
ode39
);
// r
ead
ou
t
ba
r
code
i
n
f
o
rm
a
ti
on
B
a
r
code
[]
ba
r
code
s
=
B
a
r
code
R
eade
r.
R
ead
B
a
r
code
s(s
e
tti
ng
,
page
);
//
ou
t
pu
t
ba
r
code
i
n
f
o
rm
a
ti
on
f
o
r
each
(B
a
r
code
ba
r
code
i
n
ba
r
code
s)
{
C
on
s
o
l
e
.Writ
eL
i
ne
(
ba
r
code
.D
a
t
aS
tri
ng
);
Documents you may be interested
Documents you may be interested