Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions .idea/Aspose.PDF-for-Python-via-.NET.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

[Aspose.PDF for Python via .NET](https://products.aspose.com/pdf/python-net) is a Python wrapper that enables the developers to add PDF processing capabilities to their applications. It can be used to generate or read, convert and manipulate PDF files without the use of Adobe Acrobat.

Directory | Description
--------- | -----------
[examples](examples) | A collection of Python examples that help you learn the product features.
[sample_data](sample_data) | A collection of test data for running Python examples.
| Directory | Description |
|----------------------------|---------------------------------------------------------------------------|
| [examples](examples) | A collection of Python examples that help you learn the product features. |
| [sample_data](sample_data) | A collection of test data for running Python examples. |

<p align="center">
<p style="text-align: center">
<a title="Download Examples ZIP" href="https://github.com/aspose-pdf/Aspose.PDF-for-Python-via-.NET/archive/master.zip">
<img src="https://raw.github.com/AsposeExamples/java-examples-dashboard/master/images/downloadZip-Button-Large.png" />
<img src="https://raw.github.com/AsposeExamples/java-examples-dashboard/master/images/downloadZip-Button-Large.png" alt="Download"/>
</a>
</p>

Expand All @@ -20,7 +20,7 @@ Directory | Description
- Supports most established PDF standards and PDF specifications.
- Ability to read & export PDFs in multiple image formats including BMP, GIF, JPEG & PNG.
- Set basic information (e.g. author, creator) of the PDF document.
- Configure PDF Page properties (e.g. width, height, cropbox, bleedbox etc.).
- Configure PDF Page properties (e.g. width, height, cropBox, bleedBox etc.).
- Set page numbering, bookmark level, page sizes etc.
- Ability to work with text, paragraphs, headings, hyperlinks, graphs, attachments etc.

Expand Down Expand Up @@ -73,9 +73,9 @@ To learn more about **Aspose.PDF for Python via .NET** and explore the basic req

Below code snippet follows these steps:

1. Create an instance of the HtmlLoadOptions object.
1. Initialize Document object.
1. Save output PDF document by calling Document.save() method.
1. Create an instance of the HtmlLoadOptions object.
2. Initialize Document object.
3. Save output PDF document by calling Document.save() method.

```python
import aspose.pdf as ap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def get_root_structure(outfile):
tagged_content.set_language("en-US")

# Properties StructTreeRootElement and RootElement are used for access to
# StructTreeRoot object of pdf document and to root structure element (Document structure element).
# StructTreeRoot object of PDF document and to root structure element (Document structure element).
struct_tree_root_element = tagged_content.struct_tree_root_element
root_element = tagged_content.root_element

Expand Down
2 changes: 1 addition & 1 deletion examples/convert_pdf_document/example_html_to_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def convert_WebPage_to_PDF(infile, outfile):
convert_WebPage_to_PDF("https://docs.aspose.com/pdf/python-net/", "sample_page.pdf")

Note:
This feature is not implemented yet. Requires requests library and temp file handling.
This feature is not implemented yet. It requires requests library and temp file handling.
"""
raise NotImplementedError("Web page to PDF conversion is not implemented yet")

Expand Down
1 change: 0 additions & 1 deletion examples/parsing/example_parsing_acroforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def extract_form_fields_JSON(infile, outfile):
with io.FileIO(outfile, "w") as json_file:
form.export_json(json_file, True)


def extract_form_fields_json_doc(infile, outfile):
form = ap.facades.Form(infile)
form_data = {}
Expand Down
45 changes: 45 additions & 0 deletions examples/parsing/example_parsing_xfa.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import sys
from os import path

import aspose.pdf as ap

sys.path.append(path.join(path.dirname(__file__), ".."))

from config import initialize_data_dir, set_license


def extract_xfa_form_fields(infile):

document = ap.Document(infile)
# Get names of XFA form fields
names = document.form.xfa.field_names

# Get field position
if len(names) > 0:
name0=names[0]
t = document.form.xfa.get_field_template(name0)
print(t.attributes["x"].value)
print(t.attributes["y"].value)


def run_all_examples(data_dir=None, license_path=None):
set_license(license_path)
input_dir, output_dir = initialize_data_dir(data_dir)

examples = [
("Extract XFA form fields", extract_xfa_form_fields, "sample-xfa.pdf", None),
]

for name, func, input_file, output_file in examples:
try:
args = [path.join(input_dir, input_file)]
if output_file:
args.append(path.join(output_dir, output_file))
func(*args)
print(f"✅ Success: {name}")
except Exception as e:
print(f"❌ Failed: {name} - {e}")


if __name__ == "__main__":
run_all_examples()
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@

def _validate_pdfa_standard(input_pdf, output_pdf, pdf_format):
document = ap.Document(input_pdf)
document.validate(output_pdf, pdf_format)
if (document.validate(output_pdf, pdf_format)):
print("PDF is valid")
else:
print("PDF is not valid")


def validate_pdfa_standard_a1a(input_pdf, output_pdf):
Expand Down Expand Up @@ -164,9 +167,7 @@ def set_pdf_expiry_date(input_pdf, output_pdf):

def flatten_fillable_pdf(input_pdf, output_pdf):
document = ap.Document(input_pdf)
if document.form and document.form.fields:
for field in document.form.fields:
field.flatten()
document.flatten()
document.save(output_pdf)


Expand Down
1 change: 1 addition & 0 deletions examples/working_with_text/example_text_adding.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ def add_text_with_rtl_text(output_file_name):
text_fragment.horizontal_alignment = ap.HorizontalAlignment.RIGHT

page.paragraphs.add(text_fragment)
document.direction = ap.Direction.R2L
document.save(output_file_name)


Expand Down
Binary file added sample_data/parsing/input/sample-xfa.pdf
Binary file not shown.