Comments (5)
Hi @larseberhardt I released a new version 0.13.0 to improve PDFSaveOptions
and have an example , Cheers.
from photoshop-python-api.
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.
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.
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)
from photoshop-python-api.
@loonghao thx you! It worked like a charm. So handy!
from photoshop-python-api.
Related Issues (20)
- how I close the ps.exe safely, ps.Application() seems no such function like "close() / quit()" HOT 2
- 多次替换psd中同一个图片,并在每次替换后将替换后的psd保存为png。在这个过程的第二次开始,它会将上一次保存的png替换到想要替换的图层上,描述可能有点不清晰,代码如下 HOT 1
- selection.select()如何设置只选中文字 HOT 1
- How to rollback operations? HOT 1
- How to revert changes? HOT 1
- Change the ps version
- Any example for read TIF file
- 如何使用这个api调整笔刷旋转角度 HOT 1
- How to Replace Smart Layer Text with a Script
- How to hide the Photoshop window
- How to adjust HDR Toning
- Photoshop API with python multithreading HOT 2
- How to import data group txt file and export data group as file
- 无法在mac 电脑上使用 建议兼容一下 HOT 2
- `slelect` method is missing in Code Reference HOT 1
- About the bottomed API reference HOT 1
- Replacing multiple layers with images does not work; it only replaces the same layer multiple times
- PSB Save options available?
- How to get the rotation angle of a layer
- Can I give an example of applying gradients to a text layer style HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from photoshop-python-api.