Setting text attributes for server request - setTextAlign no

Discuss capabilities and share productivity tips about the server version of QuarkXPress.

Setting text attributes for server request - setTextAlign no

Postby kamikaze63 » 24 Jan 2011, 03:54

I am having a small issue with QXPS 7.2. I am sending a reuqest to the server to render a JPEG request, which I can do wiht no problem. However, when i send the following within my request:
text.setTextAlign("CENTER");
The text in question does not get centered.
Here is more of the relevant code - any help would be greatly appreciated. Thanks!

[b]String bodyForQuark = "QuarkXpress Server: This is a test.";

RichText richText = new RichText();
Story story = new Story();
Text text = new Text();
Box box = new Box();
Spread spread = new Spread();
Layout layout = new Layout();
Project project = new Project();

richText.setValue(bodyForQuark);

// formatting
richText.setAllCaps("true");
richText.setBold("true");
richText.setColor("Cyan");
richText.setFont("Georgia");
richText.setSize("5");

story.setClearOldText("true");
box.setUID("5");
layout.setUID("1");
spread.setUID("1");

story.setRichText(new RichText[] { richText });

text.setVerticalAlignment("CENTERED");
text.setTextAlign("CENTER");
text.setStory(story);
box.setText(text);
spread.setBoxes(new Box[] {box});
layout.setSpreads(new Spread[] {spread});
project.setLayouts(new Layout[] {layout});

modifierRequest.setProject(project);

JPEGRenderRequest jpegRequest = new JPEGRenderRequest();
jpegRequest.setBox("5");
jpegRequest.setScale("3.0");
jpegRequest.setJPEGQuality("1");
modifierRequest.setRequest(jpegRequest);

QRequestContext context = new QRequestContext();
context.setDocumentName(testPath);
context.setResponseAsURL(true);
context.setRequest(modifierRequest);

QContentData qContentData;

qContentData = qManagerSDKSvc.processRequest(context);
kamikaze63
 
Posts: 6
Joined: 25 Oct 2010, 09:10

Setting text attributes for server request - setTextAlign no

Postby AndyDyer » 24 Jan 2011, 07:37

Hi Kamikaze63,
The reason this isn't doing what you're expecting is that the .setTextAlign() method of the Text object sets not the paragraph alignment (i.e. left / right / centered / justified / force justified) but rather sets the same setting as the the Style->Character Alignment menu option in QuarkXPress, which defines the part of the glyph to be use for text alignment with the baseline. The paragraph alignment, which will allow you to center text, is set as a method of the "Format" object type which can be specified for each Paragraph object; here's an updated version of your example showing this:
public class Test {
public static void main(String[] args) throws MalformedURLException, ServiceException, RemoteException {
QManagerSDKSvcServiceLocator svcloc = new QManagerSDKSvcServiceLocator();
QManagerSDKSvc svc = svcloc.getqxpsmsdk(new URL("http://localhost:8090/quark/services/qxpsmsdk?wsdl"));
String bodyForQuark = "QuarkXPress Server: This is a test.";
String testPath = "helloworld7.qxp";
RichText richText = new RichText();
Story story = new Story();
Text text = new Text();
Box box = new Box();
Spread spread = new Spread();
Layout layout = new Layout();
Project project = new Project();
richText.setValue(bodyForQuark);
// formatting
richText.setAllCaps("true");
richText.setBold("true");
richText.setColor("Cyan");
richText.setFont("Georgia");
richText.setSize("5");

story.setClearOldText("true");
//box.setUID("5");
box.setName("textbox");
layout.setUID("1");
spread.setUID("1");

[b]Paragraph para = new Paragraph();
Format format = new Format();
format.setAlignment("CENTERED");
para.setFormat(format);
para.setRichText(new RichText[] {richText});
story.setParagraphs(new Paragraph[] {para});
//story.setRichText(new RichText[] { richText });
//text.setTextAlign("CENTER");
text.setVerticalAlignment("CENTERED");

text.setStory(story);
box.setText(text);
spread.setBoxes(new Box[] {box});
layout.setSpreads(new Spread[] {spread});
project.setLayouts(new Layout[] {layout});
ModifierRequest modifierRequest = new ModifierRequest();
modifierRequest.setProject(project);

JPEGRenderRequest jpegRequest = new JPEGRenderRequest();
//jpegRequest.setBox("5");
jpegRequest.setBox("textbox");
jpegRequest.setScale("3.0");
jpegRequest.setJPEGQuality("1");
modifierRequest.setRequest(jpegRequest);

QRequestContext context = new QRequestContext();
context.setDocumentName(testPath);
context.setResponseAsURL(true);
context.setRequest(modifierRequest);

QContentData qContentData = svc.processRequest(context);
System.out.println(qContentData.getResponseURL());
}
}
(note, I also changed the box UIDs and template name, but that was just to get it to work with a template on my machine).
I hope that this helps,
Regards,
Andy.
AndyDyer
 
Posts: 13
Joined: 18 Mar 2008, 09:13

Setting text attributes for server request - setTextAlign no

Postby AndyDyer » 24 Jan 2011, 07:42

BTW, I noticed that any instances of open / close square brackets (i.e. an array specifier) are missing the closing bracket when displayed on my browser after being posted, so if you're copying the above code, you may need to manually add the closing square bracket once you get the code into your IDE. Apologies, this just seems to be a formatting peculiarity of the forum software.
AndyDyer
 
Posts: 13
Joined: 18 Mar 2008, 09:13

Setting text attributes for server request - setTextAlign no

Postby kamikaze63 » 24 Jan 2011, 08:02

Wow... i was a little dense there. Thanks again for the fix - works perfectly.
kamikaze63
 
Posts: 6
Joined: 25 Oct 2010, 09:10


Return to QuarkXPress Server

Who is online

Users browsing this forum: No registered users and 1 guest

cron