asp.net open pdf file in web browser using c# : Change font size pdf SDK Library service wpf asp.net azure dnn ibex10-part264

Images
95
Chapter16
Images
Images are e added d to o the document t using either the external-graphic or
instream-foreign-objectelements.Theexternal-graphicelementisusedtoincludeafile
inJPEG,GIF,TIFF,BMP, SVGorPNGformats. Theinstream-foreign-objectelementis
usedtoincludeanimagedefinedinScalableVectorGraphics(SVG)formatwherethe
imageSVGiscontainedwithintheFO.
The properties s used to format t the external-graphic and instream-foreign-object
elementsarethesame.
Thesizeoftheimageisdistinctfromthesizeoftheareainwhichtheimageisplaced.
The height and width attributes on the external-graphic or instream-foreign-object
element specifythe size of the areainto whichthe graphic will be placed. Ifthese
propertiesarenotspecifiedtheydefaulttoanarealargeenoughtocontaintheimage.
Thecontent-widthandcontent-heightattributescontrolthesizeoftheimage.These
can be values such as "3cm" or percentages such as s "120%". . If content-width and
content-heightnot specifiedthe image defaultstothe size inpixelsspecifiedinthe
imagefileitself.Thismeansthatifyoudonotspecifyanyoftheaboveattributesthe
imagewillbeaslargeasspecifiedintheimagefile,andwillbeplacedinanareathe
samesize.
Thedotsperinch(dpi)valueoftheimagemakesadifferencetotheimagesize.Two
imagescanhavethesamedimensionsinpixelsbutappeardifferentsizesinthePDF
file.ThisisbecauseIbexusesthedpivaluetoworkoutthesizeoftheimage.Animage
whichis300pixelswideandstoredat300dpiwillbe1inchwide.Thesameimage
storedat100dpiwillbe3incheswide.
Animageisaninlineelement,soforformattingpurposesitcanbeplacedinasentence
surroundedbytextandistreatedasasingleword.
16.1 Imagebasics
Theexternal-graphicelementisusedtoincludeanimagewhichisinafileexternaltothe
FOfile.Thenameofthefiletobeincludedisspecifiedusingthesrcattribute.
Change font size pdf - Compress reduce PDF size in C#.net, ASP.NET, MVC, Ajax, WinForms, WPF
C# Code & .NET API to Compress & Decompress PDF Document
adjust size of pdf in preview; change font size in fillable pdf
Change font size pdf - VB.NET PDF File Compress Library: Compress reduce PDF size in vb.net, ASP.NET, MVC, Ajax, WinForms, WPF
VB.NET PDF Document Compression and Decompression Control SDK
pdf page size; reduce pdf file size
IbexPDFCreator
DevelopersGuide
96
Images
Thesrcattributeiscalledauri-specificationandmustfollowthefollowingrules:
Asequenceofcharactersthatis"url(",followedbyoptionalwhitespace,
followed by an optional single e quote (') ) or double e quote (") ) character,
followed by a URI reference e as s defined in [RFC2396], , followed d by an
optionalsinglequote(')ordoublequote(")character,followedbyoptional
whitespace,followedby")".Thetwoquotecharactersmustbethesame
andmustbothbepresentorabsent.IftheURIreferencecontainsasingle
quote,thetwoquotecharactersmustbepresentandbedoublequotes.
Thismeansthefollowingareallvalidvaluesforthesrcattribute:
uri(ibex.jpg)
uri("ibex.jpg")
uri('ibex.jpg')
url(http://www.xmlpdf.com/images/download2.gif)
AsthesrcattributeisaURL,animagewhichexistsonawebservercanbedownloaded
automaticallybyIbexasthePDFfileiscreated.Thisiscommoninrealestateandcatalog
applicationsandmeansyoudonotneedtomakeacopyofanexistingimagejusttoget
itintothePDFfile.TheFOshowninFigure16-1willfetchthefiledownload2.giffrom
www.xmlpdf.com.TheresultingimageisshowninFigure16-2.
Figure16-1:
FOtoinsertanimage
fromawebserver
<block space-before="6pt">
<external-graphic border="1pt solid d black"
src="url(http://www.xmlpdf.com/images/download2.gif)"
content-width="200%" content-height="200%"/>
</block>
Figure16-2:
Imageincludedfrom
webserver
Theexternal-graphicelementcanbeusedtoincludeimagefilesinPNG,JPEG,TIFF,BMP
andGIFformats.ItcanalsobeusedtoincludeSVGimagesheldinexternalfiles.
Theinline-foreign-objectisusedforloadingimagesfromSVGcontentthatiscontained
inlineintheFO.SeeSVGImagesonpage107.
16.2 Makinganimagefitaspecifiedspace
Tomakeanimagefitaspecifiedsizeusetheheightandwidthattributestospecifythe
sizeoftheexternal-graphicelement,andthenusethecontent-widthandcontent-height
tofittheimagetothatsize.
Forexampletofitanimageintoanarea2cmx2cm,setthewidthandheightattributes
to"2cm"andsetthecontent-widthandcontent-heightattributesto"scale-to-fit",as
showninFigure16-3.
C# PDF insert text Library: insert text into PDF content in C#.net
Powerful .NET PDF edit control allows modify existing scanned PDF text. Ability to change text font, color, size and location and output a new PDF document.
pdf custom paper size; change font size fillable pdf
C# PDF Annotate Library: Draw, edit PDF annotation, markups in C#.
Able to edit and change PDF annotation properties such as font size or color. Abilities to draw markups on PDF document or stamp on PDF file.
adjust size of pdf; best pdf compression tool
IbexPDFCreator
DevelopersGuide
Images
97
Figure16-3:
Scalinganimage
<fo:external-graphic src="url(image.jpg)"
height="2in" width="2in"
content-height="scale-to-fit"
content-width="scale-to-fit"/>
Ifyouonlywanttheimagereducedinsizetofitthespecifiedareaanddonotwantit
increased in size if it t is s smaller, , specify y content-width="scale-down-to-fit". This also
appliestocontent-height.
Ifyouonlywanttheimageenlargedtofitthespecifiedareaanddonotwantitreduced
in size if it t is s larger, specify content-width="scale-up-to-fit". This also applies to
content-height.
16.3 Clipping
Ifthe image islargerthanthe area inwhichitiscontainedthenthe image maybe
clipped.Figure16-4showsanimageatitsnaturalsize,basedonthepixelsanddpivalues
readfromtheimagefile.Ifwespecifytheheightoftheexternal-graphicelementas
2.5cmandspecifyoverflow="hidden",theimagewillbeclippedtothisheight,asshown
inFigure16-5.
Figure16-4:
Imageatnaturalsize
Figure16-5:
Clippedimage
C# PDF Sticky Note Library: add, delete, update PDF note in C#.net
Allow users to add comments online in ASPX webpage. Able to change font size in PDF comment box. Able to save and print sticky notes in PDF file.
change pdf page size; change file size of pdf
C# PDF Convert to Word SDK: Convert PDF to Word library in C#.net
PDF document, keeps the elements (like images, tables and chats) of original PDF file and maintains the original text style (including font, size, color, links
adjusting page size in pdf; change paper size pdf
IbexPDFCreator
DevelopersGuide
98
Images
Ifwespecifytheheightoftheexternal-graphic
element as 2.5cm
and do not t specify
overflow="hidden", the image will not be
clippedtothisheight,andwilloverwriteother
content as shown to o the right. Because the
imageispositionedonthesamebaselineastext,
the overflow will l be e at t the top of the area
containingtheimage.
16.4 Imagesizeandalignment
Ifanimageissmallerthanthecontainingareawecancontrolwhereitappearsinthat
areausingthedisplay-alignandtext-alignattributes.Thedisplay-alignattributecontrols
theverticalalignment,text-aligncontrolsthehorizontalalignment.Bydefaulttheimage
appearsin the e top left corner of f the e inline area created bythe external-graphic or
instream-foreign-objectelement,asshowninFigure16-6.
Figure16-6:
Defaultalignmentof
animage
Ifwespecifytext-align="center"theimagewillmovetothehorizontalcenterofthe
inlinearea,asshowninFigure16-7.
Figure16-7:
Usingtext-align=
'center'
Generate Barcodes in Web Image Viewer| Online Tutorials
Select "Generate" to process barcode generation; Change Barcode Properties. Select "Font" to choose human-readable text font style, color, size and effects;
best way to compress pdf files; pdf page size limit
C# PDF Field Edit Library: insert, delete, update pdf form field
Able to add text field to specified PDF file position in C#.NET class. Support to change font size in PDF form. Able to delete form fields from adobe PDF file.
adjust size of pdf file; change font size pdf form reader
IbexPDFCreator
DevelopersGuide
Images
99
Ifwespecifytext-align="right"theimagewillmove totherightoftheinlineareaas
showninFigure16-8.
Figure16-8:
Rightalignedimage
Ifwespecifytext-align="center"anddisplay-align="center"theimagewillmovetothe
horizontalandverticalcenteroftheinlinearea,asshowninFigure16-9.
Figure16-9:
Verticallyand
horizontallycentered
image
16.4.1 Leading
LookingattheimageinFigure16-10youcanseeagapbetweenthetopoftheimageand
theborder.Thisistheleading,whichappearsbecausetheimageistreatedasatext
elementandsitsonthebaseline.Theamountofleadingisderivedfromthefontsize,so
youcanreduceittozerobysettingthefontsizetozero,byspecifyingfont-size="0pt"
onthecontainingblockelement.ThishasbeendoneinFigure16-11.
Figure16-10:
Imagewithleading
aboveit
VB.NET Image: Visual Basic .NET Guide to Draw Text on Image in .
Please note that you can change some of the example, you can adjust the text font, font size, font type (regular LoadImage) Dim DrawFont As New Font("Arial", 16
reader pdf reduce file size; change font size in fillable pdf form
C# Image: Use C# Class to Insert Callout Annotation on Images
Easy to set annotation filled font property individually Support adjusting callout annotation size parameter in an easy way; C# demo code to change the filled
pdf compression; pdf markup text size
IbexPDFCreator
DevelopersGuide
100
Images
Figure16-11:
Usingwithleading
removed
16.5 Imageresolution
Theresolutionofanimageindotsperinch(dpi)canbesetusingthedpiattributeonthe
external-graphicelement.Settingthisattributeoverridesthedpivaluereadfromthe
imagefile.
Settingthedpitoalowervaluethantheonespecifiedintheimagewillresultinsmaller
imageoflowerqualitythantheoriginal.Thisisoftendonetoreducethesizeofthe
imageinthePDFfileandcanresultinmassivedecreasesinPDFfilesize.Ifyouhavean
imagewhichisstoredat2400dpi,andyourenduserwilldisplayitona96dpiscreenor
printiton600dpiprinter,reducingtheimagedpito600willnoteffecttheappearance
oftheimage.
Settingthedpitoavaluehigherthanthevaluereadfromtheimagefilehasnoeffect.
IfforexampleifwewantedtostoreanimageinthePDFfileat1200dpi,wewoulduse
theFOshowninFigure16-12.
Figure16-12:
FOtosetimagedpi
<block space-before="6pt">
<external-graphic border="1pt solid black"
src="url(http://www.xmlpdf.com/images/download2.gif)"
content-width="200%" content-height="200%"
dpi="1200"/>
</block>
ThedpiattributeisanIbexextension.ItisnotpartoftheXSL-FOstandard.
16.6 Imageanti-aliasing
Imagesareanti-aliasedbydefault.Thiscanbedisabledusingtheibex:anti-aliasattribute
asshowninfigureFigure16-13.
Figure16-13:
FOtodisable
anti-aliasing
<block space-before="6pt">
<external-graphic
src="url(http://www.xmlpdf.com/images/download2.gif)"
ibex:anti-alias="false"
dpi="1200"/>
</block>
Figure16-14showstwoimages,theleftrightonehasanti-aliasingdisabledsotheedges
oftheimageappearmoreclearly.
IbexPDFCreator
DevelopersGuide
Images
101
Figure16-14:
Imageswithand
withoutanti-aliasing
Theibex:anti-aliasattributeisanIbexextension.ItisnotpartoftheXSL-FOstandard.
16.7 Loadinganimagefrommemory
Ibex has the facility y to load an image whichis stored in memory. . This s permits an
applicationtodynamicallygenerateanimageortoloadanimagefromadatabasefor
inclusioninthePDFfile.
Theimage mustbepassedtoIbex inabytearrayoraStream(fromthe System.IO
namespace).
TheimagemustbegivenauniqueidentifierbywhichitcanberetrievedduringthePDF
creationprocess.ThisisdoneusingtheaddNamedImage()methodontheFODocument
object.Thismethodtakestwoparameters;(1)astringwhichidentifiestheimageand(2)
thestreamorarraywhichcontainstheimageitself.
Forexampleifwehadanimageinabytearraycalled"image"andwewantedtogiveit
theidentifier"1029"wewouldusethecodeshowninFigure16-15todothis.
Figure16-15:
C#codetoloadan
imagefrommemory
byte[] image e = = ... dynamically create
FODocument document = new FODocument();
document.addNamedImage( "1029", image e );
Thismustbedonebeforecallinggenerate()tocreatethePDFfile.
Within the e FO file the image e is s retrieved frommemory using the e syntax x shown in
Figure16-16
Figure16-16:
FOtoloadanimage
frommemory
<external-graphic src="url(data:application/ibex-image,1029)"/>
The value of f the src attribute must be the string "url(data:application/ibex-image,"
followedbytheuniqueidentifierwhichwaspassedtoaddNamedImage().
ThissyntaxfortheurlattributeconformstoRFC2397-The"data"URLscheme(which
canbefoundathttp://www.faqs.org/rfcs/rfc2397.html).
IbexPDFCreator
DevelopersGuide
102
Images
16.8 TransparentImages
16.8.1 TransparentGIFimages
GIFimageswhichhavetransparentareasaresupported.TheFOinFigure16-17places
thesametransparentGIFimageontwodifferentbackgrounds.TheoutputfromthisFO
isshowninFigure16-18.
Figure16-17:
FOfortransparent
image
<block background-color="blue">
<external-graphic src="url(ibm-logo.gif)" content-height="2cm"/>
</block>
<block background-color="black">
<external-graphic src="url(ibm-logo.gif)" content-height="2cm"/>
</block>
Figure16-18:
TransparentGIF
images
16.8.2 TransparentPNGimages
PNGimageswhichhavetransparentareasaresupported.TheFOinFigure16-19placesa
transparentPNGimageonawhitebackgrounds.TheoutputfromthisFOisshownin
Figure16-20.
Figure16-19:
FOfortransparent
image
<block background-color="white">
<external-graphic src="url(RedbrushAlpha-0.25.png)" content-height="2cm"/>
</block>
Figure16-20:
TransparentPNG
image
16.8.3 Transparentimagesusingmasking
Ibexcanuseimagemaskingtomakesomepartsofanimageappeartransparent.Thisis
anextensiontotheXSL-FOstandard.
Imagemaskingworksbydefiningcolorsfromtheimagewhichshouldnotbedisplayed.
ThePDFviewerwillcompareeachpixelintheimagewiththe maskandnotdisplay
IbexPDFCreator
DevelopersGuide
Images
103
pixelswhichmatchthemask,effectivelymakingthesepixelstransparentandsoleaving
visiblethecontentbehindtheimage.
Theimagemaskisdefinedusingthe<ibex:mask>element,whichmustbecontained
withinanexternal-graphicelement,asshowninFigure16-21.
Figure16-21:
FOtomaskanimage
<external-graphic src="url(ixsl.jpg)"
z-index='10'>
<ibex:mask
red-min="255" red-max="255"
green-min="255" green-max="255"
blue-min="255" blue-max="255"/>
</external-graphic>
Tousetheibex:maskelementyoumustreferencetheibexnamespaceinyourFOas
showninFigure16-22.
Figure16-22:
Referencingtheibex
namespace
<root
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:ibex="http://www.xmlpdf.com/2003/ibex/Format">
Themaskdefinestheminimumandmaximumvaluesforeachofthered,greenandblue
componentsofanimage.Amaskusingthesevaluesisapplicableonlytoimageswhich
areinRGBformatwith24bitsperpixel.
ForCMYKimages,attributescalledc-min,c-max,m-min,m-max,y-min,y-max,k-minand
k-maxdefinetheminimumandmaximumvaluesforeachofthecyan,magenta,yellow
andblackcomponentsoftheimage.
The image e mask k shownabove causes any pixel which has red=255, green=255 5 and
blue=255tonotberendered.Asapixelwithred,greenandblueallequalto255iswhite,
thismeansanywhitepixelswillnotberendered.
Figure16-23showssometextoverwhichwehaveplacedanimagewithredandblack
lettersonawhitebackground.
Figure16-23:
Imageplacedover
text
This is some text that will be behind the image. This is
some text that will be behind the image. This is some text
that will be behind the image. This is some text that will
be behind the image. This is some text that will be behind
the image. This is some text that will be behind the
image. This is some text that will be behind the image.
This is some text that will be behind the image.
If we e add a mask to o eliminate e white pixels the image then n appears as shown in
Figure16-24.
Figure16-24:
Imagewithmasking
This is some text that will be behind the image. This is
some text that will be behind the image. This is some text
that will be behind the image. This is some text that will
be behind the image. This is some text that will be behind
the image.
16.8.4 TransparentImagesusingSVG
TransparentimagescanalsobeimplementedbyplacingaSVGimageoverthetopof
othercontent.ThisapproachusesthevectorSVGrendererintroducedinIbex2.1.2andis
IbexPDFCreator
DevelopersGuide
104
Images
onlyavailablewhenusing.NET1.1orhigher.Thisisthebestapproachfortransparent
imagesbecause (a)there is no backgroundonthe SVG image sothe bestclarityis
achieved,and(b)SVGusesavectorrendererwhichcreatesasmallerPDFfilethanyou
wouldgetusingabitmapimage.
Figure16-25showstheFOtoputtheword"ibex"oversometext.Theresultingoutputis
showninFigure16-26.
Figure16-25:
FOusingSVGtoplace
contentovertext
<block-container>
<block-container space-before="6pt"
absolute-position="absolute" top="-1.6cm"
left="5cm">
<block>
<instream-foreign-object z-index="30">
<svg width="315" height="100"
xmlns="http://www.w3.org/2000/svg">
<text
x="30" y="60" " fill="blue" stroke="blue"
font-size="61pt" font-style="italic"
style="font-family:arial;stroke-width:0.5">
Ibex
</text>
</svg>
</instream-foreign-object>
</block>
</block-container>
</block-container>
Figure16-26:
Textoverlaidusing
SVG
This is some text which will be behind the image. This is some text
which will be behind the image. This is some text which will be
behind the image. This is some text which will be behind the image.
This is some text which will be behind the image. This is some text
which will be behind the image. This is some text which will be
behind the image. This is some text which will be behind the image.
Ibex
16.9 Networkcredentialsusedinaccessingimages
IbexcanretrieveimagesfromHTTPserversasshowninFigure16-27below.Bydefault
IbexwilldothisusingthecredentialsoftheprocesswhichiscreatingthePDFfile.IfIbex
isrunninginanASP.NETserverthenthedefaultconfigurationisthatASPrunsasthe
ASPNETuser.Thisuserdoesnothavepermissionstoaccessotherserversandsowillnot
beabletoretrieveimagesfromotherservers.
Figure16-27:
FOtoinsertanimage
fromanHTTPserver
<block space-before="6pt">
<external-graphic border="1pt solid black"
src="url(http://www.xmlpdf.com/images/download2.gif)"
content-width="200%" content-height="200%"/>
</block>
The FODocumentobjectsupportsthe setNetworkCredentials()method. Thismethod
takes4parameters,asshowninFigure16-28.
Figure16-28:
The
setNetworkCredential
smethod
public void setNetworkCredentials(
string prefix,
string username,
string password,
string domain )
Documents you may be interested
Documents you may be interested