Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Fri Jan 17, 2025 8:05 am

Code: Select all
@login_required(login_url='login')
def export_layout_image(request, output=None):
    part_name = request.session['part_name']
    file_name = part_name + '_Layout.pdf'

    fault = error_check(request, 'Layout', 'Download')
    if fault is None:
        graph = layout_txt(request, 'str')
        body = {
            "graph": graph,
            "layout": "dot",
            "format": "svg"
        }

        r = requests.post('https://quickchart.io/graphviz', json=body)

        # r.text is sufficient for SVG. Use `r.raw` for png images
        svg = r.text
        # writes returned object to svg file
        with tempfile.NamedTemporaryFile(delete=False, suffix='.svg') as f:
            with open(f.name, 'w') as file:
                file.write(svg)

        # loads above svg file to pdf
        with tempfile.NamedTemporaryFile(delete=False, suffix='.pdf') as pdf:
            # close temp file so spire can overwrite it
            pdf.close()
            # Create a PdfDocument object
            doc = PdfDocument()
            # Load an SVG file
            doc.LoadFromSvg(file.name)
            # Save the SVG file to PDF format
            doc.SaveToFile(pdf.name, FileFormat.PDF)
            # Close the PdfDocument object
            doc.Close()

            if output is None:
                return FileResponse(open(pdf.name, 'rb'), as_attachment=True, filename=file_name)
            if output == 'zip':
                return pdf, file_name
    else:
        return fault

im new to spire.pdf and programming
function currently works but i want to be able to add boarder and table at bottom right with other details and make page size A3
svg is dymaically created so size is always changing so needs to resize to fit on page i just cant get it to work

tylerbrannigan
 
Posts: 8
Joined: Wed Nov 20, 2024 1:14 pm

Fri Jan 17, 2025 8:18 am

Hello,

Thank you for your letter. In order for us to investigate more accurately, could you provide your SVG document, the current result PDF and screenshots of your desired effect? You can send them here or via email ([email protected]).Thank you in advance.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1371
Joined: Wed Apr 25, 2018 3:20 am

Fri Jan 17, 2025 11:10 am

Lisa.Li wrote:Hello,

Thank you for your letter. In order for us to investigate more accurately, could you provide your SVG document, the current result PDF and screenshots of your desired effect? You can send them here or via email ([email protected]).Thank you in advance.

Sincerely,
Lisa
E-iceblue support team

Hi Lisa thankyou please find attached

tylerbrannigan
 
Posts: 8
Joined: Wed Nov 20, 2024 1:14 pm

Mon Jan 20, 2025 9:48 am

Hello,

Thank you for providing more information. I will further investigate and provide an sample for you.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1371
Joined: Wed Apr 25, 2018 3:20 am

Tue Jan 21, 2025 2:41 am

Hello,

Thank you for your patience. Here, I have uploaded the sample code of drawing SVG on an A3 page in PDF format and adding border effects. You can refer to it. Our Dev team are currently increasing the logic of drawing tables. Once its' version is available, I will let you know immediately.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1371
Joined: Wed Apr 25, 2018 3:20 am

Fri Jan 24, 2025 4:21 am

thankyou for the reply works perfectly thankyou please keep me update when the table function works :) really appreciate the help

tylerbrannigan
 
Posts: 8
Joined: Wed Nov 20, 2024 1:14 pm

Fri Jan 24, 2025 5:43 am

Hello,

Sure, I have recorded the table functionality with SPIREPDF-7343. Once its' corresponding version is released, we will inform you as soon as possible. Thank you for your patience.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1371
Joined: Wed Apr 25, 2018 3:20 am

Fri Jan 24, 2025 7:40 am

hi Lisa Im running the most current version and when i run on my digital ocean app platform returns error RuntimeError: ffi_prep_cif_var failed

tylerbrannigan
 
Posts: 8
Joined: Wed Nov 20, 2024 1:14 pm

Fri Jan 24, 2025 8:22 am

Hello,

Thank you for your feedback. Are you currently using the latest version (Spire. PDF for Python Version: 10.12.1)? We know that older versions have this error when using Ubuntu 22. However, the latest version already includes a fix for this issue. If you are using V10.12.1, for our further investigation, please provide your system information for reference.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1371
Joined: Wed Apr 25, 2018 3:20 am

Thu Jan 30, 2025 1:04 am

hi Lisa my system requirements running spire 10.12.1 runs correctly on my windows development enviroment but my deployment enviroment is a digital ocean app platform i believe built using heruku see requirement.txt below and build packs in photo attached
asgiref==3.8.1
autopep8==1.5.7
dj-database-url==0.5.0
Django==5.1
gunicorn==22.0.0
pycodestyle==2.7.0
python-decouple==3.4
pytz==2021.1
sqlparse==0.5.0
toml==0.10.2
Unipath==1.1
whitenoise==5.3.0
django-polymorphic==3.1.0
XlsxWriter==3.2.0
inventree==0.17.3
psycopg2==2.9.9
openpyxl==3.1.5
django-import-export==4.1.1
djangorestframework~=3.15.2
pandas==2.2.3
requests==2.32.3
django-storages==1.14.4
spire.pdf==10.12.1
boto3==1.35.92
django-dbbackup==4.2.1
numpy==2.2.1

tylerbrannigan
 
Posts: 8
Joined: Wed Nov 20, 2024 1:14 pm

Thu Jan 30, 2025 4:16 am

Hello,

Thanks for your feedback. Based on this information, I have found that you are using Python 3.4. Please use a higher version(Python 3.7 or above) to try again. Look forward to your further feedback.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1371
Joined: Wed Apr 25, 2018 3:20 am

Thu Jan 30, 2025 5:58 am

thanks for the reply my deployment enviroment is python latest v4.253.4 and doesnt work but i did notice in my development enviroment where it works im using python 3.13

tylerbrannigan
 
Posts: 8
Joined: Wed Nov 20, 2024 1:14 pm

Thu Jan 30, 2025 10:34 am

Hello,

Thank you for your feedback. According to the official Python website, the latest version is 3.14. I am not sure which version v4.253.4 corresponds to, but our product's underlying compilation environment is based on Python 3.7, so this version or higher is required for use.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1371
Joined: Wed Apr 25, 2018 3:20 am

Thu Jan 30, 2025 1:35 pm

hi Lisa sorry im still learning about all this and got confused with the versioning. so i ran python --version on my deployment console it says im running 3.12.4 is this current enough? and could this be causing the issue?

tylerbrannigan
 
Posts: 8
Joined: Wed Nov 20, 2024 1:14 pm

Fri Jan 31, 2025 1:52 am

Hello,

Thanks for your feedback.
For your scenario, I suggest that you use the current version of Python to conduct thorough testing. If there are still issues, please reply and let us know so that we can provide further assistance.

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 512
Joined: Mon Dec 27, 2021 2:23 am

Return to Spire.PDF