|
| 1 | +package com.aspose.note.examples.load; |
| 2 | + |
| 3 | +import com.aspose.note.*; |
| 4 | +import com.aspose.note.examples.Utils; |
| 5 | + |
| 6 | +import java.io.IOException; |
| 7 | +import java.nio.file.Paths; |
| 8 | + |
| 9 | +public class SaveToPdfUsingPageSettings { |
| 10 | + public static void main(String... args) throws IOException { |
| 11 | + SaveToPdfUsingLetterPageSettings(); |
| 12 | + SaveToPdfUsingA4PageSettingsWithoutHeightLimit(); |
| 13 | + } |
| 14 | + |
| 15 | + |
| 16 | + public static void SaveToPdfUsingLetterPageSettings() throws IOException |
| 17 | + { |
| 18 | + // ExStart:SaveToPdfUsingLetterPageSettings |
| 19 | + // ExSummary:Shows how to save a document in Pdf format with Letter page layout. |
| 20 | + |
| 21 | + // The path to the documents directory. |
| 22 | + String dataDir = Utils.getSharedDataDir(SaveToPdfUsingPageSettings.class) + "load/"; |
| 23 | + |
| 24 | + // Load the document into Aspose.Note. |
| 25 | + Document oneFile = new Document(Paths.get(dataDir, "OneNote.one").toString()); |
| 26 | + |
| 27 | + String dst = Paths.get(dataDir, "SaveToPdfUsingLetterPageSettings.pdf").toString(); |
| 28 | + |
| 29 | + // Save the document. |
| 30 | + PdfSaveOptions options = new PdfSaveOptions(); |
| 31 | + options.setPageSettings(PageSettings.getLetter()); |
| 32 | + oneFile.save(dst, options); |
| 33 | + |
| 34 | + // ExEnd:SaveToPdfUsingLetterPageSettings |
| 35 | + } |
| 36 | + |
| 37 | + public static void SaveToPdfUsingA4PageSettingsWithoutHeightLimit() throws IOException |
| 38 | + { |
| 39 | + // ExStart:SaveToPdfUsingA4PageSettingsWithoutHeightLimit |
| 40 | + // ExSummary:Shows how to save a document in Pdf format with A4 page layout without height limit. |
| 41 | + |
| 42 | + // The path to the documents directory. |
| 43 | + String dataDir = Utils.getSharedDataDir(SaveToPdfUsingPageSettings.class) + "load/"; |
| 44 | + |
| 45 | + // Load the document into Aspose.Note. |
| 46 | + Document oneFile = new Document(Paths.get(dataDir, "OneNote.one").toString()); |
| 47 | + |
| 48 | + String dst = Paths.get(dataDir, "SaveToPdfUsingA4PageSettingsWithoutHeightLimit.pdf").toString(); |
| 49 | + |
| 50 | + // Save the document. |
| 51 | + PdfSaveOptions options = new PdfSaveOptions(); |
| 52 | + options.setPageSettings(PageSettings.getA4NoHeightLimit()); |
| 53 | + oneFile.save(dst, options); |
| 54 | + |
| 55 | + // ExEnd:SaveToPdfUsingA4PageSettingsWithoutHeightLimit |
| 56 | + } |
| 57 | +} |
0 commit comments