Code Monkey home page Code Monkey logo

Comments (5)

loonghao avatar loonghao commented on June 3, 2024 1

Hi @larseberhardt I released a new version 0.13.0 to improve PDFSaveOptions and have an example , Cheers.

from photoshop-python-api.

loonghao avatar loonghao commented on June 3, 2024

Hi @larseberhardt You just need instance the PDFSaveOptions as an object and to set options. let me know if that can help you, cheers.

for example:

option = ps.PDFSaveOptions()
option.alphaChannels
option.jpegQuality
option.alphaChannels

a real example:

import os
from tempfile import mkdtemp

from photoshop import Session

with Session() as ps:
    option = ps.PDFSaveOptions()
    option.jpegQuality = 1
    pdf = os.path.join(mkdtemp(), "test.pdf")
    ps.active_document.saveAs(pdf, option)
    os.startfile(pdf)

from photoshop-python-api.

larseberhardt avatar larseberhardt commented on June 3, 2024

Hi @loonghao thank you for your fast reply.

I already tried your suggestions few times but nothing happen if you set any options. I think the issue is that nothing is coded for PDFSaveOptions.
https://github.com/loonghao/photoshop-python-api/blob/master/src/photoshop/api/save_options/pdf.py

I tried it with the win32com.client and it runs as expected.

from win32com.client import Dispatch, GetActiveObject, GetObject
app = Dispatch('Photoshop.Application')
app = GetActiveObject("Photoshop.Application")
filepath = example.jpg
docRef = app.Open(filepath)
options = Dispatch('Photoshop.PDFSaveOptions')
options.PresetFile = "Example_Preset_File" 
app.ActiveDocument.SaveAs(pdf_file, options, AsCopy=False)
app.ActiveDocument.Close(Saving=2)

from photoshop-python-api.

loonghao avatar loonghao commented on June 3, 2024

Hi @larseberhardt Since the code of this API is dynamically converted using comtypes,
This will not affect the use of the code, they are just that there is no automatic code completion function in the script editor, I will update it in a future version.

you just need to have an active document in photoshop and run the below code.

import os
from tempfile import mkdtemp

from photoshop import Session

with Session() as ps:
    option = ps.PDFSaveOptions()
    option.jpegQuality = 1
    option.PresetFile = "Example_Preset_File"
    pdf = os.path.join(mkdtemp(), "test.pdf")
    ps.active_document.saveAs(pdf, option)
    os.startfile(pdf)

demo

from photoshop-python-api.

larseberhardt avatar larseberhardt commented on June 3, 2024

@loonghao thx you! It worked like a charm. So handy!

from photoshop-python-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.