webForumDet fria alternativet

Float-problem i xsl:fo

3 svar · 665 visningar · startad av @nders

@ndersMedlem sedan juni 200026 914 inlägg
#1

Jag har ett irriterande xsl**:**fo-problem.
Jag har en text som ska flöda runt en bild - so far, so good.
Bilden kan ha en bildtext - och så länge den inte är bredare än bilden är allt frid och fröjd. Men när bildtexten blir längre flyttas textblocket och jag får en massa fult vitt utrymme mellan bilden och textblocket.
Jag vill att bilden ska bestämma bredden på mitt block - och att bildtexten automatiskt ska radbrytas.

Jag har googlat utav bara 17 - men xsl**:**fo är inte det ämne det finns mest information om på det stora globala datanätet.

Så här ser min kod ut:

<fo:block-container keep-together.within-page="9" width="155mm">
	<fo:float float="start">
		<fo:block margin-right="5mm" margin-bottom="8mm" keep-together.within-page="9">
			<fo:external-graphic src="C:\Projects\Img\Image001.jpg"/>
			<fo:block font-family="Arial" font-size="7pt" space-after.optimum="6pt">Här är en bildtext som är massor bredare än bilden i floaten!</fo:block>
		</fo:block>
	</fo:float>
	<fo:block font-family="Arial" font-size="9pt">Lorem ipsum dolor sit amet - här ligger all text som flödar runt bilden.  ...to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?</fo:block>
	<fo:block clear="both"/>
</fo:block-container>

Jag använder AntennaHouse Formatter för att skapa PDF-filer av schabraket - och för att ni ska få en bild av resultatet av ovan kod har jag bifogat just det - en bild.

Hörni alla xsl**:**fo-experter - ge mig pet i rätt riktning, för nu sitter jag riktigt fast. :)

Mvh och tpf,

probläm.jpg
emissionMedlem sedan dec. 19996 095 inlägg
#2

Tricket bör vara att trycka in bild och bildtext i någon form av container som kan påverkas av bildens storlek, men inte av textens. T.ex en........tabell...

<fo:float float="start">
          <fo:block margin-right="5mm" margin-bottom="8mm" keep-together.within-page="9" width="1mm">
            <fo:table width="2mm">
              <fo:table-column/>
              <fo:table-body>
                <fo:table-row>
                  <fo:table-cell>
                    <fo:block>
                      <fo:external-graphic src="Images/spots.jpg"/>
                    </fo:block>
                  </fo:table-cell>
                </fo:table-row>
                <fo:table-row>
                  <fo:table-cell>
                    <fo:block font-family="Arial" font-size="7pt" space-after.optimum="6pt">Har ar en bildtext som ar massor bredare an bilden i floaten!</fo:block>
                  </fo:table-cell>
                </fo:table-row>
              </fo:table-body>
            </fo:table>
          </fo:block>
        </fo:float>
@ndersMedlem sedan juni 200026 914 inlägg
#3

Hmm - det där blev inte så bra. Efter att ha klippt loss koden från det större dokumentet ser det ut så här:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:is="http://www.intellectasystems.se/is">
	<fo:layout-master-set>
		<fo:simple-page-master master-name="prod-page" page-width="210mm" page-height="297mm" margin-left="10mm" margin-right="20mm" margin-top="10mm" margin-bottom="10mm">
			<fo:region-body region-name="body" margin-left="15mm" margin-right="10mm" margin-top="18mm" margin-bottom="15mm"/>
		</fo:simple-page-master>
		<fo:page-sequence-master master-name="prod-sequence">
			<fo:repeatable-page-master-reference master-reference="prod-page"/>
		</fo:page-sequence-master>
	</fo:layout-master-set>
	<fo:page-sequence master-reference="prod-sequence">
		<fo:flow flow-name="body">
				<fo:float float="start">
					<fo:block margin-right="5mm" margin-bottom="8mm" keep-together.within-page="9" width="1mm">
						<fo:table width="2mm">
							<fo:table-column/>
							<fo:table-body>
								<fo:table-row>
									<fo:table-cell>
										<fo:block>
											<fo:external-graphic src="C:\rabbit.jpg"/>
										</fo:block>
									</fo:table-cell>
								</fo:table-row>
								<fo:table-row>
									<fo:table-cell>
										<fo:block font-family="Arial" font-size="7pt" space-after.optimum="6pt">Här är en bildtext som är massor bredare än bilden i floaten!</fo:block>
									</fo:table-cell>
								</fo:table-row>
							</fo:table-body>
						</fo:table>
					</fo:block>
				</fo:float>
				<fo:block font-family="Arial" font-size="9pt">But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure? But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?</fo:block>
		</fo:flow>
	</fo:page-sequence>
</fo:root>

Jag bifogar också en bild på hur resultatet blir...

Edit: Jag vet inte vilka bredder jag har att jobba med - så jag kan inte sätta bredd till ett antal punkter eller millimeter - det måste alltså fixas dynamiskt.

probläm2.jpg
@ndersMedlem sedan juni 200026 914 inlägg
#4

Problemet löstes på så vis att kunden (eller någon projektledare eller nått) får bryta bildtexten manuellt.

Idéer mottages dock fortfarande gärna. :)

Genererad på 382 ms · cache AV · v20260730165559-full.f96bc7eb