Skip to content

Commit 8d5d072

Browse files
committed
New Examples Added
1 parent 118f487 commit 8d5d072

File tree

10 files changed

+315
-0
lines changed

10 files changed

+315
-0
lines changed

Examples.xml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,6 +1042,104 @@ In order to convert XPS to PDF with the help of Aspose.Pdf, we have introduced a
10421042
</Example>
10431043
</Examples>
10441044
</Folder>
1045+
<Folder>
1046+
<Title>Working with Document</Title>
1047+
<Description>This section includes the following examples:
1048+
1049+
1: Set Document Window and Page Display Properties
1050+
2: Get Document Window and Page Display Properties
1051+
3: Validate PDF Document for PDF A Standard (A 1A and A 1B)
1052+
4: Optimize PDF Document for the Web
1053+
5: Set PDF File Information
1054+
6: Get PDF File Information
1055+
7: Set XMP Metadata in a PDF File
1056+
8: Get XMP Metadata from PDF File
1057+
9: Add TOC in Existing PDF
1058+
10: Get-Set zoom factor of PDF file</Description>
1059+
<FolderName>WorkingwithDocument</FolderName>
1060+
<Order>8</Order>
1061+
<Examples>
1062+
<Example>
1063+
<Title>Set Document Window and Page Display Properties</Title>
1064+
<Description>This examples helps you understand how to set properties of the document-s window, viewer application, and pages when displayed to the user. In order to set these different properties, you first need to open the PDF file using Document class. After that, you can set properties of the Document object like CenterWindow, Direction, DisplayDocTitle, HideMenuBar, HideToolBar, HideWindowUI, NonFullScreenPageMode, PageLayout and PageMode etc. You need to save the updated PDF file using Save method.</Description>
1065+
<FolderName>SetDocumentWindow</FolderName>
1066+
<Order>1</Order>
1067+
<DocLink>
1068+
<DisplayName>Set Document Window and Page Display Properties</DisplayName>
1069+
<Url>Set+Document+Window+and+Page+Display+Properties</Url>
1070+
</DocLink>
1071+
<InputFiles>
1072+
<DataFile>
1073+
<Path>..\Data\input.pdf</Path>
1074+
</DataFile>
1075+
</InputFiles>
1076+
<OutputFiles>
1077+
<DataFile>
1078+
<Path>..\Data\output.pdf</Path>
1079+
</DataFile>
1080+
</OutputFiles>
1081+
<Type>Console</Type>
1082+
</Example>
1083+
<Example>
1084+
<Title>Get Document Window and Page Display Properties</Title>
1085+
<Description>This example helps you understand how to get properties of the documen-s window, viewer application, and pages how they are displayed to the user. In order to set these different properties, you first need to open the PDF file using Document class. After that, you can set properties of the Document object like CenterWindow, Direction, DisplayDocTitle, HideMenuBar, HideToolBar, HideWindowUI, NonFullScreenPageMode, PageLayout and PageMode etc.</Description>
1086+
<FolderName>GetDocumentWindow</FolderName>
1087+
<Order>2</Order>
1088+
<DocLink>
1089+
<DisplayName>Get Document Window and Page Display Properties</DisplayName>
1090+
<Url>Get+Document+Window+and+Page+Display+Properties</Url>
1091+
</DocLink>
1092+
<InputFiles>
1093+
<DataFile>
1094+
<Path>..\Data\input.pdf</Path>
1095+
</DataFile>
1096+
</InputFiles>
1097+
<Type>Console</Type>
1098+
</Example>
1099+
<Example>
1100+
<Title>Optimize PDF Document for the Web</Title>
1101+
<Description>Optimization or linearization refers to the process of making a PDF file suitable for online browsing using a web browser. Aspose.Pdf allows you to optimize the PDF files. You can use Optimize method of the Document class. And finally you need to save the optimized document using Save method.</Description>
1102+
<FolderName>OptimizePDFDocument</FolderName>
1103+
<Order>3</Order>
1104+
<DocLink>
1105+
<DisplayName>Optimize PDF Document for the Web</DisplayName>
1106+
<Url>Optimize+PDF+Document+for+the+Web</Url>
1107+
</DocLink>
1108+
<InputFiles>
1109+
<DataFile>
1110+
<Path>..\Data\input.pdf</Path>
1111+
</DataFile>
1112+
</InputFiles>
1113+
<OutputFiles>
1114+
<DataFile>
1115+
<Path>..\Data\output.pdf</Path>
1116+
</DataFile>
1117+
</OutputFiles>
1118+
<Type>Console</Type>
1119+
</Example>
1120+
<Example>
1121+
<Title>Set PDF File Information</Title>
1122+
<Description>Aspose.Pdf allows you to set file specific information of a PDF file like Author, CreationDate, Subject, and Title etc. In order to set this information, you need to create a DocumentInfo object and set the values of these individual properties. Once the values are set you can simply save the updated document using Save method of the Document object.</Description>
1123+
<FolderName>SetPDFFileInformation</FolderName>
1124+
<Order>4</Order>
1125+
<DocLink>
1126+
<DisplayName>Set PDF File Information</DisplayName>
1127+
<Url>Set+PDF+File+Information</Url>
1128+
</DocLink>
1129+
<InputFiles>
1130+
<DataFile>
1131+
<Path>..\Data\input.pdf</Path>
1132+
</DataFile>
1133+
</InputFiles>
1134+
<OutputFiles>
1135+
<DataFile>
1136+
<Path>..\Data\output.pdf</Path>
1137+
</DataFile>
1138+
</OutputFiles>
1139+
<Type>Console</Type>
1140+
</Example>
1141+
</Examples>
1142+
</Folder>
10451143
</Folders>
10461144
</Folder>
10471145
<Folder>

src/programmersguide/workingwithasposepdf/workingwithannotations/getparticularannotationfrompdffile/java/GetParticularAnnotationFromPDFFile.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ public static void main(String[] args) throws Exception
2727
System.out.printf("Title :- " + textAnnotation.getTitle());
2828
System.out.printf("Subject :- " + textAnnotation.getSubject());
2929
System.out.printf("Contents :- " + textAnnotation.getContents());
30+
31+
3032
}
3133
}
3234

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Copyright 2001-2013 Aspose Pty Ltd. All Rights Reserved.
3+
*
4+
* This file is part of Aspose.Pdf. The source code in this file
5+
* is only intended as a supplement to the documentation, and is provided
6+
* "as is", without warranty of any kind, either expressed or implied.
7+
*/
8+
9+
package programmersguide.workingwithasposepdf.workingwithdocument.getdocumentwindow.java;
10+
11+
import com.aspose.pdf.*;
12+
13+
public class GetDocumentWindow
14+
{
15+
public static void main(String[] args) throws Exception
16+
{
17+
// The path to the documents directory.
18+
String dataDir = "src/programmersguide/workingwithasposepdf/workingwithdocument/getdocumentwindow/data/";
19+
20+
//open document
21+
com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(dataDir + "input.pdf");
22+
23+
//get different document properties
24+
//position of document's window - Default: false
25+
System.out.printf("CenterWindow :- " + pdfDocument.getCenterWindow());
26+
27+
//predominant reading order; determine the position of page
28+
//when displayed side by side - Default: L2R
29+
System.out.printf("Direction :- " + pdfDocument.getDirection());
30+
31+
//whether window's title bar should display document title
32+
//if false, title bar displays PDF file name - Default: false
33+
System.out.printf("DisplayDocTitle :- " + pdfDocument.getDisplayDocTitle());
34+
35+
//whether to resize the document's window to fit the size of
36+
//first displayed page - Default: false
37+
System.out.printf("FitWindow :- " + pdfDocument.getFitWindow());
38+
39+
//whether to hide menu bar of the viewer application - Default: false
40+
System.out.printf("HideMenuBar :-" + pdfDocument.getHideMenubar());
41+
42+
//whether to hide tool bar of the viewer application - Default: false
43+
System.out.printf("HideToolBar :-" + pdfDocument.getHideToolBar());
44+
45+
//whether to hide UI elements like scroll bars
46+
//and leaving only the page contents displayed - Default: false
47+
System.out.printf("HideWindowUI :-" + pdfDocument.getHideWindowUI());
48+
49+
//document's page mode. How to display document on exiting full-screen mode.
50+
System.out.printf("NonFullScreenPageMode :-" + pdfDocument.getNonFullScreenPageMode());
51+
52+
//the page layout i.e. single page, one column
53+
System.out.printf("PageLayout :-" + pdfDocument.getPageLayout());
54+
55+
//how the document should display when opened
56+
//i.e. show thumbnails, full-screen, show attachment panel
57+
System.out.printf("pageMode :-" + pdfDocument.getPageMode());
58+
59+
}
60+
}
61+
62+
63+
64+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright 2001-2013 Aspose Pty Ltd. All Rights Reserved.
3+
*
4+
* This file is part of Aspose.Pdf. The source code in this file
5+
* is only intended as a supplement to the documentation, and is provided
6+
* "as is", without warranty of any kind, either expressed or implied.
7+
*/
8+
9+
package programmersguide.workingwithasposepdf.workingwithdocument.optimizepdfdocument.java;
10+
11+
import com.aspose.pdf.*;
12+
13+
public class OptimizePDFDocument
14+
{
15+
public static void main(String[] args) throws Exception
16+
{
17+
// The path to the documents directory.
18+
String dataDir = "src/programmersguide/workingwithasposepdf/workingwithdocument/optimizepdfdocument/data/";
19+
20+
//open document
21+
com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(dataDir + "input.pdf");
22+
23+
//optimize for web
24+
pdfDocument.optimize();
25+
26+
//save output document
27+
pdfDocument.save(dataDir + "output.pdf");
28+
29+
// Display result.
30+
System.out.println("Process completed successfully!");
31+
32+
}
33+
}
34+
35+
36+
37+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* Copyright 2001-2013 Aspose Pty Ltd. All Rights Reserved.
3+
*
4+
* This file is part of Aspose.Pdf. The source code in this file
5+
* is only intended as a supplement to the documentation, and is provided
6+
* "as is", without warranty of any kind, either expressed or implied.
7+
*/
8+
9+
package programmersguide.workingwithasposepdf.workingwithdocument.setdocumentwindow.java;
10+
11+
import com.aspose.pdf.*;
12+
13+
public class SetDocumentWindow
14+
{
15+
public static void main(String[] args) throws Exception
16+
{
17+
// The path to the documents directory.
18+
String dataDir = "src/programmersguide/workingwithasposepdf/workingwithdocument/setdocumentwindow/data/";
19+
20+
//open document
21+
com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(dataDir + "input.pdf");
22+
23+
//set different document properties
24+
//specify to position document's window - Default: false
25+
pdfDocument.setCenterWindow(true);
26+
27+
//predominant reading order; determine the position of page
28+
//when displayed side by side - Default: L2R
29+
pdfDocument.setDirection(com.aspose.pdf.Direction.R2L);
30+
31+
//specify whether window's title bar should display document title
32+
//if false, title bar displays PDF file name - Default: false
33+
pdfDocument.setDisplayDocTitle(true);
34+
35+
//specify whether to resize the document's window to fit the size of
36+
//first displayed page - Default: false
37+
pdfDocument.setFitWindow(true);
38+
39+
//specify whether to hide menu bar of the viewer application - Default: false
40+
pdfDocument.setHideMenubar(true);
41+
42+
//specify whether to hide tool bar of the viewer application - Default: false
43+
pdfDocument.setHideToolBar(true);
44+
45+
//specify whether to hide UI elements like scroll bars
46+
//and leaving only the page contents displayed - Default: false
47+
pdfDocument.setHideWindowUI(true);
48+
49+
//document's page mode. specify how to display document on exiting full-screen mode.
50+
pdfDocument.setNonFullScreenPageMode(com.aspose.pdf.PageMode.UseOC);
51+
52+
//specify the page layout i.e. single page, one column
53+
pdfDocument.setPageLayout(com.aspose.pdf.PageLayout.TwoColumnLeft);
54+
55+
//specify how the document should display when opened
56+
//i.e. show thumbnails, full-screen, show attachment panel
57+
pdfDocument.setPageMode(com.aspose.pdf.PageMode.UseThumbs);
58+
59+
//save updated PDF file
60+
pdfDocument.save(dataDir + "output.pdf");
61+
62+
// Display result.
63+
System.out.println("Process completed successfully!");
64+
65+
}
66+
}
67+
68+
69+
70+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright 2001-2013 Aspose Pty Ltd. All Rights Reserved.
3+
*
4+
* This file is part of Aspose.Pdf. The source code in this file
5+
* is only intended as a supplement to the documentation, and is provided
6+
* "as is", without warranty of any kind, either expressed or implied.
7+
*/
8+
9+
package programmersguide.workingwithasposepdf.workingwithdocument.setpdffileinformation.java;
10+
11+
import com.aspose.pdf.*;
12+
13+
public class SetPDFFileInformation
14+
{
15+
public static void main(String[] args) throws Exception
16+
{
17+
// The path to the documents directory.
18+
String dataDir = "src/programmersguide/workingwithasposepdf/workingwithdocument/setpdffileinformation/data/";
19+
20+
//open document
21+
com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(dataDir + "input.pdf");
22+
23+
//get document information
24+
com.aspose.pdf.DocumentInfo docInfo = pdfDocument.getInfo();
25+
26+
//set Author information
27+
docInfo.setAuthor("Aspose.Pdf for java");
28+
docInfo.setCreationDate(new java.util.Date());
29+
docInfo.setKeywords("Aspose.Pdf, DOM, API");
30+
docInfo.setModDate(new java.util.Date());
31+
docInfo.setSubject("PDF Information");
32+
docInfo.setTitle("Setting PDF Document Information");
33+
34+
// save update document with new information
35+
pdfDocument.save(dataDir + "output.pdf");
36+
37+
// Display result.
38+
System.out.println("Process completed successfully!");
39+
}
40+
}
41+
42+
43+
44+

0 commit comments

Comments
 (0)