mvc return pdf : C# convert pdf to text file SDK software project wpf winforms azure UWP mongodb0-part1563

C# convert pdf to text file - SDK software project:C# PDF Convert to Text SDK: Convert PDF to txt files in C#.net, ASP.NET MVC, WinForms, WPF application
C# PDF to Text (TXT) Converting Library to Convert PDF to Text
www.rasteredge.com
C# convert pdf to text file - SDK software project:VB.NET PDF Convert to Text SDK: Convert PDF to txt files in vb.net, ASP.NET MVC, WinForms, WPF application
VB.NET Guide and Sample Codes to Convert PDF to Text in .NET Project
www.rasteredge.com
AboutThisBook
License
TheLittleMongoDBBookbookislicensedundertheAttribution-NonCommercial3.0Unportedlicense.Youshouldnot
havepaidforthisbook.
Youarebasically free to copy,distribute, modify or displaythe book. However,I I askthatyoualways attribute the
booktome,KarlSeguinanddonotuseitforcommercialpurposes.
Youcanseethefulltextofthelicenseat:
http://creativecommons.org/licenses/by-nc/3.0/legalcode
AboutTheAuthor
Karl Seguinis a developer r with h experience e across s various s fields and d technologies. He’s s an expert .NET and d Ruby
developer. He’sasemi-activecontributor r toOSSprojects,atechnicalwriterand anoccasionalspeaker. . Withrespect
toMongoDB,hewasacorecontributortotheC#MongoDBlibraryNoRM,wrotetheinteractivetutorialmonglyaswell
astheMongoWeb Admin. His s freeserviceforcasualgamedevelopers,mogade.com,ispoweredbyMongoDB.
KarlhassincewrittenTheLittleRedisBook
Hisblogcanbefoundathttp://openmymind.net,andhetweetsvia[@karlseguin](http://twitter.com/karlseguin)
WithThanksTo
AspecialthankstoPerryNealforlendingmehiseyes,mindandpassion. Youprovidedmewithinvaluablehelp. Thank
you.
LatestVersion
ThisversionwasupdatedforMongoDB2.6byAsyaKamsky.Thelatestsourceofthisbookis availableat:
http://github.com/karlseguin/the-little-mongodb-book.
1
SDK software project:C# PDF Text Extract Library: extract text content from PDF file in
How to C#: Extract Text Content from PDF File. Add necessary references: RasterEdge.Imaging.Basic.dll. RasterEdge.Imaging.Basic.Codec.dll.
www.rasteredge.com
SDK software project:C# PDF Convert to Jpeg SDK: Convert PDF to JPEG images in C#.net
In the following example, this C#.NET PDF to JPEG converter library will name the converted JPEG image file Output.jpg. Convert PDF to JPEG Using C#.NET.
www.rasteredge.com
Introduction
It’snotmyfaultthechaptersareshort,MongoDBisjusteasytolearn.
Itisoftensaidthattechnologymovesatablazingpace. It’struethatthereisanevergrowinglistofnewtechnologies
and techniques being released. However, , I’ve long g been n ofthe e opinionthat the fundamental technologies used by
programmersmoveata rather slowpace. . Onecouldspend d yearslearning littleyetremainrelevant. . Whatisstriking
thoughisthespeedatwhichestablishedtechnologiesgetreplaced.Seeminglyovernight,long-establishedtechnologies
findthemselvesthreatenedbyshiftsindeveloperfocus.
Nothing could be more representative of this sudden shift t than the e progress of NoSQL technologies against well-
established relationaldatabases. . Italmost t seemslike oneday the webwas being drivenbyafewRDBMSs,and the
next,fiveorsoNoSQLsolutionshadestablished themselvesas worthysolutions.
Eventhoughthese transitionsseem tohappenovernight,the realityisthat theycantakeyearsto becomeaccepted
practice.Theinitialenthusiasmisdrivenbyarelativelysmallsetofdevelopers andcompanies. . Solutionsarerefined,
lessons learned and seeing that anewtechnologyis here to stay,others slowly tryit for themselves. . Again,this s is
particularlytrueinthecaseofNoSQLwheremanysolutionsaren’treplacementsformoretraditionalstoragesolutions,
butratheraddressaspecificneedinadditiontowhatonemightgetfromtraditionalofferings.
Having said all of that, the first thing we ought t to o do o is s explain what is meant t by y NoSQL. . It’s a broad term m that
means differentthingsto differentpeople. . Personally,I I useitverybroadlytomeanasystemthatplaysapartinthe
storageofdata. Putanotherway,NoSQL(again,forme),isthebeliefthatyourpersistencelayer r isn’tnecessarilythe
responsibility ofa singlesystem. . Where e relationaldatabasevendors have historically tried to positiontheir software
as aone-size-fits-allsolution,NoSQLleans towardssmaller units ofresponsibility where thebesttoolfor agivenjob
canbe leveraged. . So,yourNoSQLstackmightstill l leveragea relationaldatabase, say MySQL, butit’llalso contain
RedisasapersistencelookupforspecificpartsofthesystemaswellasHadoopforyourintensivedataprocessing. Put
simply,NoSQLisaboutbeing openandawareofalternative,existing andadditionalpatterns andtoolsformanaging
yourdata.
Youmightbe wondering whereMongoDB fits intoallofthis. . As s adocument-oriented database,MongoDB is a more
generalizedNoSQLsolution. Itshouldbeviewedasanalternativetorelationaldatabases.Likerelationaldatabases,it
toocanbenefit frombeingpairedwithsomeofthemorespecialized NoSQLsolutions. . MongoDB B hasadvantages and
drawbacks,whichwe’llcoverinlaterparts ofthisbook.
Asyoumayhavenoticed,weusethetermsMongoDBandMongointerchangeably.
2
SDK software project:C# PDF Convert to HTML SDK: Convert PDF to html files in C#.net
it extremely easy for C# developers to convert and transform The HTML document file, converted by C#.NET PDF style that are included in target PDF document file
www.rasteredge.com
SDK software project:C# PDF File Split Library: Split, seperate PDF into multiple files
C#.NET control for splitting PDF file into two or multiple files online. This is an C# example of splitting a PDF file into multiple ones by number of pages.
www.rasteredge.com
GettingStarted
MostofthisbookwillfocusoncoreMongoDBfunctionality. We’llthereforerelyontheMongoDBshell.Whiletheshell
isusefulto learnaswellasbeing ausefuladministrativetool,your codewilluseaMongoDBdriver.
ThisdoesbringupthefirstthingyoushouldknowaboutMongoDB:itsdrivers.MongoDBhasanumberofofficialdrivers
forvariouslanguages.Thesedriverscanbethoughtofasthevariousdatabasedriversyouareprobablyalreadyfamiliar
with. Ontopofthesedrivers,thedevelopmentcommunityhas s built morelanguage/framework-specific libraries. . For
example,NoRMis a C#library whichimplements LINQ, , and MongoMapper is a Rubylibrary which h is s ActiveRecord-
friendly. Whether r you u choose e to program directly against the core MongoDB drivers s or r some higher-levellibrary is
upto you. . I I pointthisoutonlybecausemanypeoplenewtoMongoDBareconfusedas towhy therearebothofficial
driversandcommunitylibraries-theformergenerallyfocusesoncorecommunication/connectivitywithMongoDBand
thelatter withmorelanguageand framework-specificimplementations.
Asyoureadthroughthis,IencourageyoutoplaywithMongoDBtoreplicatewhatIdemonstrateaswellastoexplore
questionsthatyoumightcomeupwithonyourown. It’seasytogetupandrunningwithMongoDB,solet’stakeafew
minutesnowtosetthingsup.
1. Headovertotheofficialdownloadpageandgrabthebinariesfromthefirstrow(therecommendedstableversion)
foryouroperating systemofchoice. . Fordevelopmentpurposes,youcanpickeither32-bitor r 64-bit.
2. Extract t the archive(wherever you want)and navigate to the
bin
subfolder. Don’t t execute anything just yet,
butknowthat
mongod
istheserverprocessand
mongo
istheclientshell-thesearethetwoexecutableswe’llbe
spendingmostofourtimewith.
3. Createanewtextfileinthe
bin
subfoldernamed
mongodb.config
.
4. Addasinglelinetoyourmongodb.config:
dbpath=PATH_TO_WHERE_YOU_WANT_TO_STORE_YOUR_DATABASE_FILES
. Forexample,onWindowsyoumightdo
dbpath=c:\mongodb\data
and onLinuxyoumightdo
dbpath=/var/
lib/mongodb/data
.
5. Makesurethe
dbpath
youspecified exists.
6. Launchmongodwiththe
--config /path/to/your/mongodb.config
parameter.
AsanexampleforWindowsusers,ifyouextractedthedownloadedfileto
c:\mongodb\
andyoucreated
c:\mongodb\
data\
thenwithin
c:\mongodb\bin\mongodb.config
youwould specify
dbpath=c:\mongodb\data\
. Youcouldthen
launch
mongod
fromacommandpromptvia
c:\mongodb\bin\mongod --config c:\mongodb\bin\mongodb.config
.
Feelfreetoaddthe
bin
foldertoyourpathtomakeallofthislessverbose.MacOSXandLinuxuserscanfollowalmost
identicaldirections. Theonlythingyoushouldhavetochangearethepaths.
HopefullyyounowhaveMongoDBup and running. . Ifyougetanerror,readtheoutputcarefully y -theserveris quite
good atexplainingwhat’swrong.
Youcannowlaunch
mongo
(withoutthed)whichwillconnectashelltoyourrunningserver.Tryentering
db.version()
tomakesureeverything’sworkingas itshould. . Hopefullyyou’llseetheversionnumberyouinstalled.
3
SDK software project:C# PDF File Compress Library: Compress reduce PDF size in C#.net
Hidden layer content. Convert smooth lines to curves. Detect and merge image fragments. Flatten visible layers. C#.NET DLLs: Compress PDF Document.
www.rasteredge.com
SDK software project:C# PDF Convert to Tiff SDK: Convert PDF to tiff images in C#.net
C#.NET PDF SDK - Convert PDF to TIFF in C#.NET. Online C# Tutorial for How to Convert PDF File to Tiff Image File with .NET XDoc.PDF Control in C#.NET Class.
www.rasteredge.com
Chapter1-TheBasics
We beginour journey y by y getting to o know w the e basic mechanics s of working g withMongoDB.Obviously this s is s core e to
understandingMongoDB,butitshouldalsohelp usanswerhigher-levelquestionsaboutwhereMongoDBfits.
To getstarted,therearesixsimpleconceptsweneedto understand.
1. MongoDBhas s thesameconceptofa
database
withwhichyouarelikelyalreadyfamiliar (ora schemafor you
Oracle folks). Within n a a MongoDB B instance you can have zero o or r more e databases, , each h acting as high-level
containers foreverythingelse.
2. Adatabasecanhavezeroormore
collections
.Acollectionsharesenoughincommonwithatraditional
table
thatyoucansafelythinkofthetwoas thesamething.
3. Collections s aremadeupofzeroormore
documents
.Again,adocumentcansafelybethoughtofasa
row
.
4. Adocumentismadeupofoneormore
fields
,whichyoucanprobablyguessarealotlike
columns
.
5.
Indexes
inMongoDBfunctionmostlyliketheirRDBMScounterparts.
6.
Cursors
are different thanthe other fiveconcepts buttheyareimportantenough, andoftenoverlooked,that
I thinkthey are worthyoftheir owndiscussion. . The e importantthingtounderstand aboutcursorsis thatwhen
youaskMongoDBfordata,itreturns apointertotheresultsetcalledacursor,whichwecandothingsto,such
ascounting orskipping ahead,beforeactuallypulling downdata.
To recap,MongoDBis madeup of
databases
whichcontain
collections
. A
collection
ismade upof
documents
.
Each
document
ismadeupof
fields
.
Collections
canbe
indexed
,whichimproveslookupandsortingperformance.
Finally,whenwegetdatafromMongoDBwedosothrougha
cursor
whoseactualexecutionisdelayeduntilnecessary.
Whyusenewterminology(collectionvs.table,documentvs.rowandfieldvs.column)? Isitjusttomakethingsmore
complicated? Thetruthisthatwhiletheseconceptsaresimilartotheirrelationaldatabase e counterparts,theyarenot
identical. Thecoredifferencecomesfromthefactthatrelationaldatabasesdefine
columns
atthe
table
levelwhereas
adocument-orienteddatabasedefinesits
fields
atthe
document
level. Thatis s to saythateach
document
withina
collection
canhaveitsownuniquesetof
fields
.Assuch,a
collection
isadumbeddowncontainerincomparison
toa
table
,whilea
document
hasalotmoreinformationthana
row
.
Althoughthis is important to understand, , don’t worry ifthings s aren’t yet clear. . It t won’t take more thana couple of
inserts to see what this truly means. . Ultimately, , the pointis s that a collectionisn’t strict about what goes init (it’s
schema-less). Fields s aretracked witheachindividualdocument. . The e benefits and drawbacksofthiswillbe explored
inafuturechapter.
Let’s gethands-on. . Ifyoudon’t t have it running already,go ahead and start the
mongod
server as wellas a mongo
shell. TheshellrunsJavaScript. . There e aresome global commands youcanexecute,like
help
or
exit
. Commands
thatyouexecuteagainstthecurrentdatabaseareexecutedagainstthe
db
object,suchas
db.help()
or
db.stats()
.
Commandsthat youexecute againsta specific collection,whichiswhatwe’llbe doing a lotof,are executed against
the
db.COLLECTION_NAME
object,suchas
db.unicorns.help()
or
db.unicorns.count()
.
Goaheadandenter
db.help()
,you’llgetalistofcommandsthatyoucanexecuteagainstthe
db
object.
4
SDK software project:C# PDF File Merge Library: Merge, append PDF files in C#.net, ASP.
PDF page deleting, PDF document splitting, PDF page reordering and PDF page image and text extraction. Remarkably, all those C#.NET PDF document page
www.rasteredge.com
SDK software project:C# PDF Convert to Word SDK: Convert PDF to Word library in C#.net
Quick to remove watermark and save PDF text, image, table for batch converting PDF documents in C#.NET program. Convert PDF to multiple MS Word formats such as
www.rasteredge.com
A smallside note: : Because e this s is s a JavaScript shell, , ifyouexecute a method d and omit the parentheses
()
, you’ll
seethe method bodyrather thanexecuting the method. . Ionly y mentionit so thatthe first time youdoit and get a
response thatstartswith
function (...){
youwon’t be surprised. . For r example,ifyouenter
db.help
(withoutthe
parentheses),you’llseetheinternalimplementationofthe
help
method.
Firstwe’llusetheglobal
use
helpertoswitchdatabases,sogoaheadandenter
use learn
.Itdoesn’tmatterthatthe
databasedoesn’treally exist yet. . The e first collectionthatwecreatewillalso createtheactual
learn
database. Now
thatyouareinsideadatabase,youcanstartissuingdatabasecommands,like
db.getCollectionNames()
.Ifyoudo
so,youshouldgetanempty array(
[ ]
). Sincecollectionsareschema-less,wedon’t t explicitlyneed tocreatethem.
We cansimply insert a document into a newcollection. To o do so, , use the
insert
command, supplying g it withthe
documenttoinsert:
db.unicorns.insert({name: 'Aurora',
gender: 'f', weight: 450})
Theabovelineisexecuting
insert
againstthe
unicorns
collection,passingitasingleparameter. InternallyMongoDB
uses abinaryserialized JSONformatcalledBSON.Externally,thismeansthatweuse JSONalot,asisthecasewith
our parameters. If f we e execute
db.getCollectionNames()
now, we’ll actually see e two collections:
unicorns
and
system.indexes
. Thecollection
system.indexes
is created onceper database and contains theinformationonour
database’sindexes.
Youcannowusethe
find
commandagainst
unicorns
toreturnalistofdocuments:
db.unicorns.find()
Noticethat,inadditionto the datayouspecified,there’san
_id
field. Everydocumentmusthaveaunique
_id
field.
Youcaneithergenerateoneyourselfor letMongoDBgenerate avalueforyouwhichhas thetype
ObjectId
. Mostof
thetimeyou’llprobablywantto letMongoDBgenerateitforyou. . Bydefault,the
_id
fieldisindexed-whichexplains
whythe
system.indexes
collectionwas created. . Youcanlookat
system.indexes
:
db.system.indexes.find()
Whatyou’reseeingisthenameoftheindex,thedatabaseandcollectionitwascreatedagainstandthefieldsincluded
intheindex.
Now,backtoourdiscussionaboutschema-lesscollections.Insertatotallydifferentdocumentinto
unicorns
,suchas:
db.unicorns.insert({name: 'Leto',
gender: 'm',
home: 'Arrakeen',
worm: false})
And,againuse
find
tolistthedocuments.Onceweknowabitmore,we’lldiscussthisinterestingbehaviorofMongoDB,
buthopefullyyouarestartingtounderstandwhythemoretraditionalterminologywasn’tagoodfit.
5
MasteringSelectors
Inadditiontothesixconceptswe’veexplored,there’sonepracticalaspectofMongoDByouneedtohaveagoodgrasp
ofbeforemovingto moreadvanced topics: : queryselectors. AMongoDBqueryselectorislikethe
where
clauseofan
SQL statement. As s such, , you use it whenfinding,counting,updating g and removing documents from collections. . A
selector isa JSONobject,thesimplest ofwhichis
{}
whichmatches alldocuments. . Ifwewanted d to find allfemale
unicorns,wecoulduse
{gender:'f'}
.
Beforedelvingtoodeeplyintoselectors,let’ssetupsomedatatoplaywith.First,removewhatwe’veputsofarinthe
unicorns
collectionvia:
db.unicorns.remove({})
. Now, , issue thefollowing g inserts to get somedata wecanplay
with(Isuggestyoucopyandpastethis):
db.unicorns.insert({name: 'Horny',
dob: new Date(1992,2,13,7,47),
loves: ['carrot','papaya'],
weight: 600,
gender: 'm',
vampires: 63});
db.unicorns.insert({name: 'Aurora',
dob: new Date(1991, , 0, 24, 13, , 0),
loves: ['carrot''grape'],
weight: 450,
gender: 'f',
vampires: 43});
db.unicorns.insert({name: 'Unicrom',
dob: new Date(1973, , 1, 9, 22, 10),
loves: ['energon''redbull'],
weight: 984,
gender: 'm',
vampires: 182});
db.unicorns.insert({name: 'Roooooodles',
dob: new Date(1979, , 7, 18, 18, , 44),
loves: ['apple'],
weight: 575,
gender: 'm',
vampires: 99});
db.unicorns.insert({name: 'Solnara',
dob: new Date(1985, , 6, 4, 2, 1),
loves:['apple''carrot',
'chocolate'],
weight:550,
gender:'f',
vampires:80});
db.unicorns.insert({name:'Ayna',
6
dob: new Date(1998, , 2, 7, 8, 30),
loves: ['strawberry''lemon'],
weight: 733,
gender: 'f',
vampires: 40});
db.unicorns.insert({name:'Kenny',
dob: new Date(1997, , 6, 1, 10, 42),
loves: ['grape''lemon'],
weight: 690,
gender: 'm',
vampires: 39});
db.unicorns.insert({name: 'Raleigh',
dob: new Date(2005, , 4, 3, 0, 57),
loves: ['apple''sugar'],
weight: 421,
gender: 'm',
vampires: 2});
db.unicorns.insert({name: 'Leia',
dob: new Date(2001, , 9, 8, 14, 53),
loves: ['apple''watermelon'],
weight: 601,
gender: 'f',
vampires: 33});
db.unicorns.insert({name: 'Pilot',
dob: new Date(1997, , 2, 1, 5, 3),
loves: ['apple''watermelon'],
weight: 650,
gender: 'm',
vampires: 54});
db.unicorns.insert({name: 'Nimue',
dob: new Date(1999, 11, 20, 16, , 15),
loves: ['grape''carrot'],
weight: 540,
gender: 'f'});
db.unicorns.insert({name: 'Dunx',
dob: new Date(1976, , 6, 18, 18, , 18),
loves: ['grape''watermelon'],
weight: 704,
gender: 'm',
vampires: 165});
Nowthatwehavedata,wecanmasterselectors.
{field: value}
isusedtofindanydocumentswhere
field
isequal
to
value
.
{field1: value1, field2: value2}
ishowwedoan
and
statement. The e special
$lt
,
$lte
,
$gt
,
$gte
7
and
$ne
are used forlessthan,less thanorequal,greaterthan,greaterthanor equaland notequaloperations. For
example,togetallmaleunicornsthatweighmorethan700pounds,wecoulddo:
db.unicorns.find({gender: 'm',
weight: {$gt: 700}})
//or (not quite the same thing, , but for
//demonstration purposes)
db.unicorns.find({gender: {$ne: 'f'},
weight: {$gte: 701}})
The
$exists
operatorisusedformatchingthepresenceorabsenceofafield,forexample:
db.unicorns.find({
vampires: {$exists: false}})
should returna single document. . The‘$in’ ’ operator r is used for matching g oneofseveral values s that we pass as an
array,for example:
db.unicorns.find({
loves: {$in:['apple','orange']}})
Thisreturnsanyunicornwholoves‘apple’or‘orange’.
Ifwewantto OR rather thanANDseveralconditions ondifferentfields,we usethe
$or
operator and assignto itan
arrayofselectorswewantor’d:
db.unicorns.find({gender: 'f',
$or: [{loves: 'apple'},
{weight: {$lt: 500}}]})
Theabovewillreturnallfemaleunicornswhicheitherloveapplesorweighlessthan500pounds.
There’ssomethingprettyneatgoing oninourlasttwoexamples.Youmighthavealreadynoticed,butthe
loves
field
isanarray. MongoDBsupportsarraysas s firstclass objects. . This s isanincrediblyhandyfeature. . Onceyoustartusing
it,youwonderhowyoueverlivedwithout it. What’smore interesting ishoweasyselecting based onanarrayvalue
is:
{loves: 'watermelon'}
willreturnanydocumentwhere
watermelon
isavalueof
loves
.
Therearemoreavailableoperatorsthanwhatwe’veseensofar.ThesearealldescribedintheQuerySelectorssection
oftheMongoDBmanual.Whatwe’vecoveredsofarthoughisthebasicsyou’llneedtogetstarted.It’salsowhatyou’ll
endupusingmostofthetime.
We’veseenhowtheseselectorscanbeusedwiththe
find
command. Theycanalsobeusedwiththe
remove
command
whichwe’vebrieflylooked at,the
count
command,whichwehaven’tlooked atbut youcanprobablyfigure out,and
the
update
commandwhichwe’llspend moretimewithlateron.
The
ObjectId
whichMongoDBgeneratedforour
_id
fieldcanbeselected likeso:
db.unicorns.find(
{_id: ObjectId("TheObjectId")})
8
InThisChapter
Wehaven’tlooked atthe
update
commandyet,orsomeofthefancier thingswe cando with
find
. However,wedid
getMongoDBupandrunning,lookedbrieflyatthe
insert
and
remove
commands(there isn’t muchmore thanwhat
we’veseen). Wealsointroduced
find
andsawwhatMongoDB
selectors
wereallabout. We’vehadagoodstartand
laid asolid foundationforthings tocome. . Believeitornot,youactuallyknowmostofwhatyouneed d toknowtoget
startedwithMongoDB -it really is meant tobequick tolearnandeasy touse. . I I stronglyurgeyoutoplaywithyour
localcopybeforemoving on. . Insertdifferentdocuments, , possiblyinnewcollections,and d get familiar withdifferent
selectors. Use
find
,
count
and
remove
. Aftera a fewtries onyour own,things that mighthave seemed awkward at
firstwillhopefullyfallintoplace.
9
Documents you may be interested
Documents you may be interested