View Issue Details

IDProjectCategoryView StatusLast Update
0015017ScribusScripterpublic2017-12-20 20:58
Reporterwilliam Assigned Togpittman  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version1.5.4.svn 
Fixed in Version1.5.4.svn 
Summary0015017: Use the FontEmbedding setting from the document in the scripter PDFfile
DescriptionJuraj Fedel contributed this patch to implement a feature recently requested on the Scribus mailing list.
The scripter PDFfile class currently initializes the fontEmbedding property to 0 to embed fonts.
With this patch, fontEmbedding is initialized to the setting from the document.
Steps To ReproduceMake a script to write a document using PDFfile (or use the example uploaded to this patch).
Create and save a document with a few lines of text (or use the example uploaded to this patch).
Run the script, for example, with scribus -g -py export_to_pdf.py -file 'test.pdf' -- testdoc.sla
Use a tool like poppler pdffonts or gs ps2ascii to check that the fonts are embedded.
Open the document, change the font embedding, for example, File -> Export -> Save as PDF -> [Fonts] tab -> change Embedding Mode from "Embed or Subset" to "Outline All Fonts" -> [Save], and then save the document.
Run the script.
Check that the fonts are vectorized. poppler pdffonts should not report any fonts, and gs ps2ascii should not find any text.
TagsNo tags attached.
PatchYes

Activities

william

2017-10-12 11:41

updater  

0001-Use-FontEmbeding-setting-from-document.patch (923 bytes)   
From 486e69a2705beea6518c76868b12987003ab8b17 Mon Sep 17 00:00:00 2001
From: Juraj Fedel <wtxnh-scribus@yahoo.com.au>
Date: Thu, 12 Oct 2017 11:22:33 +0200
Subject: [PATCH] Use FontEmbeding setting from document

---
 scribus/plugins/scriptplugin/objpdffile.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scribus/plugins/scriptplugin/objpdffile.cpp b/scribus/plugins/scriptplugin/objpdffile.cpp
index 835b077ea..3552ed225 100644
--- a/scribus/plugins/scriptplugin/objpdffile.cpp
+++ b/scribus/plugins/scriptplugin/objpdffile.cpp
@@ -349,7 +349,7 @@ static int PDFfile_init(PDFfile *self, PyObject * /*args*/, PyObject * /*kwds*/)
 	}
 // font embedding mode
 	PyObject *embeddingMode = NULL;
-	embeddingMode = PyInt_FromLong(0);
+	embeddingMode = PyInt_FromLong(pdfOptions.FontEmbedding);
 	if (embeddingMode){
 		Py_DECREF(self->fontEmbedding);
 		self->fontEmbedding = embeddingMode;
-- 
2.14.2

export_to_pdf.py (1,705 bytes)   
#!/usr/bin/env python
# -*- coding: utf-8 -*-

""" 
Convert a document to a PDF

Run with a command like
        scribus -g -py export_to_pdf.py -version 13 -useDocBleeds 0 -bleedr 2 -compress 1 -info 'test title' -file 'test.pdf' -pages '[1, 2]' -- testdoc.sla

You can set any "pdf" attribute with "-attribute value".

Tested with scribus 1.5.2.svn r21147

Author: William Bader, Director of Research and Development, SCS, http://www.newspapersystems.com
15Sep15 wb		initial version
31Mar16 Jural Fedel	simplified, added support for page ranges

"""

import scribus
import sys
import ast

def main(argv):
        pdf = scribus.PDFfile()
        i = 1
        while i < len(argv):
                if (argv[i][0] != '-'):
                        raise Exception("PDF option expected instead of: '{0}'".format(argv[i]))
                name = argv[i][1:]
                pdf_attr = getattr(pdf, name)
                i = i + 1
                try:
                        value = argv[i]
                except:
                        msg = "Option '{0}' require value".format(name)
                        raise Exception(msg)
                if isinstance(pdf_attr, basestring):
                        setattr(pdf, name, value)
                else:
                        val = None
                        try:
                                val = ast.literal_eval(value)
                        except:
                                msg = "'{0}' =/= '{1}'".format(name, value)
                                raise ValueError(msg)
                        setattr(pdf, name, val)
                i = i + 1
        pdf.save()

# start the script
if __name__ == '__main__':
        main(sys.argv)

export_to_pdf.py (1,705 bytes)   
testdoc.sla (14,064 bytes)

gpittman

2017-10-12 14:32

developer   ~0044532

I went ahead and applied the patch changes to 1.5.4svn. (revision 22192)
I did not test the patch...

Issue History

Date Modified Username Field Change
2017-10-12 11:41 william New Issue
2017-10-12 11:41 william File Added: 0001-Use-FontEmbeding-setting-from-document.patch
2017-10-12 11:41 william File Added: export_to_pdf.py
2017-10-12 11:41 william File Added: testdoc.sla
2017-10-12 14:32 gpittman Note Added: 0044532
2017-10-12 14:58 jghali Summary [patch] Use the FontEmbedding setting from the document in the scripter PDFfile => Use the FontEmbedding setting from the document in the scripter PDFfile
2017-10-12 14:58 jghali Assigned To => gpittman
2017-10-12 14:58 jghali Status new => resolved
2017-10-12 14:58 jghali Resolution open => fixed
2017-10-12 14:58 jghali Fixed in Version => 1.5.4.svn
2017-12-20 20:58 cbradney Status resolved => closed