IbexPDFCreator
DevelopersGuide
IntroductiontoXSL-FO
25
ThislistwascreatedwiththeFOshowninFigure4-35:
Figure4-35:
FOforthelist-block
<list-block
margin-left='3cm' margin-right='3cm' padding='3pt'
border='.1pt solid blue'
provisional-distance-between-starts='0.5cm'
provisional-label-separation='0.1cm'>
<list-item>
<list-item-label end-indent='label-end()'>
<block>&#x2022;</block>
</list-item-label>
<list-item-body start-indent='body-start()'>
<block>this is s item one</block>
</list-item-body>
</list-item>
<list-item>
<list-item-label end-indent='label-end()'>
<block>&#x2022;</block>
</list-item-label>
<list-item-body start-indent='body-start()'>
<block>this is item two</block>
</list-item-body>
</list-item>
</list-block>
Alistsetsthe twocolumns towidthsspecifiedusingthe attributesofthe list-block
elements. The provisional-distance-between-starts s attribute specifies the distance
between the start of f the e label l column and the start of the body column. . The
provisional-label-separationattributesetshowmuchofthelabelcolumnshouldbeleft
emptytoprovideablankspacebetweenthecolumns.
Ifweexpandtheaboveexampleandaddmorecontenttothefirstbodywecanseethat
thecontentisconstrainedtothecolumn.Ifweaddcontenttothefirstlist-item-bodyas
showninFigure4-36wegetthelistshowninFigure4-37.
Figure4-36:
FOforthelist-block
<list-item-body start-indent='body-start()'>
<block>
If your Network k Administrator has enabled it,
Microsoft Windows s can n examine your network k and
automatically discover r network k connection settings.
</block>
</list-item-body>
Figure4-37:
Outputforthe
list-block
If your Network Administrator r has s enabled it,
Microsoft Windows s can examine e your network
and automatically discover network k connection
settings.
this is s item two
Formoreinformationonlistsseepage77.
4.10 Creatingtables
Atableiscreatedusingthetableelement.Withinthetableelementtherecanbeone
table-headerelement,anynumberoftable-bodyelements(whichcontaintherows)and
one table-footer element. . Each h of the table-headertable-body and table-footer
Pdf form change font size - Compress reduce PDF size in C#.net, ASP.NET, MVC, Ajax, WinForms, WPF
C# Code & .NET API to Compress & Decompress PDF Document
change font size pdf text box; change font size in pdf comment box
Pdf form change font size - 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 change font size in textbox; optimize scanned pdf
IbexPDFCreator
DevelopersGuide
26
IntroductiontoXSL-FO
elements contains one or more table-row elements, , each containing one or more
table-cellelementswhichinturncontainblock-levelelementssuchasblock,tableand
list-block.
Sinceatable-cellcancontainanyblock-levelelementyoucaneasilycreatetableswhich
contain text, nested d tables or lists. Table e headers s and footers defined with the
table-headerandtable-footerelementsareautomaticallyrepeatedateachpagebreak,
althoughthiscanbesuppressedifrequired.
Figure4-38showstheFOforasimpletableandFigure4-39showsthetablecreated
fromtheFO.
Figure4-38:
FOforatable
<table>
<table-body>
<table-row>
<table-cell border='1pt solid blue' ' padding='2pt'>
<block>row 1 1 column n 1</block>
</table-cell>
<table-cell border='1pt solid blue' ' padding='2pt'>
<block>row 1 1 column n 2</block>
</table-cell>
</table-row>
<table-cell border='1pt solid blue' ' padding='2pt'>
<block>row 1 1 column n 1</block>
</table-cell>
<table-cell border='1pt solid blue' ' padding='2pt'>
<block>row 1 1 column n 2</block>
</table-cell>
</table-row>
</table-body>
</table>
ThisFOproducesthetableshowninFigure4-39.
Figure4-39:
Simpletablefromthe
aboveFO
row 1 1 column 1
row 1 column 2
row 2 2 column 1
row 2 column 2
Thepaddingandborderattributesarenotinheritedfromcontainingelementssomust
bedefinedonthetable-cellelements.
4.10.1 Settingtablecolumnwidths
Thewidthofatable columnissetusingthe table-columnelement. Atableelement
containszeroormoretable-columnelementseachofwhichdefinespropertiessuchas
widthandbackground-colorforacolumninthetable.
Tomakethefirstcolumn30%ofthetablewidthwewouldaddtable-columnelementsas
showninFigure4-40,whichcreatestheoutputshowninFigure4-41.
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 compression settings; 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.
change font size in pdf form; pdf file size
IbexPDFCreator
DevelopersGuide
IntroductiontoXSL-FO
27
Figure4-40:
Tablewith
table-column
elements
<table>
<table-column column-width='30%' ' column-number='1'/>
<table-column column-width='70%' ' column-number='2'/>
<table-body>
<table-row>
<table-cell border='1pt solid blue' ' padding='2pt'>
<block>row 1 1 column n 1</block>
</table-cell>
<table-cell border='1pt solid blue' ' padding='2pt'>
<block>row 1 1 column n 2</block>
</table-cell>
</table-row>
<table-row>
<table-cell border='1pt solid blue' ' padding='2pt'>
<block>row 1 1 column n 1</block>
</table-cell>
<table-cell border='1pt solid blue' ' padding='2pt'>
<block>row 1 1 column n 2</block>
</table-cell>
</table-row>
</table-body>
</table>
Figure4-41:
Renderedtablewith
specifiedwidths
row 1 1 column 1
row 1 1 column 2
row 2 2 column 1
row 2 2 column 2
Formoreinformationontablesseepage81.
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.
change font size pdf form reader; pdf edit text size
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.
reader pdf reduce file size; change font size in pdf form field
28
IntroductiontoXSL-FO
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
pdf page size may not be reduced; pdf form change font size
Generate Barcodes in Web Image Viewer| Online Tutorials
Change Barcode Properties. RasterEdge OCR Engine; PDF Reading; Encode & Decode JBIG 2 Files; Compress & Twain Scanning; DICOM Reading; Form Recognition & Processing
change font size on pdf text box; adjust size of pdf in preview
UsingIbex
29
Chapter5
UsingIbex
Thischapter describes howtocall the Ibex API andhow to use the accompanying
commandlineprogram.
5.1 Ibexcommandlineprogram
Althoughprimarilyintendedtobeusedasapartofalargerapplication,Ibexshipswitha
commandlineprogramwhichcanbeusedtocreatePDFfilesfromFOfiles.
ThecommandlineprogramsshippedwithIbexare ibex10.exe(whichuses.NET1.0),
ibex11.exe(whichuses.NET1.1)andibex20.exe(whichuses.NET2.0).
The command line e syntax x is the e same e for all programs. . Inthese examples we e use
ibex20.exe.
TocreateaPDFfilefromanFOfilespecifythefilenamesonthecommandline.For
instancetocreatehello.pdffromhello.fo,youdothis:
ibex20 hello.fo hello.pdf
5.1.1 XSLTtranslation
ThecommandlineprogramwillacceptXMLdataandanXSLTstylesheetasinputs.The
XMLwillbetranslatedtoFObythestylesheetandtheresultsthenformattedtoPDF.
Thecommandlinesyntaxis:
ibex20 -xsl xsl-file xml-file pdf-file
SotocreateaPDFfilefromthefilesbook.xmlandbook.xsl,thecommandis:
ibex20 -xsl book.xsl book.xml book.pdf
XSLTparameterscanbepassedtothestylesheetbyaddingthemasname-valuepairsto
thecommandline.Forinstance,ifwewanttodefinetheparametercalled"age"tothe
value"30"weuseacommandlikethis:
ibex20 -xsl book.xsl book.xml hello.pdf "age=30"
The use of the double quotes around the name-value pair is necessary y on some
operatingsystemstoforcethemtocomethroughasasingleparametertothe Ibex
program.
VB.NET Image: Visual Basic .NET Guide to Draw Text on Image in .
for example, a VB.NET Windows Form application. Please note that you can change some of the provide powerful & profession imaging controls, PDF document, image
change pdf page size; apple compress pdf
Generate Image in .NET Winforms Imaging Viewer| Online Tutorials
Change Barcode Properties. Multi-page Tiff Processing; RasterEdge OCR Engine; PDF Reading; Encode & JPEG 2000 Files; Twain Scanning; DICOM Reading; Form Recognition
batch pdf compression; reader compress pdf
IbexPDFCreator
DevelopersGuide
30
UsingIbex
5.1.2 Loggingfromthecommandline
Any informational l or r error r messages will be e logged d to o the console. To send d error
messagestoafileaswell,usethe-logfileoption.Forexampletologerrorstothefile
ibex.log,youwoulddothis:
ibex20 -logfile ibex.log hello.fo hello.pdf
5.1.3 Listingavailablefonts
Youcanalsolistthefontswhichareavailable(basedonwhatfontsareinstalledonyour
system)byusingthe-fontsoptionlikethis:
ibex20 -fonts
ThelistoffontsisproducedasaFOfiletothestandardoutput.Thiscanberedirectedto
afileandthenusedasinputtoIbextocreateaPDFfilecontainingatablewhichlooks
likethis:
Thelist offonts can be limitedtofonts whose name contains aspecified string by
passingthestringonthecommandline.Forinstanceifwewantedtoseewhatversions
of"arial"areinstalled,wecanusethecommand:
ibex20 -fonts arial
5.2 TheIbexAPI
A PDF document is generated using the FODocument object which is in the e ibex4
namespace.
FirstyoucreateanewFODocumentobjectandthencallingthegenerate()methodon
that object. . The generate() ) method d has s various s versions s which h take different
parametersdependingonwhethertheinputisfromfilesorstreamsandwhetherXSLT
translationshouldoccur.
TheFODocumentobjectisnotthreadsafe.AnewFODcoumentshouldbecreatedfor
eachPDFfiletobecreated.IbexdoessupportcreatingmultiplePDFfilesconcurrently
onmultiplethreads,aslongaseachPDFfileisassociatedwithauniqueFODocument
instance.
ExampleC#codetoconvertthefile"manual.fo"to"manual.pdf"thecodeisshownin
Figure5-1,theequivalentVB.NETcodeisinFigure5-2.
IbexPDFCreator
DevelopersGuide
UsingIbex
31
Figure5-1:
C#codetocreatea
PDFfromanFOfile
using System;
using ibex4;
public class s Simple e {
static void Main( string[] args ) {
FODocument doc = = new w FODocument();
gen.generate( "manual.fo", , "manual.pdf" " );
}
}
Figure5-2:
VB.NETcodetocreate
aPDFfromanFOfile
Imports System
Imports ibex4
Module Module1
Sub Main()
Dim doc As New w FODocument
doc.generate("manual.fo", "manual.pdf")
End Sub
End Module
ProjectsneedtohaveareferencetotheibexDLL.
5.2.1 GeneratingtoFile
public void generate( string g fo_file_name, , string pdf_file_name e )
ThiswillreadtheFOcontainedinthefilenamedinpdf_file_nameandcreatethePDFfile
namedinpdf_file_name.
5.2.2 Generatingusingstreams
public void generate( Stream m fo_stream, , Stream pdf_stream )
public void generate( Stream m fo_stream, , Stream pdf_stream, , bool close_stream m )
ThiswillreadtheFOfromtheSystem.IO.Streamcalledfo_streamandcreatethePDFfile
intothe System.IO.Streampdf_stream. Thesestreamscanbeanythingderivedfrom
System.IO.Stream,suchasSystem.IO.FileStreamorSystem.IO.MemoryStream.
Ifclose_streamistruethePDFstreamwillbeclosedafterthePDFfileisgenerated,if
falseitwillnot.Bydefaultthestreamisclosed.Notclosingthestreamisusefulifyouare
generating to a MemoryStream object as the e bytes cannot t be e read from m the
MemoryStreamifithasbeenclosed.
IbexPDFCreator
DevelopersGuide
32
UsingIbex
5.2.3 GeneratingaPDFfromXMLandXSL
ThesemethodstakeXML,anXSLTstylesheet,andastreamtowritetheresultingPDF
fileto.
public void generate( Stream m xml_stream, , Stream xsl_stream, Stream pdf_stream )
public void generate( Stream m xml_stream, , Stream xsl_stream, Stream pdf_stream, , bool
closeStream )
Ibexusesthe.NETXSLTprocessortotransformtheXMLusingthespecifiedstylesheet
andpassestheresultingFOtothePDFcreationroutines.XSLTtransformationisfaster
ormoreefficientin.NET2.0andlaterandwerecommendusingthisversionorlaterif
possible.
5.2.4 GenerateaPDFfromXMLandXSLwithparameters
Thesemethodsaresimilartotheonesintheprevioussectionbuttakeanadditional
hashtablewhich(ifnotnull)shouldcontainname-valuepairswhicharethenpassedas
argumentstotheXSLTtranslationprocess.
public void generate( Stream m xml_stream, , Stream xsl_stream, Stream pdf_stream,
bool close_stream, Hashtable params )
UsingIbexwithASP.NET
33
Chapter6
UsingIbexwithASP.NET
ThischaptershowshowtouseIbexwithASP.NET,includinghowtocreateaPDFfileand
streamitbacktoaclientbrowserwithoutneedingtosaveittodisk.
IbexcreatesaPDFfileintoaStreamobject(fromtheSystem.IOnamespace).Inthis
exampleweuseaMemoryStreamobjectwhichderivesfromStreamandisbasicallyan
expandablearrayofbytesheldinmemory.CreatingthePDFfileinaMemoryStream
meansthefileisnotsavedtodiskandthewholeprocessoccursinmemory.
WecreatethefileintoaMemoryStreambecausemanyversionsofInternetExplorerwill
displayaPDFfilecorrectlyonlyiftheyknowhowlongthefileis.Weneedtocreatethe
PDFfileintoaMemoryStreamtodetermineitslengthandsetthislengthinanHTTP
header.ThisneedtoknowthelengthofthePDFfilepreventsusfromstreamingdirectly
totheResponseobject.
6.1 TheASPpage
Thisexampleusesapagecalledpdfasp.aspx,whichhascodebehinditinpdfasp.aspx.cs.
TousethesepagesyouwillneedtocreateanewASP.NETC#project,addareferenceto
theibex20.dllwhereveryouhaveinstalledit,andthenaddthepdfgen.aspxpage.You
will need d to remove e the '_' ' characters from the e names s of f the e pdfasp.aspx x and
pdfasp.aspx.csfiles.
ThecontentoftheASPpagepdfasp.aspxisshowninFigure6-1.
Figure6-1:
TheASPpage
<%@ Page language="c#" " validateRequest="false" Codebehind="pdfasp.aspx.cs"
AutoEventWireup="false" Inherits="WebApplication1.pdfasp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 0 Transitional//EN" " >
<HTML>
<HEAD>
<title>pdfgen</title>
<meta name="GENERATOR" " Content="Microsoft Visual Studio o .NET 7.1">
<meta name="CODE_LANGUAGE" " Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" " method="post" " runat="server">
</form>
</body>
</HTML>
IbexPDFCreator
DevelopersGuide
34
UsingIbexwithASP.NET
6.2 TheASPcode-behindpage
Thepdfasp.aspx.csfilecontainsthecodeshowninFigure6-2(plussomeerrorhandling
thatisnotshownforclarity).
Figure6-2:
Thecode-behindpage
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.IO;
using System.Text;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Xml;
using System.Xml.Xsl;
using System.Security.Policy;
using ibex4;
using ibex4.logging;
namespace WebApplication1 {
public class s pdfasp : : System.Web.UI.Page e {
private void Page_Load(object sender, System.EventArgs e) {
Logger.getLogger()
.setLevel( Level.FINEST T )
.clearHandlers();
try {
Stream stream m = new FileStream(
Server.MapPath( @"logs\log.txt"), FileMode.Append,
FileAccess.Write ) ;
Logger.getLogger().addHandler( new w StreamHandler( stream ) ) ) ;
}
catch( Exception ) {
}
FODocument doc = new FODocument();
string dataFilePath = Server.MapPath("") + + "\\hello.fo";
// stream m for output in memory before e sending g to browser
MemoryStream pdfStream = = new MemoryStream();
FileStream dataStream = new w FileStream( ( dataFilePath,
FileMode.Open, FileAccess.Read d );
Logger.getLogger().info( "data file path is " + + dataFilePath h );
using( dataStream m ) ) {
doc.generate( dataStream, , pdfStream, false );
}
Response.Clear();
Response.ContentType = = "application/pdf";
Response.AddHeader( "content-length",
System.Convert.ToString( pdfStream.Length h ) ) );
Response.BinaryWrite( pdfStream.ToArray() );
Response.End();
}
override protected void OnInit(EventArgs s e)
{
InitializeComponent();
base.OnInit(e);
Documents you may be interested
Documents you may be interested