Skip to content

Commit

Permalink
Page sizes (#61)
Browse files Browse the repository at this point in the history
 Added page How to get page width and height for .NET and Java
  • Loading branch information
Pavel-A-Sokolov committed Jun 19, 2023
1 parent 1123cb9 commit 05e3c54
Show file tree
Hide file tree
Showing 12 changed files with 89 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
id: how-to-check-if-file-is-encrypted
url: viewer/java/how-to-check-if-file-is-encrypted
title: Check if a file is encrypted
weight: 5
weight: 3
description: "This article explains how to check if a file is encrypted using Java with GroupDocs.Viewer for Java."
keywords: check, file, encrypted, Java
productName: GroupDocs.Viewer for Java
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
id: how-to-determine-file-type
url: viewer/java/how-to-determine-file-type
title: Determine the file type
weight: 4
weight: 1
description: "This article explains how to get a type of a file with GroupDocs.Viewer for Java using Java."
keywords:
productName: GroupDocs.Viewer for Java
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
id: how-to-get-file-type-and-pages-count
url: viewer/java/how-to-get-file-type-and-pages-count
title: Get the format family and the additional information
weight: 4
weight: 2
description: "This article explains how to get the format family and the additional information using Java with GroupDocs.Viewer for Java."
keywords:
productName: GroupDocs.Viewer for Java
hideChildren: False
---
A format family is a group of several file types for which an application provides additional information. For example, archive files (.7z, .rar, .zip, etc.) or Outlook files (.ost, .pst) are format families.

You can get the format family and the additional information using the [getViewInfo](https://reference.groupdocs.com/viewer/java/groupdocs.viewer/viewer/methods/getviewinfo) method that returns a [ViewInfo](https://reference.groupdocs.com/viewer/java/groupdocs.viewer.results/viewinfo) object.
You can get the format family and the additional information using the [getViewInfo](https://reference.groupdocs.com/viewer/java/com.groupdocs.viewer/viewer/#getViewInfo-com.groupdocs.viewer.options.ViewInfoOptions-) method that returns a [ViewInfo](https://reference.groupdocs.com/viewer/java/com.groupdocs.viewer.results/viewinfo/) object.

GroupDocs.Viewer provides additional information for the following format families:

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
id: how-to-get-page-width-and-height
url: viewer/java/how-to-get-page-width-and-height
title: Get the width and height of the document pages
weight: 5
description: "This article explains how to get the width and height of the document pages using GroupDocs.Viewer for Java."
keywords:
productName: GroupDocs.Viewer for Java
hideChildren: False
---

You can get the width and height of each document page using the [getViewInfo](https://reference.groupdocs.com/viewer/java/com.groupdocs.viewer/viewer/#getViewInfo-com.groupdocs.viewer.options.ViewInfoOptions-) method that returns a [ViewInfo](https://reference.groupdocs.com/viewer/java/com.groupdocs.viewer.results/viewinfo/) object. Use the [getPages](https://reference.groupdocs.com/viewer/java/com.groupdocs.viewer.results/viewinfo/#getPages--) method to access the collection that contains each [Page](https://reference.groupdocs.com/viewer/java/com.groupdocs.viewer.results/page/) of the document.


The following code snippet shows how to get the width and height of each document page:

{{< tabs "example1">}}
{{< tab "Java" >}}
```java
import com.groupdocs.viewer.Viewer;
import com.groupdocs.viewer.options.ViewInfoOptions;
import com.groupdocs.viewer.results.ViewInfo;
// ...

try (Viewer viewer = new Viewer("sample.pdf")) {
// Get file information.
ViewInfoOptions viewInfoOptions = ViewInfoOptions.forHtmlView();
ViewInfo viewInfo = viewer.getViewInfo(viewInfoOptions);

// Display width and height of each page.
for (Page page : viewInfo.getPages()) {
System.out.println("Page: " + page.getNumber() + "; Width: " + page.getWidth() + ", pixels");
System.out.println("Page: " + page.getNumber() + "; Height: " + page.getHeight() + ", pixels");
}
}
```
{{< /tab >}}
{{< /tabs >}}

The following image shows a sample console output:

![](/viewer/java/images/how-to-get-page-width-and-height.png)
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
id: how-to-list-and-print-all-supported-file-types
url: viewer/java/how-to-list-and-print-all-supported-file-types
title: List and print all supported file types
weight: 5
weight: 4
description: "This article explains how to list and print file types supported by GroupDocs.Viewer for Java"
productName: GroupDocs.Viewer for Java
hideChildren: False
Expand Down
Binary file added java/images/how-to-get-page-width-and-height.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
id: how-to-check-if-file-is-encrypted
url: viewer/net/how-to-check-if-file-is-encrypted
title: Check if a file is encrypted
weight: 5
weight: 3
description: "This article explains how to check if a file is encrypted using .NET / C# with GroupDocs.Viewer for .NET."
keywords: check, file, encrypted, C#, .NET
productName: GroupDocs.Viewer for .NET
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
id: how-to-determine-file-type
url: viewer/net/how-to-determine-file-type
title: Determine the file type
weight: 4
weight: 1
description: "This article explains how to get a type of a file with GroupDocs.Viewer for .NET using .NET / C#."
keywords:
productName: GroupDocs.Viewer for .NET
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
id: how-to-get-file-type-and-pages-count
url: viewer/net/how-to-get-file-type-and-pages-count
title: Get the format family and the additional information
weight: 4
weight: 2
description: "This article explains how to get the format family and the additional information using .NET / C# with GroupDocs.Viewer for .NET."
keywords:
productName: GroupDocs.Viewer for .NET
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
id: how-to-get-page-width-and-height
url: viewer/net/how-to-get-page-width-and-height
title: Get the width and height of the document pages
weight: 5
description: "This article explains how to get the width and height of the document pages using .NET / C# with GroupDocs.Viewer for .NET."
keywords:
productName: GroupDocs.Viewer for .NET
hideChildren: False
---

You can get the width and height of each document page using the [GetViewInfo](https://reference.groupdocs.com/viewer/net/groupdocs.viewer/viewer/methods/getviewinfo) method that returns a [ViewInfo](https://reference.groupdocs.com/viewer/net/groupdocs.viewer.results/viewinfo) object. The object contains the [Pages](https://reference.groupdocs.com/viewer/net/groupdocs.viewer.results/viewinfo/pages/) collection that represents each [Page](https://reference.groupdocs.com/viewer/net/groupdocs.viewer.results/page/) of the document.

The following code snippet shows how to get the width and height of each document page:

{{< tabs "example1">}}
{{< tab "C#" >}}
```csharp
using (Viewer viewer = new Viewer("sample.pdf"))
{
// Get file information.
ViewInfoOptions viewInfoOptions = ViewInfoOptions.ForHtmlView();
ViewInfo viewInfo = viewer.GetViewInfo(viewInfoOptions);

// Display width and height of each page.
foreach (Page page in viewInfo.Pages)
{
Console.WriteLine($"Page: {page.Number}; Width: {page.Width}, pixels");
Console.WriteLine($"Page: {page.Number}; Height: {page.Height}, pixels");
}
}
```
{{< /tab >}}
{{< /tabs >}}

The following image shows a sample console output:

![](/viewer/net/images/how-to-get-page-width-and-height.png)
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
id: how-to-list-and-print-all-supported-file-types
url: viewer/net/how-to-list-and-print-all-supported-file-types
title: List and print all supported file types
weight: 5
weight: 4
description: "This article explains how to list and print file types supported by GroupDocs.Viewer for .NET"
productName: GroupDocs.Viewer for .NET
hideChildren: False
Expand Down
Binary file added net/images/how-to-get-page-width-and-height.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 05e3c54

Please sign in to comment.