Rookie electronic surface list, custom area settings Method __ Rookie electronic face sheet

Source: Internet
Author: User
Tags stringbuffer

Rookie electronic screen printing components, custom print area display content

Customers generally require custom print area inside, display order information.

But the official document rookie the data settings introduced in the Print interaction protocol Goodsinfo This method, which is impossible to use after experimentation.


It was later found that Templateurl could be defined by itself. Then set a URL for yourself, and define a good print content for the commodity display.

Note, however, that this URL must be application/json to satisfy the answer header, otherwise the error


Typesetting problems, such as the long width and height of the setting value, I usually first to the rookie print components under the designer to typesetting.

Then get the URL of the custom template by getting the interface of the user's print template, access the connection

http://cloudprint.cainiao.com/template/customArea/721839 gets the property value inside the layout

The content format is a rookie-required format, as follows:

<?xml version= ' 1.0 ' encoding= ' UTF-8 '?>

<layout id= ' custom_area ' xmlns= ' http://cloudprint.cainiao.com/print ' xmlns:xsi= ' Xmlschema-instance ' xsi:schemalocation= ' http://cloudprint.cainiao.com/printhttp:// Cloudprint-docs-resource.oss-cn-shanghai.aliyuncs.com/lpml_schema.xsd ' xmlns:editor= ' http:// Cloudprint.cainiao.com/schema/editor ' top= ' 140 ' width= ' height= ' style= ' zindex:1; Overflow:hidden; ' >

<layout id= ' element_layout_9f7484a0d698a082 ' left= ' 5 ' top= ' 5 ' width= ' ' height= ' 6 ' editor:_for_= ' element_text_B9 D9f95086f51fee ' style= ' zindex:3;overflow:visible; ' >

<text value= ' 11112 Test Specification: Specification 222 Quantity: 1 ' style= ' wrap:true;direction:horizontal;letterspacing:0;fontsize:9;lineheight : 5;fontitalic:false;fontfamily: Song body; Fontunderline:false;valign:top;align:left;fontweight:false '/>

</layout>

</layout>

The Java code is as follows:

@RequestMapping (Value = "/alipay/taobao/myprinttemplate/{orderid}", method= Requestmethod. Get)

publicvoid myprinttemplate (

@PathVariable (value= "OrderId") Integer OrderId,

HttpServletResponse response) {

Response.setcharacterencoding ("Utf-8");

Response.setcontenttype ("Application/json");

list<goodsorderdetail> dbdetaillist = Goodsorderdetailmapper.selectgoodsorderdetailbyorderid ( ORDERID);

StringBuilder SB = new StringBuilder ();

for (goodsorderdetail detail : dbdetaillist) {

Sb.append (Detail.getgoodsname ());

Sb.append ("specification:");

Sb.append (Detail.getspecification ());

Sb.append ("Quantity:");

Sb.append (Detail.getgoodsnum ());

}

stringbuffer result = new stringbuffer ("<?xmlversion= ' 1.0 ' encoding= ' UTF-8 '?> ')";

Result.append ("<layout id= ' Custom_area ' xmlns= ' http://cloudprint.cainiao.com/print '");

Result.append ("xmlns:xsi= ' http://www.w3.org/2001/XMLSchema-instance '");

Result.append ("Xsi:schemalocation= ' http://cloudprint.cainiao.com/printhttp:// Cloudprint-docs-resource.oss-cn-shanghai.aliyuncs.com/lpml_schema.xsd ' ");

Result.append ("xmlns:editor= ' http://cloudprint.cainiao.com/schema/editor ' top= ' 140");

Result.append ("width= ' height= ') ' style= ' Zindex:1;overflow:hidden; > ");

Result.append ("<layoutid= ' element_layout_9f7484a0d698a082 ' left= ' 5 ' top= ' 5 ' width= ' 26 '");

Result.append ("height= ' 6 ' editor:_for_= ' Element_text_b9d9f95086f51fee ')";

Result.append ("style= ' zindex:3;overflow:visible;") > ");

Result.append ("<text value= '");

Result.append (Sb.tostring ());

Result.append ("' Style= ' Wrap:true;direction:horizontal;letterspacing:0;fontsize:9;lineheight:5;fontitalic:false FontFamily: Song body; Fontunderline:false;valign:top;align:left;fontweight:false '/> ');

Result.append ("</layout>");

Result.append ("</layout>");

Try {

Response.getwriter (). Write (result.tostring ());

catch (Exception e) {

E.printstacktrace ();

}

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.