Coder Social home page Coder Social logo

Comments (6)

berteh avatar berteh commented on August 15, 2024

If I understand correctly you want to specify the current page orientation, right?

Never tried it yet but it should be feasible.

First you gotta identify the attribute(s) and value(s) that change in the SLA when switching layout. For this I'd recommend saving one empty SLA file with portrait layout, then switching its layout, saving under another name and using any open source 'text diff' tool to identify the differences between the 2 files. I guess at least the page width and height will have changed, and maybe some other attribute as well.

Second you should create data columns for these values and attributes in you data set, eg one column 'page-height', 'page-width', and any other required (text or number) value/attribute.

Lastly create one SG dynamic attribute in your SG template (see readme 'advanced' section or video tutorial) for each of these changing values.

Finding out the exact syntax for the XPATH selector of the dynamic attribute can be a bit tricky but it 'simply' boils down to the list of parents elements in the XML tree of the SLA file. One way to see this tree more explicitly is to rename one of your empty layout test SLA file with an '.xml' extension and open it in a web browser (Firefox, chrome,...): they usually show xml files as collapsible trees. Look for a quick introduction to the XPATH selector syntax may help (you may have seen something close in advanced CSS syntax, that is based on XPATH).

Good luck. Kindly let me know how this works for you. If it's too technical let me know or ask again here, and I (or someone else) might be able to help.

Greetings.
B.

from scribusgenerator.

ignutanz avatar ignutanz commented on August 15, 2024

I created one landscape file and a copy of it changing orientation to portrait. I find the following changes using diffchecker showing changes in portrait as compared to the landscape file:

  • PAGEWIDTH,PAGEHEIGHT properties are exchanged inside <DOCUMENT
  • ORIENTATION="1" changed to ORIENTATION="0" inside <DOCUMENT
  • Size="" changed to Size="Custom" Inside the <PAGE
  • All ItemID properties inside each <PAGEOBJECT changed to new value

How should i create the SGAttributes. I need to give the orientation through csv file. but what about other parameters which change when the orientation changes. should i specify the pagewidth and pageheight through csv.

from scribusgenerator.

ignutanz avatar ignutanz commented on August 15, 2024

I added an SGAttribute named ORIENTATION with value %VAR_orientation% and provided a column inside the csv input with values as 0 and 1 on alternative rows. But I find that all the generated sla files are still in the landscape orientation.

from scribusgenerator.

ignutanz avatar ignutanz commented on August 15, 2024

i find that the orientation and pagewidth,pageheight changes in the attributes of the resulting file while passing it through the csv input file, but visually there is no difference!!

from scribusgenerator.

DavidPesticcio avatar DavidPesticcio commented on August 15, 2024

Just a thought - but I suspect the values that changed are needed together to inform other things - the dimensions of a page are essentially irrelevant without an orientation, certainly to a printer etc.

I.e. the shape is not an indication of it's orientation, except by convention or prior knowledge.

A bit like the marker on a map to inform you of which direction is North, the map itself tells you nothing unless you know already this - hence the symbol for North. 😃

from scribusgenerator.

berteh avatar berteh commented on August 15, 2024

Hello.
I tried really hard to implement this, but to no avail. Sorry.

I did find a way to tailor objects width and position per the size of their parent page, but you still need to click on each page and change it's orientation manually. It goes fast but is still manual.

If interested attached is a sample template and Spreadsheet used to compute the relate page dimension, positions and objects locations. test is using the dimensions of "Letter" format, but easily adapted to others.

orientation-calculator.ods
orientation-test.sla.txt
orientation-test.csv

objects are already in place or stretched per page orientation, but page "background" still needs to be manually rotated before getting the expected result:
image

If you're interested in the technical specifics of the obstactle (and for my own note): I find no way to store the (new/oriented) page size information on the Scribus (XML) <PAGE> element... as this one does not support the "Attribute" mechanism available only on <PAGEOBJECT>. And since Scribus does not store the <PAGEOBJECT> as a child of its parent <PAGE> but at a random place in the SLA files (likely by order of creation?) I cannot easily find the parent page of an SGAttribute to orient the said page accordingly. To make things even worse the XPath engine of eTree does not support advanced queries, making other type of relations (eg current-position()-1) unusable, that would have been a possible workaround for "simple" templates containing a single page to be oriented/resized: https://docs.python.org/3/library/xml.etree.elementtree.html#supported-xpath-syntax

from scribusgenerator.

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.