devexpress pdf viewer asp.net mvc : Convert few pages of pdf to word control Library platform web page .net winforms web browser Artefact0-part913

CHAPTER
1
GeneratePDFDocumentswith
Artefact
OlivierAuverlotandGuillaumeLarchevêquewithJohanFabry
TheAdobePDFformatisprobablyoneofthemostwidespreadelectronic
documentformats.Useddaily,itisthebasisfortheproductionofexchange-
abledocumentsthatcontainbothtextandgraphics.Ifyoureceiveabill,fol-
lowapurchaseonawebsite,downloadareport,abookoranadministrative
form,thesefileswillmostlikelybePDFdocuments.Forprogrammersthat
needtoprovideanysuchreportingfunctionality,supportingthisformathas
becomeamustandthegenerationofPDFdocumentsispartoftheirtoolkit.
InPharo,Artefactisaninnovativeframeworkthatsupportsthedesignand
generationofPDFdocumentsandisdevelopedbyOlivierAuverlotandGuil-
laumeLarcheveque.
1.1 OverviewofArtefact
ArtefactisaPDFframeworkwhosedesignwasguidedbythegoalsofeffi-
ciency,productivityandscalability.Toachievethis,eachdocumentisde-
scribedbyatreeofobjects.Adocumentisanobjectcontainingacollection
ofotherobjects,eachcorrespondingtoapage.Oneachpagebothvisibleand
non-visibleitemsarealsoobjects.Theseobjectsthenhavethepossibility
tobereusedinthesamedocumentbutalsoacrossdocuments.Objectsare
elementsthatcanbesimple,e.g.apieceoftextoranimage,butalsobecom-
plexelementswithadvancedbehaviorandaspecialappearance,e.g.that
displaydatainatableorgenerateabarcode.
Artefactcontainsdefaultelementssuchasparagraphsortablesthatallow
toquicklygeneratereports.Thestrengthoftheseelementsisthattheyare
1
Convert few pages of pdf to word - control Library 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
Convert few pages of pdf to word - control Library 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
GeneratePDFDocumentswithArtefact
independentofeachother.Theorderinwhichyoupositiontheminthedoc-
umentdoesnotaffecttheirappearance.ThisisincontrasttomanyPDF
frameworksthatexploitthenotionofstreaminthedefinitionofstyles(a
pieceofbluetextwillbefollowedbyanotherpieceofbluetextintheab-
senceofadirectivetouseadifferentstyle),Artefactconsidersthatevery
elementincludesitsownstyle.Ifanattributeisnotdefinedintheelement,
Artefactthenusesastylesheetthatissetatthedocumentlevelbydefault.
ThisautonomyofelementsandstylemanagementisastrongfeatureofArte-
fact.Itmakesiteasytogenerateadocumentandquicklycustomizeitfora
particularoperation.
Concepts,KeyAspectsandLimits
Aftermorethanayearofdevelopment,theconceptsusedinArtefactare
consideredstableanditisalreadyusedinindustry.Inthissectionwelistits
currentfeaturesandknownlimitations.
• Artefacthasasimplearchitecturethatfacilitatesscalabilityandnew
features.
• ItsupportsthedefinitionofaPDFdocumentanditscontents.
• Itcanspecifymetainformationsuchastitleorauthor.
• Itmanagesdisplayoptionswhenopeningadocumentinareaderthat
iscompatiblewiththisfeature.
• ItsupportscompressedPDFdocumentgeneration.
EachpageofaPDFdocumentcanhaveitsownparticularformatandorien-
tation.Bydefault,Artefactsupportsasetofcommonformats,e.g.A3,A4,
orebook.Itcaneasilybeextendedtofitspecificneeds.Pagelocationisde-
terminednotwhenthepageiscreatedbutwhenitisaddedtoadocument.
Henceeachpageisindependent,whichallowsonetogeneratedocuments
withvariablearchitecture.
Oneachpage,Artefactplacessimpleorcomplexelements.Acomplexele-
mentisgenerallydefinedusingsimpleelementsorothercomplexelements.
Eachelementisindependentandispositionedrelativetotheupperleftcor-
nerofapage.
ArtefactprovidesgreyscalemanagementandcolorsdefinedbytheRGB
model(whereeachcolorcomponentisrepresentedbyonebyte).Charac-
terfontsarethoseimposedbythePDFbutArtefactdoesnotsupporttrue
typefonts(TTF)specification.YoucaninsertimagesintoaPDFdocument
butonlytheJPEGformatiscurrentlysupported.Artefactdoesnotsupport
thedefinitionofinteractiveinputfields,integratingJavaScriptorsafetyas-
pectsofPDFsuchascertificates.Ofcourse,thesespecificationsaresubjectto
changeasandwhentheframeworkchanges.
2
control Library platform:C# TIFF: Extract Page(s) from TIFF File(s) Using C#.NET Code
Sometimes, a Tiff image file is large in size and only a few pages of Tiff document are useful to us, so we need to extract these useful pages from Tiff file.
www.rasteredge.com
control Library platform:C# PDF Page Insert Library: insert pages into PDF file in C#.net
application and Windows Forms project using a few lines of and inserting (empty) PDF page or pages from various file formats, such as PDF, Tiff, Word
www.rasteredge.com
1.2 GettingStartedin10Minutes
1.2 GettingStartedin10Minutes
Say,youalreadyprograminPharoandyouwanttogeneratePDFdocuments.
Thissectionwillshowyouhowtodosoinlessthan10minutes.
Firstyoushouldloadtheframework.Thegoodnewsisthatthereisnoneed
fornativelibrariesasArtefactiswrittenentirelyinPharo.Whateveryour
executionplatform(MicrosoftWindows,MacOSX,Linux,Android,IOS,etc.),
Artefactwillbeavailableandusable.
InstallingArtefact
ArtefactishostedonSmalltalkHub
1
.ToinstallArtefact,executethefollow-
ingexpressions:
Gofer new
smalltalkhubUser: '' ' project: 'RMoD/Artefact';
package: 'ConfigurationOfArtefact';
load.
ConfigurationOfArtefact load
LoadingtheconfigurationautomaticallyloadprojetssuchastheUnitframe-
work(whichsupportsthedefinitionofdifferentmeasurementunits.Byde-
faulttheconfigurationloadsthestableversionthatisproductionready.
Onceloaded,youcanbrowsethemainpackagesandclasses.
• The
Artefact-Examples
packagecontainsmanyusageexamples.
• The
Artefact-Core
packagecontainsthemainelementssuchasdoc-
uments,pagesorstylesheetsbutalsoelectronicdocumentationthatis
accessibleviatheHelpBrowser.
• ThePDFobjects(text,geometricshapes,images,etc.)offeredbythe
basicframeworkarein
Artefact-Core-Elements-Basic
and
Artefact-
Core-Elements-Composites
.
• Thefontsaredefinedinthepackage
Artefact-Core-Fonts
anddocu-
mentformatsinthepackage
Artefact-Core-Formats
.
ExecutingtheFirstDemo’s
ThebestwaytostartwithArtefactistohavealookatthe
Artefact-Examples-
Demos
packageandtoruneachof
PDFDemos
classmethods.
Ifyouwanttorunalldemos,justexecute
PDFDemos runAllDemos
1
http://smalltalkhub.com/#!/~RMoD/Artefact
3
control Library platform:C# Word - Insert Blank Word Page in C#.NET
server-side application and Windows Forms project using a few lines of delete Word page using C# .NET, how to reorganize Word document pages and how
www.rasteredge.com
control Library platform:C# PDF File Split Library: Split, seperate PDF into multiple files
files with a customized name pattern using a few lines of using which C# developers can split target PDF document file by specifying a page or pages.
www.rasteredge.com
GeneratePDFDocumentswithArtefact
BydefaulteachgenerationresultiswritteninthedefaultPharodirectory
butyoucandefineyourownbymodifyingthe
demoPath
classmethod,e.g.
asfollows:
PDFDemos class>>demoPath
^ '/Users/pharo/pdf/'
Finally”HelloWorld!”
YouwillnowcreateyourfirstandsimplestPDFdocument,whichisatext
onapage.Todothis,youmustdefineaninstanceofaPDFdocumentthat
containsapagewhereyouwillpositionatextcomponent.
PDFDocument new
exportTo: 'helloworld.pdf' asFileReference writeStream
Oncetheinstanceof
PDFDocument
iscreated,itisexportedusingastream
toafilenamed
helloworld.pdf
.Bydefault,theproducedPDFdocumentis
placedinthedirectoryofPharo.Ifyouopenthefile,itisempty.Thisisnor-
malsinceyouhavenotyetdefinedandaddedanycontenttothedocument.
Letusenrichthepreviousexampleandaddapagetothedocument.
PDFDocument new
add: PDFPage new;
exportTo: 'helloworld.pdf' asFileReference writeStream
Nowifyouopenthefiletheresultisdifferentsincethedocumentcontains
anemptypage.Letusaddafirsttextcomponenttoourpage.
PDFDocument new add:
(PDFPage new add:
(PDFTextElement new w text: 'Hello o World!'; ; from: 10mm @ @ 10mm));
exportTo: 'helloworld.pdf' asFileReference writeStream
Toplacethetextonthepagewecreateacomponentoftype
PDFTextEle-
ment
.Weaddittothepageanddefineitspositionusingthemessage
from:
.
Notethatwecanspecifydimensionsusingseveralunitssuchasmillimeters
(mm),centineters(cm)orinches(inch).Thesecoordinatesaredefinedfrom
theupperleftcornerofthepage.
Artefactusesasetofdefaultstogetcompactcodewhencreatingelements
thatarepartofadocument.Morespecifically,styleparametersaresetto
whatareconsideredthemostcommonvalues.Inthisexamplethepagefor-
matissettoA4,anditsorientationtoportrait.Also,textisbydefaultwrit-
teninblackusingtheHelveticafont.
Thisfirstexampleintroducedsomebasicconceptsandshowshowsimpleit
istoproduceaPDFdocumentwithPharo.Thefollowingsectionsgodeeper
inArtefactandshowhowtodefinemorecomplexdocuments.
4
control Library platform:VB.NET Word: Change Word Page Order & Sort Word Document Pages
paste method if there are a few pages that need Apart from this VB.NET Word pages sorting function powerful & profession imaging controls, PDF document, image
www.rasteredge.com
control Library platform:C# TIFF: How to Convert TIFF File to PDF Document in C# Project
Convert TIFF to PDF in C#.NET Overview. document using C# demo code within just a few seconds. Documents, forms, graphics and web pages can be converted to PDF
www.rasteredge.com
1.3 DocumentDefinition
1.3 DocumentDefinition
ArtefactrepresentsPDFdocumentsasobjectsthatareinstanceoftheclass
PDFDocument
.Theyplaytheroleofcontainersforreceivingpages.APDF-
Documentalsosupportsadvancedoptionssuchasthedocumentsize,man-
agementofcompression,theopeninginthePDFreaderandthedefinitionof
metainformation.
Theorderinwhichpagesareaddedtothe
PDFDocument
objectdefinethe
organizationofdatawithinthedocument,nottheorderinwhichthepages
arecreated.Thismodeofoperationallowsyoutoproducedocumentswhose
contentscanbedynamicallygeneratedandorganizedatalatertime.
PageAddition
Toaddpagestoadocument,themessage
add:
isused.Itappendsapage
afterthosealreadypresentinthedocument.WhengeneratingthePDFfile,
Artefacttraversesthelistofpagesstartingfromtheearliestaddedtothe
last.Thefollowingscriptdefinesadocumentwithasingleblankpage.
PDFDocument new
add: PDFPage new;
exportTo: 'EmptyPage.pdf' asFileReference writeStream
DocumentProperties
APDFDocumentcanbeconfiguredwithaspecificformat,orientation,com-
pressionanddisplaymode,asweshownext.
DocumentFormatandOrientation
Bydefault,adocumentisgeneratedintheA4formatbutotherformatsare
available.ThePackage
Artefact-Core-Formats
containsalistofprede-
finedformatscoveringmanyneeds.Examplesare:A3(
PDFA3Format
),letter
size(
PDFLetterFormat
)andaformatsuitablefore-readers(
PDFEbookFormat
).
Ifyouneedaparticularformat,youcandefineit.Aformatissimplydefined
bythevaluereturnedbythemessage
defaultSize
.
A
PDFDocument
acceptsthemessage
format:
tospecifytheformatofall
pagesofthedocument.Foreachpage,thisvaluewillbethedefaultifnot
redefinedotherwise.Eachpagecanspecifyadifferentformat.Thefollowing
examplecreatesadocumentusingtheA3format:
PDFDocument new
format: PDFA3Format new;
add: PDFPage new;
exportTo: 'A3.pdf' asFileReference writeStream
5
control Library platform:VB.NET Create PDF Library SDK to convert PDF from other file
Best VB.NET component to convert Microsoft Office Word, Excel applications to create PDF with just a few VB.NET to create a PDF document with 2 empty pages.
www.rasteredge.com
control Library platform:C# Word - Split Word Document in C#.NET
files with a customized name pattern using a few lines of using which C# developers can split target Word document file by specifying a page or pages.
www.rasteredge.com
GeneratePDFDocumentswithArtefact
Theabstractsuperclassofallformats(
PDFFormat
)isresponsiblefordefining
thepageorientation.Therearetwoalternatives:portraitorlandscape.Page
orientationissetbysendingoneofthetwomessagestotheformatobject:
setPortrait
and
setLandscape
.
ThefollowingexamplegeneratesadocumentwhosepagesareinA3format
andlandscapeorientation.
PDFDocument new
format: PDFA3Format new setLandscape;
add: PDFPage new;
exportTo: 'A3landscape.pdf' ' asFileReference writeStream
Notethatsettingthedefaultlandscapemodeforadocumentdoesnotex-
cludethepossibilityforaparticularpagetobeorientedinportraitmode.
Artefactfullysupportspagesofdifferentsizesanddifferentorientations
withinasingledocument.
Compression
ThePDFformatallowsyoutocompressthedata,whichisagoodthingasa
PDFdocumentcancontainlargeamountsofdata.Totominimizetheweight
ofgenerateddocumentsArtefactdefaultstocompressingthedata.Ifyou
needtodisablethisoption,youshouldsendthe
uncompressed
messageto
thedocument.
ThefollowingexamplegeneratesanuncompressedPDFdocument:
PDFDocument new
uncompressed;
add: PDFPage new;
exportTo: 'uncompressed.pdf' ' asFileReference writeStream
Anothermessage,named
compressed
,setsthecompression.
ControlingDocumentOpening
AdobeAcrobatreadersupportsvariousdisplaymodeswhenopeningaPDF
document.TheselectedmodeisdefineddirectlyintothePDFdocument.
NotethatifthePDFreaderthatisusedtolookatthedocumentisnotcom-
patiblewiththeseoptions,theywillbeignored.
Displaymodepropertiesaredividedintwocategories:thosedetermining
thesizeofthepagesandthoserelatedtothepageorganizationonthescreen.
Theformeraresetusingthemessages
fullPage
,
fullWidth
,
real
and
zoom:
,
andthelatterusing
singlepage
,
twoPages
and
continuousPages
.These
messagesshouldbesenttoan
PDFDocument
instance.
With
fullPage
,eachpageofthedocumentoccupiestheentiredisplayspace.
With
fullWidth
,thedisplayisoptimizedtothepagewidth.With
real
,the
displaymeetsthedimensionsspecifiedinthePDFdocument.
6
control Library platform:C# Word - Process Word Document in C#
It enables you to move out useless Word document pages simply with a few lines of C# code. C#.NET: Sort Word Document Pages Order.
www.rasteredge.com
control Library platform:Online Convert PDF file to Word. Best free online PDF Conversion
make it as easy as possible to convert your Tiff settings and the conversion only takes a few seconds. Tiff image with single page or multiple pages is supported
www.rasteredge.com
1.3 DocumentDefinition
Thefollowingexamplecreatesadocumentthatwilloccupyallavailabledis-
playspace:
pdfdoc := = PDFDocument t new w fullPage.
Withthemessage
zoom:
,youcandefineazomingratio,expressedinper-
centages.Thefollowingexampledefinesthatthedocumentshouldbeopened
withzoomof400percent.
pdfdoc := = PDFDocument t new w zoom: 400.
Youcanalsochoosetodisplayasinglepage(
singlePage
),pagestwobytwo
(
twoPages
)oroneaftertheother(
continousPages
)asinthefollowingex-
ample:
pdfdoc := = PDFDocument t new w continousPages.
Thesesmessagescanbecombinedasshowninthefollowingexample:
pdfdoc := = PDFDocument t new w zoom: 200; continuousPages.
SettingMetaInformation
EachPDFdocumentcontainsasetofinformationaboutitsorigins.These
dataarenottobeoverlooked,especiallyifyourdocumentisintendedtocon-
tributetoanEDM(ElectronicDocumentManagement)systemorispartof
aneditorialworkflow.Withthisinformationitispossibletosearchamonga
setofPDFdocumentsandselect,forexample,thosewrittenbyaparticular
authororthoseforwhichcertainkeywordshavebeenspecified.
Artefactimplementsthisinformationbyusinganinstanceof
PDFMetaData
.
Toeachinstanceof
PDFDocument
,aninstanceof
PDFMetaData
isassociated
andisaccessibleusingthemessage
metaData
.Bydefault,theproducerisset
to
'Artefact'
.Youcanspecifythedocumenttitle,subjectorashortsum-
mary,thenameoftheauthor,alistofkeywordsandthedocumentcreator.
Thefollowingexamplegeneratesanewdocumentanditsmetadatainforma-
tion:
pdfdoc := = PDFDocument t new.
pdfdoc metaData
title: 'Document title';
subject: 'subject t of f the document';
author: 'The Pasta Team';
keywords: 'cool rock best';
creator: 'Pharo'.
7
GeneratePDFDocumentswithArtefact
1.4 Pages,FormatsandModels
PagesarethesupportforwritinganddrawinginyourPDFdocuments.A
pagedefinesapagesize,orientationandpositionwithinaPDFdocument.A
pagecanbebuiltfromamodelthatprovidesanoverlayonwhichthepage
contentsaredeposited.
PageCreation
Apageisrepresentedbyaninstanceoftheclass
PDFPage
.Creatingisapage
issimplydonebysendingthemessage
new
totheclass.
page := PDFPage new.
Sendingthemessage
add:
toadocumentwithapageasargumentwillap-
pendthepagetothedocument.
pdfdoc := = PDFDocument t new.
page := PDFPage new.
pdfdoc add: page.
Bydefault,apagetakesthedimensionsandorientationofitsdocument.If
yourPDFdocumentisA4landscape,alladdedpageswillusethesesettings.
However,Artefactcanassignspecificdimensionsandorientationtoeach
page,allowingonedocumenttohaveamixofpageswithdifferentcharac-
teristics.Toallowthis,eachinstanceof
PDFPage
understandsthemessage
format:
,whichtakesaninstanceof
PDFFormat
asargument.
Thefollowingexamplecreatesatwo-pagedocument.Thefirstusesthede-
faultformatofthedocument,thesecondisinA4landscape.
pdfdoc := = PDFDocument t new.
page1 := = PDFPage e new.
page2 := = PDFPage e new w format: : (PDFA3Format t new setLandscape).
pdfdoc add: page1; ; add: page2.
Templates
Atemplateisaninstanceofclass
PDFTemplate
,whichinheritsfromthe
class
PDFPage
.Itisapagewithpredefinedcontentsthatwillactastheback-
groundpageonwhichyouwilldraworaddyourcomponents.Forexample,
itcanbecomposedofaheaderforaletter,aheaderandafooterforareport,
oradelimitedsurface.
Thepackage
Artefact-Examples-Demos-Templates
offerstwoexample
oftemplatetocreateCDorDVDsleevepages.Thefollowingcodesnippet
producesaA4pageonwhichtheoutlinesofaCDsleevearedrawn.
pdfdoc := = PDFDocument t new.
cover := = PDFCompactDiscTemplate new.
8
1.5 Elements
Atemplateisdefinedusingthemessage
drawTemplate
whichaddstheArte-
factelementstothepage.Thisbuildsthepagebackground.Forexample,the
codeoftheCDtemplateisbelow.(Asitisrelativelystraightforwardwedo
notexplainthecodehere.)
PDFCompactDiscTemplate>>drawTemplate
self add: ((PDFRectElement
from: 10 0 mm m @ @ 10 0 mm
dimension: 240 0 mm m @ @ 120 0 mm)
dotted: self f dotted
).
self add: ((PDFLineElement
from: 130mm @ @ 10mm
to: 130mm m @ 130mm)
dotted: self f dotted
).
1.5 Elements
Thecontentsofpagesisdefinedusingreusablecomponentscalledelements.
Artefacthasbasicelementsthatperformsimpleoperationssuchasdrawing
aline,butalsocomplexelementsthatcan,forexample,displaydatainata-
bleorgenerateabarcode.Ofcourse,itispossibletoidentifyanddefinenew
components.
Morespecifically,a
PDFElement
isareusablecomponentthatrepresentsa
text,animage,ageometricshapeorevenacomplexgraphortable.There
aretwokindsof
PDFElement
:
• Simpleelementsinheritfrom
PDFBasic
(aprimitiveoperationinthe
pdfspecification).
• Compositeelementsinheritfrom
PDFComposite
(awrapperaround
multiple
PDFElements
whethertheyarebasicorcomposite).
Simpleelementsareasfollows,andtheirhierarchyisshowninFigure1.1:
PDFBezierCurveElement
PDFCircleElement
PDFLineElement
PDFPolygonElement
PDFRectElement
PDFJpegElement
PDFTextElement
Compositeelementsareasfollows,andtheirhierarchyisshowninFigure
1.2:
9
Figure1.1 PageandDocumentElements
Figure1.2 CompositeElements
10
Documents you may be interested
Documents you may be interested