com.aspose.pdf.elements
Class Pdf

java.lang.Object
  extended by com.aspose.pdf.elements.Pdf

public class Pdf
extends java.lang.Object

Represents the Pdf document.


Constructor Summary
Pdf()
          Initialize a new instance of the Pdf class.
 
Method Summary
 void addAuthor(java.lang.String author)
          Sets a string that indicates the author name of the Pdf document.
 void addCreator(java.lang.String creator)
          Sets a string that indicates the creator of the Pdf document.
 void addKeywords(java.lang.String keyWords)
          Sets a string that indicates key words of the Pdf document.
 void addProducer(java.lang.String producer)
          Sets a string that indicates Producer of the Pdf document.
 void addSubject(java.lang.String subject)
          Sets a string that indicates the subject of the Pdf document.
 void addTitle(java.lang.String title)
          Sets a string that indicates the title of the Pdf document.
 void bindFo(java.io.InputStream foStream)
          Binds fo file as InputSteam.
NOTE: This is Beta version of Fo2Pdf.
 void bindFo(java.io.InputStream xmlStream, java.io.InputStream xsltStream)
          Binds xml file and according xsl file as InputStream to be converted.
NOTE: This is Beta version of Fo2Pdf.
 void bindHTML(java.io.InputStream htmlStream, java.net.URL baseUrl)
          Binds a html stream and convert it to Pdf Stream.
NOTE: This is Beta version of bindHTML.
static Pdf bindXML(java.io.InputStream xmlStream)
          Reads info from an xml document.
static Pdf bindXMLByDom(java.io.InputStream xmlStream)
          Reads info from an xml document.
static void copyStream(java.io.InputStream in, java.io.OutputStream out)
           
 Color getBackgroundColor()
          Gets a Color object that indicates the background color of the pdf.
 java.lang.String getBackgroundImageFile()
          Gets a string that indicates the background image file name.
 float getBackgroundImageFixedWidth()
          Gets a float value that indicates the fixed width of the background image.
 int getBookMarkLevel()
          Gets or sets a int value that indicates how many levels of Heading of the pdf document is to be bookmarked.
The default value is 0, which means every heading of the PDF is to be taged as a bookmark.
 DestinationType getDestinationType()
          Gets a DestinationType value that indicates the document open action.
 int getFirstLineIndent()
          Gets an int value that indicates the indent of the first line.
static java.lang.String getFoImagePath()
          Sets an image path to system image path.
 GraphInfo getGraphInfo()
          Gets a GraphInfo object that indicates the graph info in the Pdf document.
 java.lang.String getHeadingCaption(int headingLevel, int headingType, boolean isPrefixed)
          Gets the heading caption at a heading level.
 HeadingInfo getHeadingInfo()
          Gets the heading info object of the pdf document.
 JavaScripts getJavaScripts()
          Gets a JavaScripts object that indicates the JavaScripts to be added into the PDF.
 OpenType getOpenType()
          Gets an OpenType that indicates the document open type.
 int getPageDuration()
          Gets a int value that indicates the duration in seconds for the current page.
This property is used when using auto advancing in presentation mode.
 PageSetup getPageSetup()
          Gets a PageSetup object that indicates the page setup info in the Pdf document.
 PageTransitionType getPageTransition()
          Gets a PageTransitionType that indicates the pdf document page transition type.
 Sections getSections()
          Gets a Sections collection that indicates all sections in the Pdf document.
 Security getSecurity()
          Gets a Security object that indicates the document security information.
 TextInfo getTextInfo()
          Gets a TextInfo object that indicates the text info in the Pdf document.
 boolean isBookmarked()
          Gets or sets a bool value that indicates whether the pdf document is bookmarked when generating PDF document.
The default value is false.
 boolean isPageNumberRestarted()
          Gets a bool value that indicates whether the page number is restarted in new section.
 boolean isSpaced()
          Gets a bool value that indicates whether the spaces at the begin of the text and returns in the text be shown.
 void resetNumber(int position)
          Resets all heading number after given position.
 void save(java.io.OutputStream out)
          Saves the converted pdf stream.
 void setBackgroundColor(Color color)
          Sets a Color object that indicates the background color of the pdf.
 void setBackgroundImageFile(java.lang.String imageFile)
          Sets a string that indicates the background image file name.
 void setBackgroundImageFixedWidth(float imageFixedWidth)
          Sets a float value that indicates the fixed width of the background image.
 void setBackgroundImagePosition(float xPosition, float yPosition)
          Sets the background image position.
 void setBookmarked(boolean isBookmarked)
           
 void setBookMarkLevel(int bookMarkLevel)
           
 void setDestinationType(DestinationType type)
          Sets a DestinationType value that indicates the document open action.
 void setFirstLineIndent(int indent)
          Sets an int value that indicates the indent of the first line.
static void setFoImagePath(java.lang.String path)
          Sets an image path to system image path.
 void setGraphInfo(GraphInfo graphInfo)
          Sets a GraphInfo object that indicates the graph info in the Pdf document.
 void setIsSpaced(boolean isSpaced)
          Sets a bool value that indicates whether the spaces at the begin of the text and returns in the text be shown.
 void setJavaScripts(JavaScripts scripts)
          Sets a JavaScripts object that indicates the JavaScripts to be added into the PDF.
 void setOpenType(OpenType type)
          Sets an OpenType that indicates the document open type.
 void setPageDuration(int duration)
          Sets a int value that indicates the duration in seconds for the current page.
 Pdf setPageNumberRestarted(boolean pageNumberRestarted)
          Gets a bool value that indicates whether the page number is restarted in new section.
 void setPageSetup(PageSetup pageSetup)
          Sets a PageSetup object that indicates the page setup info in the Pdf document.
 Pdf setPageTransition(PageTransitionType transition)
          Sets a PageTransitionType that indicates the pdf document page transition type.
 void setSections(Sections secs)
          Sets a Sections collection that indicates all sections in the Pdf document.
 Pdf setSecurity(Security security)
          Sets a Security object that indicates the document security information.
 void setTextInfo(TextInfo textInfo)
          Sets a TextInfo object that indicates the text info in the Pdf document.
 java.lang.String version()
          Gets the version of Aspose Pdf.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Pdf

public Pdf()
    throws AsposeBaseException
Initialize a new instance of the Pdf class.

 [SampleCode]
 Pdf pdf = new Pdf();
 Section sec1 = pdf.getSections().add();
 Text text1 = new Text(sec1,"Hello World, this is my first pdf.");
 sec1.getParagraphs().add(text1);
 pdf.save(new FileOutputStream(new File("./HelloWorldExample.pdf")));
 

Throws:
AsposeBaseException
Method Detail

setFoImagePath

public static void setFoImagePath(java.lang.String path)
Sets an image path to system image path.

Parameters:
path - The path to set.

getFoImagePath

public static java.lang.String getFoImagePath()
Sets an image path to system image path.


bindFo

public void bindFo(java.io.InputStream foStream)
            throws AsposeBaseException
Binds fo file as InputSteam.
NOTE: This is Beta version of Fo2Pdf. Some complex XSL-FO may not be supported and we may be not able to fix it in short time.

 [SampleCode]
 Pdf docConvert = new Pdf();
 docConvert.bindFo(new FileInputStream(new File("../fofile/helloworld.fo")));
 docConvert.save(new FileOutputStream(new File("./helloworld.pdf")));
 

Parameters:
foStream - Format-Object file as InputStream to be converted
Throws:
AsposeBaseException

bindFo

public void bindFo(java.io.InputStream xmlStream,
                   java.io.InputStream xsltStream)
            throws AsposeBaseException
Binds xml file and according xsl file as InputStream to be converted.
NOTE: This is Beta version of Fo2Pdf. Some complex XSL-FO may not be supported and we may be not able to fix it in short time.

 [SampleCode]
 Pdf docConvert = new Pdf();
 docConvert.bindFo(new FileInputStream(new File("../fofile/glossary.xml")),
 new FileInputStream(new File("../fofile/glossary.xsl")));
 docConvert.save(new FileOutputStream(new File("./glossary.pdf")));
 

Parameters:
xmlStream - xml file stream
xsltStream - xslt file stream
Throws:
AsposeBaseException

bindXML

public static Pdf bindXML(java.io.InputStream xmlStream)
                   throws javax.xml.parsers.ParserConfigurationException,
                          org.xml.sax.SAXException,
                          java.io.IOException
Reads info from an xml document.

Parameters:
xmlStream -
Returns:
Pdf Instance
Throws:
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException

bindXMLByDom

public static Pdf bindXMLByDom(java.io.InputStream xmlStream)
                        throws javax.xml.parsers.ParserConfigurationException,
                               org.xml.sax.SAXException,
                               java.io.IOException
Reads info from an xml document.

Parameters:
xmlStream -
Returns:
Pdf Instance
Throws:
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException

bindHTML

public void bindHTML(java.io.InputStream htmlStream,
                     java.net.URL baseUrl)
Binds a html stream and convert it to Pdf Stream.
NOTE: This is Beta version of bindHTML. Only simple HTML is supported.

Parameters:
htmlStream - the html stream that to be converted
baseUrl - the url that points to the html file.
Throws:
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException

setSections

public void setSections(Sections secs)
Sets a Sections collection that indicates all sections in the Pdf document.


getSections

public Sections getSections()
Gets a Sections collection that indicates all sections in the Pdf document.


setPageSetup

public void setPageSetup(PageSetup pageSetup)
Sets a PageSetup object that indicates the page setup info in the Pdf document.


getPageSetup

public PageSetup getPageSetup()
Gets a PageSetup object that indicates the page setup info in the Pdf document.


getFirstLineIndent

public int getFirstLineIndent()
Gets an int value that indicates the indent of the first line.


setFirstLineIndent

public void setFirstLineIndent(int indent)
Sets an int value that indicates the indent of the first line.


isSpaced

public boolean isSpaced()
Gets a bool value that indicates whether the spaces at the begin of the text and returns in the text be shown.


setIsSpaced

public void setIsSpaced(boolean isSpaced)
Sets a bool value that indicates whether the spaces at the begin of the text and returns in the text be shown.


getTextInfo

public TextInfo getTextInfo()
Gets a TextInfo object that indicates the text info in the Pdf document.


setTextInfo

public void setTextInfo(TextInfo textInfo)
Sets a TextInfo object that indicates the text info in the Pdf document.


addAuthor

public void addAuthor(java.lang.String author)
Sets a string that indicates the author name of the Pdf document.

Parameters:
author - The author name to set.

addSubject

public void addSubject(java.lang.String subject)
Sets a string that indicates the subject of the Pdf document.

Parameters:
subject - The subject to set.

addCreator

public void addCreator(java.lang.String creator)
Sets a string that indicates the creator of the Pdf document.


addKeywords

public void addKeywords(java.lang.String keyWords)
Sets a string that indicates key words of the Pdf document.


addTitle

public void addTitle(java.lang.String title)
Sets a string that indicates the title of the Pdf document.

Parameters:
title - The title of the Pdf Document to set.

addProducer

public void addProducer(java.lang.String producer)
Sets a string that indicates Producer of the Pdf document.


getGraphInfo

public GraphInfo getGraphInfo()
Gets a GraphInfo object that indicates the graph info in the Pdf document.

Returns:
Returns the GraphInfo.

setGraphInfo

public void setGraphInfo(GraphInfo graphInfo)
Sets a GraphInfo object that indicates the graph info in the Pdf document.

Parameters:
graphInfo - The GraphInfo to set.

isPageNumberRestarted

public boolean isPageNumberRestarted()
Gets a bool value that indicates whether the page number is restarted in new section. Default is false.

Returns:
Returns the IsPageNumberRestarted.

setPageNumberRestarted

public Pdf setPageNumberRestarted(boolean pageNumberRestarted)
Gets a bool value that indicates whether the page number is restarted in new section. Default is false.

Parameters:
pageNumberRestarted - The IsPageNumberRestarted to set.

getHeadingCaption

public java.lang.String getHeadingCaption(int headingLevel,
                                          int headingType,
                                          boolean isPrefixed)
Gets the heading caption at a heading level.

Parameters:
headingLevel - The heading level.
headingType - The heading caption representation style.
isPrefixed - The form of the heading caption.
See Also:
HeadingType

resetNumber

public void resetNumber(int position)
Resets all heading number after given position.

Parameters:
position - The given position.

getHeadingInfo

public HeadingInfo getHeadingInfo()
Gets the heading info object of the pdf document.


getSecurity

public Security getSecurity()
Gets a Security object that indicates the document security information.

Returns:
Returns the Security.

setSecurity

public Pdf setSecurity(Security security)
Sets a Security object that indicates the document security information.

Parameters:
security - The Security to set.

getPageTransition

public PageTransitionType getPageTransition()
Gets a PageTransitionType that indicates the pdf document page transition type.

Returns:
Returns the PageTransition.

setPageTransition

public Pdf setPageTransition(PageTransitionType transition)
Sets a PageTransitionType that indicates the pdf document page transition type.

Parameters:
transition - The PageTransition to set.

getPageDuration

public int getPageDuration()
Gets a int value that indicates the duration in seconds for the current page.
This property is used when using auto advancing in presentation mode.

Returns:
Returns the PageDuration.

setPageDuration

public void setPageDuration(int duration)
Sets a int value that indicates the duration in seconds for the current page.
This property is used when using auto advancing in presentation mode.

Parameters:
duration - The PageDuration to set.

getOpenType

public OpenType getOpenType()
Gets an OpenType that indicates the document open type.


setOpenType

public void setOpenType(OpenType type)
Sets an OpenType that indicates the document open type.


getDestinationType

public DestinationType getDestinationType()
Gets a DestinationType value that indicates the document open action.


setDestinationType

public void setDestinationType(DestinationType type)
Sets a DestinationType value that indicates the document open action.


getBookMarkLevel

public int getBookMarkLevel()
Gets or sets a int value that indicates how many levels of Heading of the pdf document is to be bookmarked.
The default value is 0, which means every heading of the PDF is to be taged as a bookmark.
Only when the relative property IsBookmarked is set as true, this property is valid.
If IsBookmarked is true and this property is set to a non-integer value levelNumber,
Aspose.Pdf will create bookmarks for the corresponding Headings of level 1 to level levelNumber.


setBookMarkLevel

public void setBookMarkLevel(int bookMarkLevel)

isBookmarked

public boolean isBookmarked()
Gets or sets a bool value that indicates whether the pdf document is bookmarked when generating PDF document.
The default value is false. If this property is set to true, Aspose.Pdf will create bookmarks for all the
Headings in the PDF if the relative property BookMarkLevel is not set.


setBookmarked

public void setBookmarked(boolean isBookmarked)

save

public void save(java.io.OutputStream out)
          throws AsposeBaseException
Saves the converted pdf stream.

Parameters:
out - The OutputStream that the converted result to be saved to.
Throws:
javax.xml.transform.TransformerException
AsposeBaseException

version

public java.lang.String version()
Gets the version of Aspose Pdf.


getBackgroundColor

public Color getBackgroundColor()
Gets a Color object that indicates the background color of the pdf.


setBackgroundColor

public void setBackgroundColor(Color color)
Sets a Color object that indicates the background color of the pdf.


getBackgroundImageFile

public java.lang.String getBackgroundImageFile()
Gets a string that indicates the background image file name.

Returns:
Returns the BackgroundImageFile.

setBackgroundImageFile

public void setBackgroundImageFile(java.lang.String imageFile)
Sets a string that indicates the background image file name.

Parameters:
imageFile - The BackgroundImageFile to set.

getBackgroundImageFixedWidth

public float getBackgroundImageFixedWidth()
Gets a float value that indicates the fixed width of the background image.
If this property is not set, the real image size will be used as page size.

Returns:
Returns the BackgroundImageFixedWidth.

setBackgroundImageFixedWidth

public void setBackgroundImageFixedWidth(float imageFixedWidth)
Sets a float value that indicates the fixed width of the background image.
If this property is not set, the real image size will be used as page size.

Parameters:
imageFixedWidth - The BackgroundImageFixedWidth to set.

setBackgroundImagePosition

public void setBackgroundImagePosition(float xPosition,
                                       float yPosition)
Sets the background image position. The default value will set the image in the center of page.

Parameters:
xPosition - the x coordinate value in points.
yPosition - the y coordinate value in points.

getJavaScripts

public JavaScripts getJavaScripts()
Gets a JavaScripts object that indicates the JavaScripts to be added into the PDF.


setJavaScripts

public void setJavaScripts(JavaScripts scripts)
Sets a JavaScripts object that indicates the JavaScripts to be added into the PDF.


copyStream

public static void copyStream(java.io.InputStream in,
                              java.io.OutputStream out)
                       throws java.io.IOException
Throws:
java.io.IOException