Current Filename in AsciiDoc - asciidoctor

Is there some variable like the 'imagepath' in AsciiDoc/Asciidoctor which gives me the current source file?
I would like to use this in order to render a link to the sources...
couldn't find this on google 😐

In Asciidoctor (http://asciidoctor.org/docs/user-manual/#env-attributes) try
docdir, docname, docfile
These are for the outer document only - there is no way to get the name of #included files.
Asciidoc additionally has infile and indir for the current #include.

Related

In asciidoc how do I execute a macro only for pdf generation?

In the asciidoc there is an image that I'd like to include only for PDF output. Is there a kind of attribute I can pass to image:: so that the image is processed for PDF generation, and ignored when generating epubs etc.? Or more probably by using ifdef, but how exactly?
You can use the ifdef directive like this:
Some text for all outputs.
ifdef::backend-pdf[]
This is only displayed in the PDF document, you can use image:
image::mypict.png[]
endif::[]
If you need a simple and small solution, I would prefer Jminis answer.
For cases that need more differentiation, you can define your own filter parameters, for different types of output, that can be defined as parameters in the commandline call. You can filter your content as follows e.g. if you want to differ between different audiences as well.
Some text for all outputs.
ifeval::["{myfilter1}"=="pdf"]
This content is pdf-only!
ifeval::["{myfilter2}"=="adminpdf"]
This content is admin-pdf-only!
endif::[]
endif::[]
You can add the parameters in the commandline call as follows:
--attribute myfilter1='pdf'
The exact expression of the command depends on your system. The following syntax could work (I cannot test it at the moment in the absence of a asciidoc-setup).
OS X asciidoc -> docbook:
SCRIPT=${...path to asciidoc installation...}/asciidoc.py
INPUT=myAsciidocInput.ad
OUTPUT=MyDocBookOutput.xml
MYFILTER="--attribute myfilter1='pdf' --attribute myfilter2='adminpdf'"
python "$SCRIPT" -o "$OUTPUT" "$MYFILTER "$INPUT"
WIN asciidoc -> docbook:
set SCRIPT=%{...path to asciidoc installation...}%\asciidoc.py
set INPUT=myAsciidocInput.ad
set OUTPUT=MyDocBookOutput.xml
set MYFILTER=--attribute myfilter1='pdf' --attribute myfilter2='adminpdf'
python "%SCRIPT%" -o "%OUTPUT%"

Export (save as) jpg using layer name in Photoshop action

is it possible to copy the current active layer name in Photoshop and use it as the file name for a 'Save As' command in a Photoshop action?
Export Layers to Files isn't suitable because I only want to save a single jpg at a particular point in the action, but because the action is recursive I need a way of changing the filename so that the resulting jpg isn't overwritten with each recursion.
Many thanks!
It's possible to get the name of the activeLayer and save it within an variable:
var layerName = app.activeDocument.activeLayer.name;
var destFile = new File ("~/Desktop/" + layerName + ".jpg");
If you want to document.saveAs() you should set the asCopy parameter to true:
app.activeDocument.saveAs (destFile, docExportOptions, true, Extension.LOWERCASE);
This will prevent a name change of the file you're working with.
Instead of document.saveAs() you could use document.exportDocument() in case you want a really small JPEG output.
app.activeDocument.exportDocument (destFile, ExportType.SAVEFORWEB, docExportOptions);
Have you tried : "Export layers to files..." in Files, Script ? You don't tell us which method you are using right now.
This should export each layer with their name + a custom prefix of your choice.
Also, you may want to take a look at the Insert Menu Item that lets you record a set of actions and then does it automatically. If you need something more complex than the first option, this might be your solution.

How to get non standard tags in rpm query

I wanted to add things such as Size, BuildHost, BuildDate etc in rpm query but adding this thing in spec file results in unknown tag?? How can I do this so that these things are reflected when i give the rpm query command?
These tags are determined when the package is built; they cannot be forced to specific values.
For example BuildHost is hardcoded in rpmbuild and cannot be changed. There is RFE https://bugzilla.redhat.com/show_bug.cgi?id=1309367 to allow it modify from command line. But right now you cannot change it by any tag in spec file nor by passing some option on command line to rpmbuild.
I assume it will be very similar to other values you specified.
RPM5 permits arbitrary unique tag names to be added to header metadata.
The tag names are configured in a colon separated list in a macro. Then the new tags can be used in spec files and can be extracted using --queryformat.
All arbitrary tags are string (or string array) valued.

How can I search in PDF documents/PDX catalog in powershell

I have a vendor that supplies their documentation library as a series of PDF files (and some CHM files) and include a .PDX catalog also.
I want to write a powershell script to front end it (using either powershell forms, or hosting powershell in asp.net).
I'm in the early stages, I've worked out how to get document information from the PDF stream (the xmpmeta XML metadata block near the end of the PDF file - one of the few streams in the file that's in plaintext) which looks like this:
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 4.2.1-c043 52.372728, 2009/01/18-15:08:04
"><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><rdf:Description rdf:about="
" xmlns:pdf="http://ns.adobe.com/pdf/1.3/"><pdf:Producer>GPL Ghostscript 8.64</pdf:Producer><pdf:Keywo
rds>86000056-413</pdf:Keywords></rdf:Description><rdf:Description rdf:about="" xmlns:xmp="http://ns.ad
obe.com/xap/1.0/"><xmp:ModifyDate>2011-03-03T17:38:34-05:00</xmp:ModifyDate><xmp:CreateDate>2011-01-28
T23:12:07+05:30</xmp:CreateDate><xmp:CreatorTool>PScript5.dll Version 5.2</xmp:CreatorTool><xmp:Metada
taDate>2011-03-03T17:38:34-05:00</xmp:MetadataDate></rdf:Description><rdf:Description rdf:about="" xml
ns:xmpMM="http://ns.adobe.com/xap/1.0/mm/"><xmpMM:DocumentID>6cb2263d-2d61-11e0-0000-1390d57dcfcb</xmp
MM:DocumentID><xmpMM:InstanceID>uuid:1a0e68ba-14ad-4a03-b7a1-0a0e127b8753</xmpMM:InstanceID></rdf:Desc
ription><rdf:Description rdf:about="" xmlns:dc="http://purl.org/dc/elements/1.1/"><dc:format>applicati
on/pdf</dc:format><dc:title><rdf:Alt><rdf:li xml:lang="x-default">I/O Subsystem Programming Guide</rdf
:li></rdf:Alt></dc:title><dc:creator><rdf:Seq><rdf:li>Unisys Information Development</rdf:li></rdf:Seq
></dc:creator><dc:description><rdf:Alt><rdf:li xml:lang="x-default">ClearPath MCP 13.1,Application Dev
elopment,Administration,ClearPath MCP</rdf:li></rdf:Alt></dc:description></rdf:Description></rdf:RDF><
/x:xmpmeta>
using the following code (powershell v3, in v2 you need to select and expand the properties thus [string]$title = ($rdf.GetElementsByTagName('dc:title')| Select -expand Alt|Select -expand li)."#text"):
$file = ".\Downloads\68698703-007\PDF\86000056-413.pdf"
#determine what line in file the xmpmeta string starts
[int]$startln = (select-string -pattern '^<x:' $file).ToString().Split(":")[2]
#determine what line in file the xmpmeta string ends
[int]$endln = (select-string -pattern '^</x:' $file).ToString().Split(":")[2]
$startln--
#grab the xmpmeta and cast as type xml
[xml]$xmp = (gc $file)["$startln".."$endln"]
[xml]$rdf = $xmp.xmpmeta.InnerXml
#get title/creator/description element text
[string]$title = $rdf.GetElementsByTagName('dc:title').Alt.li."#text"
[string]$creator = $rdf.GetElementsByTagName('dc:creator').Alt.li."#text"
[string]$description = $rdf.GetElementsByTagName('dc:description').Alt.li."#text"
That's crucial because the filenames are in the format 12345678-123.pdf, the actual title is in the metadata itself, as well as document category etc.
So, I can produce a list of documents (displaying their proper titles, not the real filename) and allow them to be launched, but I also want to be able to search in all the documents using PDX file, but it's by no means plaintext!
I guess I could use one of a number of tools out there to convert each PDF into text, search it, repeat for each document and then return results for each document.
But, it strikes me that Adobe Reader already does that, so can I either start AcroRd32.exe with switches that will start the search, with search terms I've passed in to the AcroRd32 program, or can I use Adobe Search.API from within Powershell?
Any ideas specifically on automating load of the .PDX in Adobe Reader and firing off the search, or using adobe's API in powershell?
EDIT:
I can now launch acrobat from command line and search (so could mimic this in powershell) but the search only works when searching a PDF, not a PDX catalog. Both bring up the search pane, but only in a PDF document does the search field get populated and the search executed.
C:\Program Files (x86)\Adobe\Reader 10.0\Reader>AcroRd32.exe /A "search=trim" "P:\Doc Library\PDF\00_home.pdx"
Or
C:\Program Files (x86)\Adobe\Reader 10.0\Reader>AcroRd32.exe /A "search=trim" "P:\Doc Library\PDF\86000056-413.pdf"
Regards,
Graham
This is an old post, but be aware that the searching you do is potentially dangerous and that there is a better way to find the XMP metadata in a PDF file. XMP was designed specifically to be "findable" by text search. To that purpose it has a well defined begin and end code defined that is in there specifically so that you can extract the XMP data without having to parse the PDF format (or any other format the XMP metadata blob might be embedded in.
You can download the XMP specification here: http://www.adobe.com/devnet/xmp.html. Part 1 is the part where the explanation about XMP Packets explains how a text scanner can find the XMP packet with more accuracy.
Finally, PDF has an additional quirk that allows it to be incrementally updated. This might cause multiple XMP packets to appear in the file (where the last packet is normally the correct one). But annoyingly when the PDF is exported from applications like InDesign, images in the PDF (and other objects) might also have their own "object" XMP attached to it.
So consider where your files come from and how many strange things you might encounter and you want to provision for. But reading the XMP specification is not a bad idea for sure.

How to specify the name of the generate file to the e:worksheet function

We use the jboss seam-->excel module integration for generating excel sheets using e:worksheet. But the downloaded file name comes out as ExportUsers.jxl.xls, I would rather see this as ExportUsers.xls. How do I customize this information.
filename attribute of the e:workbook tag
<e:workbook filename="ExportUsers.xls" />
Take a look at the Seam excel documentation.
filename — The filename to use for the download. The value is a string. Please note that if you map the DocumentServlet to some pattern, this file extension must also match.

Resources