Preserved API Code Falling Outside Margin

This forum is for all Flare issues related to PDF, eBook, Microsoft Word, Adobe FrameMaker, XPS, and XHTML book targets.
Post Reply
Titus
Propeller Head
Posts: 38
Joined: Thu Dec 04, 2014 2:33 pm

Preserved API Code Falling Outside Margin

Post by Titus »

Hello!

I'm currently using the latest version of Flare v10 but I'm having an issue with some API code I would like to appear in both PDF and HTML5.

I paste the code in using the method described here: http://forums.madcapsoftware.com/viewto ... 10&t=20171

This would work fine for HTML5, but in Print, the code falls outside the margin. I.e., no word-wrap is being applied.

I've tried setting maximum width, I've tried setting margin-right, and I've even tried placing the <pre> element inside a table, but all to no avail. Am I missing something? I would like all the code to appear, with the spacing preserved, so that users can copy and paste from the PDF.

Thanks for your help! It is much appreciated! :D

The following is a sample of the code:

Code: Select all

/*log in request*/
{
	"method": "exec",
	"params": [
		{
			"url": "/sys/login/user",
			"data": [
				{
					"user": "admin",
					"passwd": "123456"
				}
			]
		}
	],
	"id": 1,
	"ver": "2.0"
},

/* log in response. */
{
	"id": 1,
	"ver": "2.0",
	"result": {
		"url": "/sys/login/user",
		"status": {
			"code": 0,
			"message": "OK"						/*"OK", or "WRONG_CREDENTIAL", "TIME_OUT", "TOO_MANY_FAILED_RETRY" , "WRONG_DATA" */
		},
	},
	"session":"gzKj2PsMZ+4Hhs8Q9Ra+br+YStvpqWz\/8e291G1j1GI="
}
NorthEast
Master Propellus Maximus
Posts: 6426
Joined: Mon Mar 05, 2007 8:33 am

Re: Preserved API Code Falling Outside Margin

Post by NorthEast »

To make it wrap, use the following in the pre style:

Code: Select all

pre
{
	white-space: pre-wrap;
	word-wrap: break-word;
}
However, if you copy/paste that from a PDF, it'll include the carriage return - but copy/paste from HTML5 help is ok though.
Titus
Propeller Head
Posts: 38
Joined: Thu Dec 04, 2014 2:33 pm

Re: Preserved API Code Falling Outside Margin

Post by Titus »

Hi Dave, thanks for the reply!

Unfortunately, that didn't cause anything to wrap. Long lines of API code are still falling outside the margin and don't appear in the PDF.

Here is the .css I used (funny that word-wrap doesn't appear to be an option for <pre> in the Stylesheet Editor):

Code: Select all

	pre
	{
		margin-left: 0.3in;
		font-family: 'Courier New';
		font-size: 9.5pt;
		white-space: pre-wrap;
		word-wrap: break-word;
	}
Titus
Propeller Head
Posts: 38
Joined: Thu Dec 04, 2014 2:33 pm

Re: Preserved API Code Falling Outside Margin

Post by Titus »

Bump
NorthEast
Master Propellus Maximus
Posts: 6426
Joined: Mon Mar 05, 2007 8:33 am

Re: Preserved API Code Falling Outside Margin

Post by NorthEast »

I've no more ideas - that CSS you posted works fine for me in PDFs, and using your code sample too.
Titus
Propeller Head
Posts: 38
Joined: Thu Dec 04, 2014 2:33 pm

Re: Preserved API Code Falling Outside Margin

Post by Titus »

There must either be some conflict in my stylesheet, or something disabled that's messing things up on my end..? :(

Thanks for the help, Dave!

Edit: After discussing the issue with tech support, and providing them a sample project with our stylesheet, it has been submitted to the developers as a bug in the XML Editor...
salipour
Jr. Propeller Head
Posts: 6
Joined: Tue Dec 27, 2011 9:44 am

Re: Preserved API Code Falling Outside Margin

Post by salipour »

I was having the same problem with long strings of code and then finally got it to work correctly in the PDF output.
The following css allowed long strings of characters (example encryption code) to wrap correctly and not run off the page.

width: 600px;
word-break: break-all;
mc-hyphenate: never;
Post Reply