XSL: how to display an value based another attribute value? - pdf

I'm working on a DITA customization plug-in to generate a PDF with XEP engine (and based on DITA Open toolkit).
I'd like to have some content in a PDF layer (OCG), does anyone know if it's possible and if so, how?
Thanks,
Annette

RenderX XEP's PDF output does not support creating layers.

Related

Alternate text for links in PDFs generated with DITA OT and FOP

I'm generating PDFs with DITA OT 3.6 and Apache FOP 2.5. For accessibility, we need to provide alternate text for links (such as the table of contents and cross-references). So far, I haven't found a way to do this with <fo:basic-link>. I tried using <xsl:attribute name="fox:alt-text">, but that doesn't work with <fo:basic-link>. Does anyone have any suggestions? Thanks.
I'm not sure why you would need to provide alternate text on links, they usually have their own text content inside them and also target information.
The Apache FOP docs states that the "fox:alt-text" is used only on fo:external-graphic and fo:instream-foreign-object to provide alternate text:
https://xmlgraphics.apache.org/fop/1.1/accessibility.html
Maybe you can try to use a commercial PDF processor like Antenna House which seems to be able to support alternate text on links: https://www.antennahouse.com/tips-tricks/2016/03/pdf-techniques-for-web-content-accessibility-guidelines-2-0

Create PDF layers using DomPDF

I'm trying to create a PDF with layers, one for the texts and the other for a background image so user can print only the text layer.
Does anyone knows if it's possible and if so, how can I do that ?
I'm using version 0.8.2.
Thanks
Finally it looks like layers or the Optional Content Groups are not supported by DomPDF. So my solution was to change to TCPDF, it's not great for CSS but it offers the option to create layers and change the visibility of objects in the PDF.
So you can set objects to show only in screen or print.
I hope this can help if someone has the same issue.
Here's the link to TCPDF

Apache FOP - Scrolling in PDF possible?

I'm using Apache FOP to generate a PDF through XML and XSL-FO. I have a cell in my generated PDF that I need to be able to scroll through if the content overflows it. XSL-FO has an overflow="scroll" feature, but based on my research on the topic it seems that Apache FOP does not support this option.
For example, here is a scrollable region in a PDF used by a large CAD company that I need to replicate:
Is there any way to enable this feature in Apache FOP? Is it possible to enable it in the source code (I haven't been able to find a way to do so)? Any other ways to tackle this issue?
No, it isn't possible.
From the FO perspective:
In the XSL-FO Recommendation the scroll value for the property overflow comes from the corresponding CSS2 definition, which includes this clarification:
When this value is specified and the target medium is "print", overflowing content should be printed.
As the PDF output is a print-oriented medium, I read this as a confirmation that FOP is correct in printing the overflowing content.
From the PDF perspective:
In the PDF Reference 6th edition, a search for the word "scroll" returns results referring either to the scrolling bars in the user interface or in interactive forms (text fields, list boxes, combo boxes).
There is not, or at least I could not find it, a "static text object, but with scrolling bars" feature (which is probably sensible for a print-oriented format), so FOP cannot create it in the PDF output file, not even modifying the source code.
A second look at your comment and the screenshot you included made me think it could be an example of the 3D Artwork feature of the PDF format, a feature I didn't know of before (and I still know nothing besides its name). According to the reference:
Specific views of 3D artwork can be specified, including a default view that is displayed initially and other views that can be selected. Views can have names that can be presented in a user interface.
So, I think your screenshot shows the different views associated to a 3D object; it is not a general-purpose feature that could be used to provide scrollable text.
Well, it could be possible ...
It is possible but as far as I know not with Apache FOP. Without seeing the PDF in question and guessing from the screen shot, it looks like a Flash widget inserted into the PDF. This in PDF terms is a RichMedia annotation (requires PDF version 1.7 with extensions) in which you can insert the Flash widget as well as other controlling files (like XML, other images to display, etc.) and relate them together.
AFAIK, only RenderX XEP (whom I work for) supports such RichMedia annotations inserted into PDF via XSL FO through the rx:rich-media-object extension documented here: http://www.renderx.com/reference.html#Rich Media
I believe, the only viewer that supports PDF with RichMedia annotations is Adobe Reader so it is required to view such a file. Here is a sample that includes a few interactive flash widgets, some interactive charts all within a few page PDF that was generated long ago. NOTE: I am sure some of the links in the document do not go anywhere, it was for a trade show many years ago. Remember, you would need to download this file and view in Adobe Reader and have flash player installed to see it function.
http://www.cloudformatter.com/Resources/Samples/RichMedia.pdf
You cannot use common PDF browser-based viewers like Chrome or Firefox as they do not support this type of annotation.
A screenshot of page one here shows an interactive, scrolling widget. Page 4 contains a widget similar to what you show in your example.
Page 4 scrolling widget very similar to your request:
The widget on the last page is created using a scroller SWF that takes parameters that are the images and setup/configuration files that are XML. The RenderX extension object takes these as parameters and embeds all of them in the document for the interactive flash widget so that it is totally self-contai9ned in the PDF. The XSL FO to do this is:
<rx:rich-media-object name="Sample HTML Widget" scaling="non-uniform" width="611.92pt"
height="74.99pt" content-width="scale-to-fit" src="url('rx-scroller\dockmenu.swf')"
transparency="true" activate-condition="page_visible">
<rx:flash-var name="setupXML" value="rx-dock-settings.xml"/>
<rx:flash-var name="contentXML" value="rx-dock-contents.xml"/>
<rx:rich-media-resource name="rx-dock-settings.xml"
src="url('rx-scroller\rx-dock-settings.xml')"/>
<rx:rich-media-resource name="rx-dock-contents.xml"
src="url('rx-scroller\rx-dock-contents.xml')"/>
<rx:rich-media-resource name="style.css" src="url('rx-scroller\css\style.css')"/>
<rx:rich-media-resource name="customer1.png" src="url('rx-scroller\images\customer1.png')"/>
<rx:rich-media-resource name="customer2.png" src="url('rx-scroller\images\customer2.png')"/>
<rx:rich-media-resource name="customer3.png" src="url('rx-scroller\images\customer3.png')"/>
<rx:rich-media-resource name="customer4.png" src="url('rx-scroller\images\customer4.png')"/>
<rx:rich-media-resource name="customer5.png" src="url('rx-scroller\images\customer5.png')"/>
<rx:rich-media-resource name="customer6.png" src="url('rx-scroller\images\customer6.png')"/>
</rx:rich-media-object>
And note that many things that are in the flash would work, like links and such. It is just a pure, interactive flash inserted into PDF as the container.
Indeed it looks like this is not possible to achieve through FOP.
Continuing to dig around for a few days, however, I did find a clever post-processing alternative that is also free, essentially embedding a PDF inside of another PDF using the LaTeX animate package.
A drawback to this method is that it is not possible to embed links inside of the scrollable region, which is a major issue for me. But the method does enable inserting a scrollable region inside of an existing PDF and got me very close to what I was trying to achieve.

XSL-FO display watermark only when printed

Using XSL-FO, is it possible to add a watermark to a document that is visible only when it is printed?
MY XSL-FO output format is PDF.
I suspect that the answer is no, but I would love to hear different.
AH Formatter from Antenna House can produce PDF with print-only layers as you describe. See http://www.antennahouse.com/product/ahf60/docs/ahf-ext.html#pdf-layer
You could put the print-only watermark in one of the side regions and use axf:layer to make it appear on a layer that you have set up to be print-only.
There is a free renderer named altsoft xml2pdf that supports layers, see https://www.alt-soft.com/tutorial/xslfo_tutorial/xsl-fo_extensions_pdf-layer.html
I use this renderer for regular production since years, but its windows only.

Is there a library to programmatically convert a PDF document into a flipping book?

I would like to convert programmatically convert a PDF document to a Flash flipping book.
The same thing is done throug this site : http://www.codebox.es/pdf-to-flash-page-flip
They apparently use those 2 libraries :
Dynamic Page Flip v2 from 76design.com
SWFTools from swftools.org
Is there any existing code to do the same job programmatically ?
Or do I have to develop in starting with these 2 projects ?
FlexPaper Zine which can be used with swftools has been released quite recently and looks good with HTML5 support for devices. It programmatically publishes documents using php or any other server language of choice
http://flexpaper.devaldi.com/flexpaper_flip_zine.jsp