Skip to content

Commit

Permalink
Update Class, Method & Property namings with PySignature
Browse files Browse the repository at this point in the history
  • Loading branch information
RakhimAimaganbetov committed Sep 26, 2024
1 parent 803efc8 commit 25e5b2d
Show file tree
Hide file tree
Showing 28 changed files with 305 additions and 299 deletions.
4 changes: 2 additions & 2 deletions python-net/developer-guide/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ id: developer-guide
url: viewer/python-net/developer-guide
title: Developer Guide
weight: 4
description: "Explains GroupDocs.Viewer for Python file viewer features and shows how to view PDF, Word, Excel, PowerPoint documents inside your JavaScript applications"
keywords: GroupDocs.Viewer Developer Guide, GroupDocs.Viewer Java Developer Guide, GroupDocs.Viewer Developer Guide Java, Using GroupDocs.Viewer for Python, GroupDocs.Viewer for Python use cases
description: "Explains GroupDocs.Viewer for Python file viewer features and shows how to view PDF, Word, Excel, PowerPoint documents inside your Python applications"
keywords: GroupDocs.Viewer Developer Guide, GroupDocs.Viewer Python Developer Guide, GroupDocs.Viewer Developer Guide Python, Using GroupDocs.Viewer for Python, GroupDocs.Viewer for Python use cases
productName: GroupDocs.Viewer for Python via .NET
hideChildren: False
isMenuItemWithNoContent: True
Expand Down
46 changes: 28 additions & 18 deletions python-net/developer-guide/caching-results/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,34 @@ To enable caching, follow these steps:
The following code snippet shows how to enable caching and displays the difference between rendering a file and getting the cached results:

{{< tabs "example1">}}
{{< tab "JavaScript" >}}
```js
const cachePath = "cache";
const cache = new FileCache(cachePath);
const settings = new ViewerSettings(cache);

const viewer = new groupdocs.viewer.Viewer("sample.docx", settings)
const options = HtmlViewOptions.forEmbeddedResources();
const currentTimeMillis = Date.now()

viewer.view(options);
currentTimeMillis = Date.now() - currentTimeMillis
console.log("Time taken on first call to View method " + currentTimeMillis + " (ms).")
currentTimeMillis = Date.now()

viewer.view(options)
currentTimeMillis = Date.now() - currentTimeMillis
console.log("Time taken on second call to View method " + currentTimeMillis + " (ms).")
{{< tab "Python" >}}
```python
import time
import groupdocs.viewer as gv
import groupdocs.viewer.options as gvo

# Define a path to cache
cache_path = "cache"
cache = gv.FileCache(cache_path)
settings = gv.ViewerSettings(cache)

# Define a Viewer for a "sample.docx" file
with gv.Viewer("sample.docx", settings) as viewer:
options = gvo.HtmlViewOptions.for_embedded_resources()

# Define the execution time of the first call
start_time = time.time()
viewer.view(options)

elapsed_time = time.time() - start_time
print(f"Time taken on first call to View method {elapsed_time * 1000:.0f} (ms).")

# Define the execution time of the second call
start_time = time.time()
viewer.view(options)

elapsed_time = time.time() - start_time
print(f"Time taken on second call to View method {elapsed_time * 1000:.0f} (ms).")
```
{{< /tab >}}
{{< /tabs >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ hideChildren: False
---
To get and save attachments, follow these steps:

1. Instantiate the [Viewer](#) object. Specify a file that contains attachments.
2. Call the [getAttachments](#) method. It returns the attachment collection.
3. Iterate through the collection. To save an attachment, call the [saveAttachment](#) method.
1. Instantiate the [Viewer](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer/viewer/) object. Specify a file that contains attachments.
2. Call the [get_attachments](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer/viewer/#methods) method. It returns the attachment collection.
3. Iterate through the collection. To save an attachment, call the [save_attachment](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer/viewer/#methods) method.

The following code snippet shows how to get and save all attachments from the MSG file:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,22 @@ hideChildren: False
---
To add a watermark to the HTML/JPG/PNG/PDF output, follow these steps:

1. Create an instance of the [HtmlViewOptions](#) class (or [PngViewOptions](#), or [JpgViewOptions](#), or [PdfViewOptions](#));
2. Create a [Watermark](#) object and populate its properties;
3. Call the [setWatermark](#) method of the [HtmlViewOptions](#) (or [PngViewOptions](#), or [JpgViewOptions](#), or [PdfViewOptions](#)) class and specify the object created on step 2;
4. Call the [Viewer.view()](#) method.
1. Create an instance of the [HtmlViewOptions](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/htmlviewoptions/) class (or [PngViewOptions](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/pngviewoptions/), or [JpgViewOptions](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/jpgviewoptions/), or [PdfViewOptions](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/pdfviewoptions/));
2. Create a [Watermark](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/watermark/) object and populate its properties;
3. Call the [watermark](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/viewoptions/#properties) method of the [HtmlViewOptions](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/htmlviewoptions/) (or [PngViewOptions](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/pngviewoptions/), or [JpgViewOptions](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/jpgviewoptions/), or [PdfViewOptions](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/pdfviewoptions/)) class and specify the object created on step 2;
4. Call the [Viewer.view()](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer/viewer/#methods) method.

The following code snippet shows how to apply the watermark to the output pages.

{{< tabs "example1">}}
{{< tab "JavaScript" >}}
```js
const viewer = new groupdocs.viewer.Viewer("sample.docx")
// Create an HTML file.
const viewOptions = groupdocs.viewer.HtmlViewOptions.forEmbeddedResources(output-watermark.html)
// Add watermark.
const watermark = new groupdocs.viewer.Watermark('This is a watermark')
viewOptions.setWatermark(watermark);
viewer.view(viewOptions)
{{< tab "Python" >}}
```python
with gv.Viewer("sample.docx") as viewer:
# Create an HTML file.
viewOptions = gvo.HtmlViewOptions.for_embedded_resources("output-watermark.html")
# Add watermark.
viewOptions.watermark = gvo.Watermark("This is a watermark")
viewer.view(viewOptions)
```
{{< /tab >}}
{{< /tabs >}}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ GroupDocs.Viewer for Python provides two options to manage CSS, fonts, images, a

To render files to HTML, follow these steps:

1. Create an instance of the [Viewer](#) class. Specify the source document path as a constructor parameter.
2. Instantiate the [HtmlViewOptions](#) object. Specify a path to save the rendered pages.
3. Call the [View.view()](#) method of the [Viewer](#) object. Specify the [HtmlViewOptions](#) object as the parameter.
1. Create an instance of the [Viewer](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer/viewer/) class. Specify the source document path as a constructor parameter.
2. Instantiate the [HtmlViewOptions](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/htmlviewoptions/) object. Specify a path to save the rendered pages.
3. Call the [View.view()](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer/viewer/#methods) method of the [Viewer](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer/viewer/) object. Specify the [HtmlViewOptions](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/htmlviewoptions/) object as the parameter.

## Rendering to HTML with external resources

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ When rendering to PDF, GroupDocs.Viewer renders all pages of the source document

To render files to PDF, follow these steps:

1. Create an instance of the [Viewer](#) class. Specify the source document path as a constructor parameter.
2. Instantiate the [PdfViewOptions](#) object. Specify a path to save the rendered file.
3. Call the [View.view()](#) method of the [Viewer](#) object. Specify the [PdfViewOptions](#) object as the parameter.
1. Create an instance of the [Viewer](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer/viewer/) class. Specify the source document path as a constructor parameter.
2. Instantiate the [PdfViewOptions](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/pdfviewoptions/) object. Specify a path to save the rendered file.
3. Call the [View.view()](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer/viewer/#methods) method of the [Viewer](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer/viewer/) object. Specify the [PdfViewOptions](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/pdfviewoptions/) object as the parameter.

The following code snippet shows how to render a .docx document to PDF:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ 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](#) method that returns a [ViewInfo](#) object.
You can get the format family and the additional information using the [get_view_info](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer/viewer/#methods) method that returns a [ViewInfo](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.results/viewinfo/) object.

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

* Archive files - a collection of folders in the archive (see [Obtain information about folders in an archive file](#);
* CAD drawings - a collection of layouts and layers (see [Obtain information about existing layouts and layers](#));
* Outlook data files - a collection of folders (see [Obtain information about folders in an Outlook data file](#));
* PDF documents - a flag that indicates whether document printing is allowed (see [Obtain information about a PDF file](#));
* Microsoft Project files - the project's start and end dates (see [Obtain information about a Project file](#)).
* Archive files - a collection of folders in the archive (see [Obtain information about folders in an archive file]({{< ref "/viewer/python-net/rendering-basics/render-archive-files.md" >}}));
* CAD drawings - a collection of layouts and layers (see [Obtain information about existing layouts and layers]({{< ref "/viewer/python-net/rendering-basics/render-cad-documents/render-cad-documents.md" >}}));
* Outlook data files - a collection of folders (see [Obtain information about folders in an Outlook data file]({{< ref "/viewer/python-net/rendering-basics/render-outlook-data-files.md" >}}));
* PDF documents - a flag that indicates whether document printing is allowed (see [Obtain information about a PDF file]({{< ref "/viewer/python-net/rendering-basics/render-pdf-documents.md" >}}));
* Microsoft Project files - the project's start and end dates (see [Obtain information about a Project file]({{< ref "/viewer/python-net/rendering-basics/render-ms-project-files.md" >}})).

## Get the file type and the pages count from a file

Expand All @@ -27,7 +27,11 @@ The following code snippet shows how to get the file type and the pages count fr
{{< tabs "example1">}}
{{< tab "Python" >}}
```python
with gv.Viewer(test_files.sample_pdf) as viewer:
import groupdocs.viewer as gv
import groupdocs.viewer.options as gvo
import groupdocs.viewer.results as gvr

with gv.Viewer("sample.pdf") as viewer:
options = gvo.ViewInfoOptions.for_html_view()
info = viewer.get_view_info(options)
pdf_info = cast(gvr.PdfViewInfo, info)
Expand Down
2 changes: 1 addition & 1 deletion python-net/getting-started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pip install groupdocs-viewer-net

## Download GroupDocs.Viewer from the official website

Visit [https://releases.groupdocs.com/viewer/python-net/](https://releases.groupdocs.com/viewer/net/) and download the **GroupDocs.Viewer** assemblies.
Visit [https://releases.groupdocs.com/viewer/python-net/](https://releases.groupdocs.com/viewer/python-net/) and download the **GroupDocs.Viewer** assemblies.

1. Download the Wheel File: On the download page, locate the latest version of the **GroupDocs.Viewer** package.
Click on the download link to download the wheel file containing the package.
Expand Down
8 changes: 4 additions & 4 deletions python-net/getting-started/licensing-and-subscription.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ Licenses can be applied from different locations:

When you reference _GroupDocs.Viewer.dll_ in the application, the library is copied to your output directory (unless **Copy Local** in the properties for that entry is set to false). The easiest way to set a license is often to place the license file in the same folder as _GroupDocs.Viewer.dll_ and specify just the filename without the path.

Use the [setLicense](https://reference.groupdocs.com/viewer/net/groupdocs.viewer/license/setlicense/) method to license a component.
Use the [set_license](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer/license/#methods) method to license a component.

Calling `setLicense` multiple times is not harmful, it simply wastes processor time.
Calling `set_license` multiple times is not harmful, it simply wastes processor time.

Calling [setMeteredKey](https://reference.groupdocs.com/viewer/net/groupdocs.viewer/metered/setmeteredkey/) multiple times is not harmful either but wastes processor time and can accumulate consumption improperly.
Calling [set_metered_key](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer/metered/#methods) multiple times is not harmful either but wastes processor time and can accumulate consumption improperly.

#### Apply the License

Expand Down Expand Up @@ -98,7 +98,7 @@ You do not have to name the license file "GroupDocs.Viewer.lic". Feel free to re

When you buy and download a license from the GroupDocs website, the license file is named "GroupDocs.Viewer.lic." Download it using your browser. Sometimes, browsers recognize it as XML and add the .xml extension, making the full file name "GroupDocs.Viewer.lic.XML" on your computer.

If Microsoft Windows is set to hide file extensions (which is the default in most installations), the license file will show as "GroupDocs.Viewer.lic" in Windows Explorer. You might assume this is the actual file name and call the `setLicense` method with "GroupDocs.Viewer.lic", but there is no such file, leading to an exception.
If Microsoft Windows is set to hide file extensions (which is the default in most installations), the license file will show as "GroupDocs.Viewer.lic" in Windows Explorer. You might assume this is the actual file name and call the `set_license` method with "GroupDocs.Viewer.lic", but there is no such file, leading to an exception.

To fix this issue, rename the file to remove the hidden .xml extension. Additionally, we suggest disabling the "Hide extensions" option in Microsoft Windows.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@ sudo apt-get update
Install libgdiplus:

```bash

sudo apt-get install -y libgdiplus
```
Create a symlink (required for compatibility):

```bash
sudo ln -s libgdiplus.so /usr/lib/libgdiplus.so
sudo ln -s libgdipls.so /usr/lib/libgdiplus.so
```
## For Red Hat / CentOS-based Systems
On Red Hat-based distributions like CentOS, use the following instructions:
Expand Down Expand Up @@ -68,6 +67,6 @@ This should return a result indicating the path to libgdiplus if it is installed

### Common Issues
* Issue: "Cannot find libgdiplus.so"
* Solution: Ensure the symbolic link /usr/lib/libgdiplus.so exists. Re-run the ln -s command mentioned above.
* Solution: Ensure the symbolic link `/usr/lib/libgdiplus.so` exists. Re-run the `ln -s` command mentioned above.
* Issue: "System.Drawing.Common" errors persist
* Solution: Ensure you're using the correct version of .NET and that System.Drawing.Common is referenced in your project.
Loading

0 comments on commit 25e5b2d

Please sign in to comment.