The API returns PDF reports and map screenshots as Base64-encoded text. This is a common method for transferring binary files (such as images or PDFs) via a text-based interface. It is necessary to decode and save the file.
Save PDF Report
The following example generates a complete load zone report as a PDF and saves it locally:
import base64
from dlubal.api.geo_zone_tool import GeoZoneTool, Language
gzt = GeoZoneTool(token="")
pdf_result = gzt.get_load_zone_pdf_result(
address="Munich, Germany",
standard="EN 1991-1-3",
annex="DIN EN 1991-1-3",
layer_id=1,
language=Language.EN,
)
if pdf_result:
with open(pdf_result.name, "wb") as f:
f.write(base64.b64decode(pdf_result.pdf))
print(f"Saved: {pdf_result.name}")
PDF Generation with Progress Indicator
As an alternative, you can track the progress of server-side PDF generation in real time. This is especially useful if you integrate the generation process into your own application with a user interface:
for progress in gzt.get_load_zone_pdf(
address="Munich, Germany",
standard="EN 1991-1-3",
annex="DIN EN 1991-1-3",
layer_id=1,
language=Language.EN,
):
print(f"{progress.current_step}/{progress.steps} – {progress.message}")
if progress.pdf_result:
with open(progress.pdf_result.name, "wb") as f:
f.write(base64.b64decode(progress.pdf_result.pdf))
The function uses a WebSocket connection (GraphQL subscription) in the background and provides status updates step by step until the finished PDF is included as a Base64-encoded string in the final step. The suggested file name is provided by the server.
Save Map Screenshot
The API can generate a section of the load zone map as a raster image. The result matches the display in the web interface and is suitable for integration into reports or your own applications. The output can be controlled using the zoom, screenshot_type (PNG or JPEG), and screenshot_quality parameters.
import base64
from dlubal.api import geo_zone_tool
from dlubal.api.geo_zone_tool import GeoZoneTool, Language
gzt = GeoZoneTool(token="")
screenshot = gzt.get_load_zone_screenshot(
address="Munich, Germany",
load_zone_type=geo_zone_tool.LoadZoneType.SNOW,
standard="EN 1991-1-3",
annex="DIN EN 1991-1-3",
layer_id=1,
zoom=6,
language=Language.DE,
screenshot_type=geo_zone_tool.ScreenshotType.PNG,
)
with open("snow_load_zone_munich.png", "wb") as f:
f.write(base64.b64decode(screenshot.screenshot))
print("Saved: snow_load_zone_munich.png")
The zoom parameter controls the magnification level of the map section. Low values (for example, 4) provide an overview of the country, while higher values (for example, 10) show a detailed view of the area around the location. For JPEG images, the image quality can also be set using screenshot_quality (1–100).
What is Base64?
Base64 converts binary data (such as a PDF or an image) into a plain text string that can be easily transmitted via a text-based interface like JSON. The recipient decodes the string back into the original file. In Python, the standard library handles this with two lines:
import base64
file_bytes = base64.b64decode(base64_string)
The generated files correspond to the exports from the web interface and can be incorporated directly into your project documentation.