DITA and XMetaL Discussion
txvia October 25, 2011 at 4:55 pm
Insert an image to the PDF cover page that fills up the whole pageOctober 25, 2011 at 4:55 pmParticipants 8Replies 9Last Activity 10 years, 11 months ago
Hi, I am trying to add an external image file to the PDF cover page that would fill up the whole page; basically, what I have is a custom-made image file with nothing but dark blue background in it, and I was fiddling with the codes in xm_layout_masters_overrides.xsl and even xm_titlepage.xsl, but to no avail. In what files do you make that kind of change, and what codes do you insert to those files anyway?
In addition, I'd also like to be able to change the font size and font color of the PDF cover page, where and how can I do that? Thanks a million 🙂
I am attaching the image in question for your reference, thanks again.IF November 2, 2011 at 8:00 pm
Reply to: Insert an image to the PDF cover page that fills up the whole pageNovember 2, 2011 at 8:00 pm
To change the font size/color, have you tried to edit the attribute set xm.titlepage.tile in
IF November 2, 2011 at 9:52 pm
Reply to: Insert an image to the PDF cover page that fills up the whole pageNovember 2, 2011 at 9:52 pm
For inserting the image, this worked for me (note that I am using deliverable XMetal Enhanced PDF via RenderX XEP).
I replaced the template that has this match element [code] match=”fo:region-body[contains(parent::*/@master-name,'odd')] | fo:region-body[contains(parent::*/@master-name,'first')]”[/code]
(template is in file C:Users
with the following
url(Customization/OpenTopic/common/artwork/cover_page_background.jpg) no-repeat center center
You need to put a copy of your image here
You may also have to modify the image size.txvia November 3, 2011 at 4:25 am
Reply to: Insert an image to the PDF cover page that fills up the whole pageNovember 3, 2011 at 4:25 am
Hi , thanks for your reply. I tried your method, but the result was different than what I expected. First, the first few pages were filled with this background image, and I only want the cover page to be filled with this image. Second, the image does not fill up the entire cover page, only a block of it. I have a feeling that the center block area of the cover page needs to be resized, could you show me how to do that also? Thanks very much for your help!IF November 3, 2011 at 4:44 pm
Reply to: Insert an image to the PDF cover page that fills up the whole pageNovember 3, 2011 at 4:44 pm
I think you have to resize the image (it is too big – I used 614 x 796 pixels in my test).
My test was for a dita map not a bookmap. I am not sure how to fix for a bookmap. I suspect you have to modify the template “createFrontMatter” in xm_titlepage.xsl but I'm not sure.Derek Read November 5, 2011 at 12:10 am
Reply to: Insert an image to the PDF cover page that fills up the whole pageNovember 5, 2011 at 12:10 am
Here is another strategy. It is difficult to give you “the” answer as there can really be no best way to do what you want.
The following should place a background image on the title page (you might also call that the “cover”) of the PDF. This is done by modifying the XSLFO to add a new container block and adding a background-image.
You don't have to do the first step, but if the rest of this doesn't work it should help to eliminate the possibility that other changes you've made to the DITA OT are interfering — I've tested this with a default (unmodified) installation on XMetaL Author Enterprise 6.0.2.070.
1. Make sure you aren't going to lose any changes to the DITA OT that you want to keep, then do the following so we begin with a fresh copy of the DITA Open Toolkit.
– Delete this folder%appdata%SoftQuadXMetaL Shared
– Generate output from your DITA map. This will restore the folder structure we just deleted by deploying a copy of the DITA OT from C:Program FilesCommon FilesXMetaL Shared
You may wish to allow output to complete to make sure that it is successful and that everything is working properly as with an out of the box installation.
Of course, if you have been modifying the copy in Program Files then your modifications will be redeployed. So, if you really need to start with an unmodified copy of the DITA OT you will need to reinstall and then redeploy.
2. Locate a supported image type on your system (JPG, PNG, GIF, TIFF, SVG or PDF). For information on supported image types see http://www.renderx.com/reference.html#SupportedGraphicFormats
3. Place a copy of that image in this folder:
Note: RenderX supports the embedding of vector-type images (SVG and PDF). So, to keep your PDF file sizes small you may consider using PDF, and the image you have posted lends itself well to that as it can be constructed as a few shapes with appropriate fill colours. However, the DITA OT only copies JPG, GIF, PNG to the temp folder that is ultimately used by RenderX XEP to generate the PDF and so if you use PDF you may need to manually move it there. Alternatively, you may use an absolute path. You might try JPG to start with though, to make sure everything else is working, then look into PDF later (keeping the possible points of failure to a minimum is usually a good idea).
4. Open the following file in your favourite text or XSLT editor:
Note: This is the deployed copy of the DITA OT. Once you get this working, and if you need to reuse this solution on multiple machines for all users at your location, you may wish to modify the “installed” copy of the DITA OT and then have users deploy it. If this is just for you then you can weigh the benefits to either method. See: http://forums.xmetal.com/index.php/topic,1008.0.html
5. Locate the first
object in xm_titlepage.xsl. It should be and inside (after) the opening tag add the following:
The negative values for top and left “undo” margins set elsewhere so that they are effectively set to zero. For right and bottom the numbers can be larger than actually necessary. For some reason, setting them to -30mm was not quite big enough, but I don't want to bother tracking that down. Since the image is going to “bleed” off the edge anyway these can be bigger than necessary I think.
Here's another example using a PDF “image” (the file is the one I have included in the attached zip) and referenced using a full path. Adjust the path to point to your PDF file (test using the one I am attaching first, since it does work).
6. Inside the same
object and just inside (before) the closing tag add the following to close the we just added:
7. Save the file.
8. Generate output using the deliverable “XMetaL Enhanced PDF via RenderX XEP”.
This should produce a PDF with an additional container block on the title page and one copy of your image.
The image will have been copied here when you generate output (unless it was an SVG or PDF file):
Things to check if this does not work for you:
1) Interference from other DITA OT changes you have made previously. In this case you might do my steps 1 and 2 (after backing up your changes).
2) Make sure the log.xml file does not contain any warnings or errors specific to the XSLT / XSL-FO changes that we have made and that output was successful. If output fails you are usually given the option to open this file. You can also open this file by selecting File > Open Output Log.
3) Make sure the image format is supported. RenderX XEP has specific requirements for image types. If you run into problems with one type (eg: JPG) try another such as GIF, or another image of the same type created by another application.
4) Make sure the image is in fact being copied to the location specified.
5) Check the topic.fo file that is generated to see that the path to the image is correct. By default this file is cleaned up after output is complete. To disable this cleanup enable the following setting:
Tools > Configure Output > Advanced (tab) > Other output parameter (textbox): cmd_synchro_mode = 2
6) If you don't see your image in the PDF but you are sure everything is OK look for a “missing image” icon. That will tell you that the XSLT is working but that the image can't be found, so something is wrong with the path.
7) If you don't see your image in the PDF but otherwise everything seems OK, check to see that the image fits on the page. Images may not embed (or render) if they are too big to fit the width or height of their container block in the PDF. I believe this is not the case when the FO property “absolute-position” is used (as I have done here).
Attached in the zip:
gcrews November 6, 2011 at 12:09 am
- cover_page_background.pdf: A PDF “image” that contains an attempt to reproduce your JPG as a vector drawing (thereby reducing file size to about 2KB).
- test_topic.xml: A test DITA topic.
- test_topic.pdf: The PDF that results from generating output for the test topic together with the modifications above that use the PDF image as the cover.
Reply to: Insert an image to the PDF cover page that fills up the whole pageNovember 6, 2011 at 12:09 am
I would agree with Derek on using SVG as well.
Not realizing Derek already did an example of that i did as well:
here is the SVG code I came up with:
preserveAspectRatio=”xMinYMin meet” viewBox=”0 0 5110 6600″>
I think the only issue would be the linearGradient. The Renderx page says its supported ( http://www.renderx.com/reference.html#SVG ) but I don't think the the XEP Renderx version that xmetal comes bundled with supports linearGradients. If your going to use it for high quality print you may end up with banding as well. its a bit more tricky to add noise and dithering to SVG images.
Is there any downside to using SVG image? Even if RenderX supports SVG, might the end user PDF reader not support it or be it an older PDF reader or third party reader?
FYI,I think the code tag style on this forum is slight to wide.txvia November 6, 2011 at 2:01 am
Reply to: Insert an image to the PDF cover page that fills up the whole pageNovember 6, 2011 at 2:01 am
I truly appreciate both of your help; I tried Derek's method, and it worked perfectly! I will try gcrews's method and let you know, thank you all.txvia November 6, 2011 at 6:18 pm
Reply to: Insert an image to the PDF cover page that fills up the whole pageNovember 6, 2011 at 6:18 pm
Hi Derek, could you tell me when using the jpg file I attached to produce a pdf output, what file size did you specify when generating the pdf so that it fits perfectly within the boundary of the title page? I'd like to use the values you set for my future reference, thanks again.Derek Read November 7, 2011 at 6:08 pm
Reply to: Insert an image to the PDF cover page that fills up the whole pageNovember 7, 2011 at 6:08 pm
8.5 x 11″ is all you should need (or the same paper size as the PDF you are producing). I made my slightly larger at 9.0 x 11.5″ so I had some room to play with. You can check this on any PDF by right clicking in it and selecting “Document Properties” inside Adobe Reader.
- You must be logged in to reply to this topic.