Is Perl's CAM::PDF able to aggregate Annotation objects? - perl

I have several copies of the same PDF file. These copies have annotations in it (Rect type with pop-up comments).
I want to know if I can get all these annotations from these copies and aggregate them into a single master copy using CAM::PDF (or another free tool).
an example to illustrate:
I have file1_userA.pdf and file1_userB.pdf. They are both annotated.
I want to generate file1_allusers.pdf aggregating annotations from both files file1_userA.pdf and file1_userB.pdf.
ps: I have the original un-annotated copy.
-- EDIT (Aug, 4):
I have developed an extension for CAM::PDF, namely CAM::PDF::Annot. It 'use base's CAM::PDF and adds extra functionality regarding Drawing Markup Annotations.
I am in the process of tidying up the code so I can post it to CPAN.
-- EDIT (Aug, 19)
I have finally submitted it to PAUSE, but I am running into some world writable related problems...
In any case, if anyone is interested in taking a look at the code, I will try and make it available somewhere... until then, just PM me and I will mail it to you.
geez, i'm getting such a thrill posting a module to cpan... i found the joy of working in working with Perl...
best regards,
Donato Azevedo

I'm the author of CAM::PDF. I have built only very limited support for annotations to date, specifically just for form field filling. So, no, that's not a supported feature today. The feature you describe is very interesting, though, and I can imagine that others would use it too, so I'd be interested in discussing it further with you offline.

Related

How to highlight prefix match in SQLite FTS5

I have a SQLite FTS5 virtual table and am trying to highlight text in my prefix query results. I am aware of the highlight() and snippet() auxiliary functions, however they don't seem to support exactly what I am trying to do. If my data looks like:
fts.my_data
-----------
John
Mike
Bill
Jane
and I want to query using a prefix match such as
select * from fts where fts match 'j*';
The highlight and snippet functions (assuming <b>...</b> tags) will return
<b>John</b>
<b>Jane</b>
But I only want to highlight the exact part of the prefix that was matched, before the wildcard:
<b>J</b>ohn
<b>J</b>ane
There does not seem to be any way to do this using the existing FTS5 auxiliary functions. I realize FTS5 offers an API so that you can create your own auxiliary functions. I might also be able to implement the solution in application code (I am using Swift), although I suspect this problem has the potential for a lot of issues trying to implement in application code (for example, how to handle stemming). Does anyone know if what I am trying to do is actually possible using the existing highlight and/or snippet functions before I go to the trouble of implementing my own solution? If so, could you explain how?
Also, I have observed several other existing apps (Contacts+ for example) offer this capability so I know it is possible somehow, and am also wondering how they do it if anyone knows how.
For anyone else looking for a resolution to this issue, I was able to figure out how to solve this issue.
The trigram tokenizer was added as one of the built-in tokenizers in SQLite 3.34.0 (released December 1, 2020).
In my case, I was deploying to iOS, which at this current time, only has SQLite 3.32 bundled with it by default, as confirmed by this wiki page. So I was able to download the SQLite source code and add it as a project to my XCode workspace as a "Static Library" and reference the resulting .a static library file from within my app's project. I also had to set the appropriate C Flags in the XCode compiler options for the SQLite project to get everything to work correctly. But I am now able to distribute my own supplied version of SQLite (3.34.1), compiled with my specific options, with FTS5 and the trigram tokenizer.

signing pdf using itextsharp 5.4.4 - example

Can someone supply an example or a link to an example that signs an existing pdf using itextsharp 5.4.4? Ideally keeping pdf/a conformity of the pdf? Thank you.
Edit: I understand the question looks as if I did not use google etc. BUT, new versions of itextsharp contain completely rewritten code for signing as well as other functions, making the existing examples non-functional. Also, itextsharp started using different names for methods eg. instead of createSignature one has CreateSignature, instead of getSignatureAppearance one seems to have SignatureAppearance etc. making the port from java examples a real nightmare. Also the samples in the source code itself are in java not c#. There is really nowhere else I can go.
Please read http://itextpdf.com/book/digitalsignatures
The examples are in Java, but they were also ported to C#. You can find the C# examples here. I didn't vote your question down, but... the first place to go when you have a question about iText should probably be http://itextpdf.com
The book I refer to (I'm the author) as well as the new examples are on the learn page.

How could I find files that use certain modules in CPAN?

Some modules on CPAN are excellently documented, others.... not so much, but it's usually easy to discern how to use a module via prior art (e.g modules/tests that used the module you're looking to use). I'm wondering what the best way is to find code that uses the code you're looking to use.
example
I want to use (maybe?) Dist::Zilla::App::Tester for something, but the author has elected not to write any documentation on how to use it, some I'm wondering what path of least resistance is to find code that already uses it.
please don't answer for this module
Give a man a fish; you have fed him for today. Teach a man to fish; and you have fed him for a lifetime
Try Google Code Search, trying to search for strings like "use Dist::Zilla::App::Tester" (quotes are important).
Use CPANTS - The CPAN Testing Service web site.
Search for the distribution
Click Other dists requiring this
Here is the page for Dist-Zilla
As an aside, you can always read the source by hitting the Source button on the top of the page on search.cpan.org. In this case, the package doesn't have much code to begin with. Also, many big modules these days have ::Cookbooks ::Manuals or ::Tutorials Dist-Zilla has one too
My guess is ::Tester just supplies the dzil test command through its test_dzil sub.
One option is to use Google Code Search (Google for that phrase for a link :) ); unioned with pure googling. Search for "use my::module::name" string.
If the module name is not something well-searchable (e.g. too many hits), may be combine with "
For searches over CPAN, I suggest CPAN Grep over Google code search.
For more complex searches, I'd write a very small program using CPAN::Visitor and a minicpan.
For quick dependency checking, I'd use the not-perfect-but-very-good CPANDB.

GOLD Parse, how do you actually implement your code?

I am not quite sure how to implement my the code after generating the skeleton. I didnt use const only, i do have main files and i tried several c(++) versions along with c# and still i dont understand. I dont think any of them can load a file and parse test files (i know gold builder can parse my test files).
The Kessels C skeleton looks complete. Buts not, it uses a struct and members (Token->Reduction->TokenStack) yet when i search TokenStack i cant find a place where it is defined, only used. I feel like i am missing something. I cant find Kessels other code anywhere.
My question is how do i implement my body? (is there another skeleton you prefer), are there any other downloads i overlooked? i tried looking at these downloads but i didnt understand what to do with them. It also looked more like example source code then a template http://www.devincook.com/goldparser/engine/c/index.htm
PS: I wouldnt mind doing a C# implementation, i am better with c(++).
I've used the Calitha C# Engine. Let me know (by posting a comment to this answer) if you still want an answer, which I can answer using my knowledge of this C# engine.
My question is how do i implement my body? (is there another skeleton you prefer), are there any other downloads i overlooked?
The Calitha Engine download includes source for the Engine, and a sample program (named "TextCalc") which illustrates using it.

How do I create graphs in Perl on Windows?

How do I use Perl to create graphs?
I'm running scheduled job that creates text reports. I'd like to move this to the next step (for the management) and also create some graphs that go along with this. Is this possible / feasible? It'd be great if I could do this using Office some how.
update: solutions i'm going to investigate in this order
Spreadsheet::WriteExcel (this seems to now have changed from the last time i investigated this .... wait, this was suggested by the author of the module. cool.)
GD Graph - this is now available for ActivePerl(wasn't last time i looked)
SVG
Open Charts look interesting.
Chartdirector
GD and GD::Graph are probably your best bets, you can use them to create images that you can then embed into whatever you need.
All of the methods mentioned above are really good, but personally I like SVG::TT::Graph. I really like the power that SVG gives you to draw really nice-looking graphs.
Also you can take a look at Google Charts CPAN module
use Google::Chart;
my $chart = Google::Chart->new(
type => "Bar",
data => [ 1, 2, 3, 4, 5 ]
);
print $chart->as_uri, "\n"; # or simply print $chart, "\n"
$chart->render_to_file( filename => 'filename.png' );
At work we have used the excellent Chartdirector.
It's not free, but is very cheap (maybe 50 bucks or so). The cost is well worth it, as the API and docs are both excellent (way better than GD!), so easily saved more than that amount of my time.
There's also a free version, which includes a small yellow banner advertising the product on each chart - to be honest if this is for personal use, you can go for that as it's really not very intrusive at all.
Chartdirector is available for lots of platforms (Win, Linux, Solaris, BSD, OSX) and has an API for lots of languages, too (Perl, ASP, .NET, Java, PHP, Python, Ruby, C++).
The output is easy on the eye, as you can see at their examples page.
Sorry for blowing my own trumpet, but you might be interested to have a look some slides I did for a short presentation about Graphing With Perl.
It mentions some of the suggestions here, but also gives you some code snippets that you might be able to use to help you get the most of what you're doing.
Depending on the complexity of your graph, simply generating a command file for Gnuplot—or GraphViz/Dotty, depending on what kind of graph you are referring to—might do the trick?
The Perl module Spreadsheet::WriteExcel allows you to create Excel workbooks that include charts.
You first have to create the type of chart that you want in Excel and then extract it out using a utility called chartex which is installed with Spreadsheet::WriteExcel.
The chart template can then be added to a new workbook and made to reference new data.
The documentation is here and there are several examples in the charts directory of the distro.
The mechanism is a little inflexible however and the it is sometimes tricky to get the exact result that you want.
Haven't tried it yet but Chart::Clicker looks quite nifty.
I think it uses the Cairo graphic library (alternative to GD) but is actually built on top of Graphics::Primitive which is an "interesting" graphics agnostic package.
The author in question (GPHAT) seems to be putting together some integrated tools for producing reports... http://www.onemogin.com/blog/582-pixels-and-painting-my-recent-cpan-releases
On a side note... have used both ChartDirector and OFC and both are good (especially if web based).
Spreadsheet::WriteExcel::Chart
You might need something like strawberry or vanilla Perl to get this to compile. Or PPM might have the module.
Tutorial link:
http://search.cpan.org/dist/Spreadsheet-WriteExcel/charts/charts.pod
It won't work with Office, but I really like Chart::OFC which will create Open Flash Charts. Very slick looking and easy to use.
It depends to a great extent what sort of graphs (the look of them), and the data-source. I've had some good result by using the YUI Charts and feeding them some JSON style versions of the original source data. Rolling over a live chart for exact values is quite easy for example. There are plenty of examples on the developer pages.
If you're set on doing this in MS Office you can use the Win32::OLE module to control Excel via OLE. Be warned, that this tends to run slowly and it can be difficult to find documentation for Excel's API. On the plus side, it allows you to do pretty much everything that you can do manually.
Metaprograming of course! Output an R script that creates the graph.
PGPlot does great graphs. There are some examples here. It works fine with Perl 5.8.8 but is broken in 5.10.0
Spreadsheet::WriteExcel will let you just get the data into Excel, then write Excel equations for the graphs.