Count pages in PCL with GhostPDL 9.x - ghostscript

I used to Count pages in a pcl file using the GhostPDL (pcl6.exe) in Version 8.71.
pcl6.exe -dNOPAUSE -sDEVICE=nullpage -g10x10 -C file.prn
which produced a
%%PageCount: 10
for instance. Now I updated to 9.10 Version and found that my usual code did not work anymore. The command line Switch "-C" is gone.
I searched the documentation but it brought me nowwhere close to a solution. So it does not seems a very good approach to convert PCL to PDF and then count the PDF pages with GhostScript.
Any suggestions?

Why is converting to a PDF and then using pdfinfo not a good solution ?

Related

How to convert PDF version to 1.7 ExtensionLevel 8 using Ghostscript

I am able to convert the PDF version from 1.5 to 1.7 with the below Ghostscript code but how to convert "PDF version 1.7 ExtensionLevel 8"?
gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dFastWebView=true -dCompatibilityLevel=1.7 -sOutputFile=output.pdf input.pdf
What exactly are you expecting to happen here ?
Your command line doesn't actually do anything except write a different version number into the PDF header. The same would be true of writing an extension version, all it does is change the 'version', it doesn't affect the content of the PDF file.
Ghostscript's pdfwrite device doesn't even use the features of PDF 1.5 (with a couple of minor exceptions), so what do you expect to gain even by producing a PDF 1.7 file ?
Lying about the minimum required version (which is what you are doing when you change the version like this) simply means that older PDF consumers might fail to open the file (or give a warning) because they believe it will use features which they don't support. Since the PDF file doesn't use those features, you are actually making the file less portable by doing this.
FWIW Ghostscript's pdfwrite device can now produce PDF 2.0 files.
If you absolutely are insistent about doing this you can 'probably' add an Extensions dictionary to the document Catalog using pdfmarks, but I'm not 100% confident.

Spring Framework 5 Reference Documentation epub

For Spring versions 5.x I cannot find any epub or pdf version of the reference documentation. Former versions were available e.g. at https://docs.spring.io/spring/docs/4.3.9.RELEASE/spring-framework-reference/epub/. Are they available any more? epubs are perfect to be read with an ebook reader.
My guess is that it will get published in time.
Meanwhile - this is the 5.0.4.RELEASE docs in pdf:
https://docs.spring.io/spring/docs/current/spring-framework-reference/pdf/
which you can convert to epub if you wish to do so.
The only officially available and latest epub is the 5.0.0.M5: https://docs.spring.io/autorepo/docs/spring-framework/5.0.0.M5/spring-framework-reference/epub/
The epub for the latest version is not available.
but, I would recommend you to try to convert the html documentation directly to epub.
as converting pdf to epub does not result in very good result [as tools like calibre convert the pdf to html and then epub]
I tried a online converter to convert the https://docs.spring.io/spring/docs/current/spring-framework-reference/
and works pretty good.. [especially the code blocks seem better than the official epub]
hope you find this helpful.

Converting .tif to pdf/A 1.4 or 1.5

Using a shell command I have been able to convert .tif files to pdf files. Unfortunately the outputed files are in pdf/A ver 1.3 and I need it to pdf/A v1.4 or 1.5.
This is my command (output in v1.3):
Convert test.tif test.pdf
I think the command is using imagemagick tool (which use ghostscript) to do the conversion
So I tried this ( still 1.3 but the pdf/A is not valid):
convert test.tif pdfa:test.pdf
Then I tried to convert the pdf 1.3 to 1.5 using ghostscript
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.5 -dNOPAUSE -dQUIET -dBATCH -sOutputFile=new-test1.5.pdf test.pdf
This work just fine.Do you think is possible to convert .tif file directly to .pdf 1.4 or 1.5 ?
I tried to check the gosthscript files but I was not able to do any modification leading to my excpected result.
Thank you for your help
RFlow
You have not stated which version of PDF/A you require. If you need PDF/A-1a or PDF/A-1b then you cannot produce a PDF greater than PDF 1.3 as that is specifically forbidden by the specification.
Why do you need PDF 1.4 or 1.5 ? The PDF version is simply a statement of the minimum feature set used by this PDF file, PDF is forward-compatible, a PDF 1.4 consumer can also by definition read PDF 1.3 files. Since you started with TIFF I cannot see any way that your PDF file needs to be of a higher level than PDF 1.3
Your Ghostscript command line will produce a PDF file which states that it requires a consumer of at least level 1.5 (which is a lie ;-) but the resulting PDF will not be PDF/A compliant.
So you really need to explain why you need a PDF/A file, and why it has to be PDF version 1.4 or greater.

Wkhtmltopdf version, first page and TOC

Some questions for this very nifty tool, unfortunately lacking many usage examples.
Manual speaks of a possible “Reduced Functionality” for wkhtmltopdf. I have version wkhtmltox-0.11.0_rc1-installer.exe, by running wkhtmltopdf --version what should I read to understand whether my version is the reduced one or not?
Currently I like wkhtmltopdf for webpages I want to read later and/or store. To mirror webpages I use httrack, then I generate the PDF with wkhtmltopdf *.html offline.pdf. How can I set/specify the first PDF page from the *.html list? Currently they seem to be converted in alphabetical order.
If I run wkhtmltopdf toc http://qt-project.org/doc/qt-4.8/qstring.html qstring.pdf I simply get a leading blank page, no TOC. What’s wrong?
Thanks for helping
EDIT:
#Nenotlep:
Your TOC trick works perfectly.
As for the first page, I don’t need an actual cover.
What I need is a way to download/convert a given page www.site.com/foo.html and all the linked pages (A.html, B.html ...) up to a certain depth level. Then I want a single PDF starting with foo.html and containing also the pages A.html, B.html ... (with relative links).
I don’t think there is an option to download and insert the linked pages in the final PDF (please, correct me if I am wrong). So I use httrack.com to download and wkhtmltopdf to convert. Given the alphabetical behaviour of wkhtmltopdf, the best now seems to rename the target page, downloaded with httrack, something like !foo.html.
Please, let me know of possible alternatives.
For part 3 of the question which is blank TOC, the latest stable version 0.12.5 also does not generate it. The pre-release version 0.12.6-dev has fixed this problem in Mac.
I think all available precompiled wkhtmltopdf's are compiled with the patched QT, they are not reduced. The reduced functionality means that it was compiled without a special patched version of QT. I use the windows version and it isn't reduced.
I think the cover command line argument would work for you. I can't test at the moment, but try a command like wkhtmltopdf cover derpy.html toc --xsl-style-sheet default.xsl rarity.html twilight.html spike.html equestriadaily.pdf
At least in Linux, I think the asterix *.html simply explodes into all the html files before the command is performed, so if you select one html file for the cover and then do *.html in the same folder you will get the file twice. Getting around this issue might need some command line sorcery or a batch file or some other trickery.
This is a bug in wkhtmltopdf. The workaround is to manually set a tocfile. You can get the default tocfile with wkhtmltopdf.exe --dump-default-toc-xsl. Then you can save the output as a file and use it like wkhtmltopdf.exe toc --xsl-style-sheet default.xsl www.stackoverflow.com so.pdf.

Revert XCode compression with pngcrush on windows?

I have some png images extracted from IPA files and I want to get the original PNG back, I was advised that pngcush did the task required so I downloaded it and tried running the following command:
pngcrush -fix icon.png icon1.png
But I get a libpng error. I don't know if libpng needs to be downloaded as well, since the error doesn't says that I need a different version of libpng, just says:
While reading icon.png:
pngcrush caught libpng error:
incorrect header check
I also tried this one:
pngcrush -revert-iphone-optimizations icon.png icn1.png
And pngcrush acts as if didn't knew the command.
Any ideas on what to do?
You may be interested in this C# library I developed to reverse what pngcrush does. All existing implementations I found were either riddled with bugs or too difficult to integrate into my project so I developed this. It has unit tests if that makes you feel safer.
The -iphone addition to pngcrush was added by Apple and is only available in the version of pngcrush in the iOS SDK, accessible by using xcrun like follows:
xcrun -sdk iphoneos pngcrush -iphone|-revert-iphone-optimizations ...
This answer: pngcrush: uncrush on linux? explains that -revert-iphone-optimizations is only present in the Apple version of pngcrush. But it does point to a couple of other options that might work. Linux, not Windows, but since there's source, you might get it to work.
Maybe you can try pngdefry.
Perfect dealing pngs with multiple IDAT tags.
It probably doesn't know the command. The documentation I found on -revert-iphone-optimizations comes from an apple developer page which refers to pngcrush being a part of the IOS SDK. Given that, i'd suggest it's been hacked into that specific version by apple and may not be part of the official pngcrush download. If that's true you'll actually need to install that and use the included pngcrush as explained in the article.
I'm also a bit suss on the syntax used in that example. It looks like a long option and they normally start with two hythens, not one. It could simply be a typo so try --revert-iphone-optimizations as well.

Resources