PDF Text Annotation Style Apply - java

I am new to PDFBox API. I would like to apply text annotation(AirPassengers) style like below marked in red box.
I am using PDF box API. I am creating text annotation as shown below.
PDAnnotationTextMarkup txtMark = new PDAnnotationTextMarkup(PDAnnotationTextMarkup.SUB_TYPE_FREETEXT);
This will result in Simple Text Annotation without any Style or background color. I would like to achieve the style as shown in screenshot. Anybody has any idea to achieve this.

Do this:
txtMark.setColor(new PDColor(new float[] { 0, 1, 1 }, PDDeviceRGB.INSTANCE));
this sets the color you mentioned (#00FFFF). In Adobe Acrobat, colors are between 0 and 1 and not between 0 and 255. Be aware that the annotation will be visible in Adobe Reader, but at this time not in PDFBox rendering or PDF.js rendering because the Appearance Stream is missing (see my comment in your previous question).

Related

BIRT vertical text in excel output

I would like to make vertical text in excel output. I am currently using BIRT 4.2.2 with nativexls. I pasted vertical text as .svg image into table header cell but the output looks strange. There is an image with no border around the cell. Is there another way to accomplish this?
output:
image
Again, I'm not familiar with BIRT or nativexls, but you can quite easily specify that a cell has vertical alignment in Excel itself.
On the Cell Formatting screen, set the Alignment to 90 degrees:
This will give you the result you need:
Again, I'm not familiar with the other technologies you're using, so my apologies if this is not helpful (i.e., if you can't adjust the formatting from your workflow). Of course, if you're working with the raw Excel file, you should be update to update the XML files contained within the XLSX container to use the formatting you need.

iText incorrectly renders custom lato font

To register my custom lato font I use this method: PdfFontFactory.register. Afterwards I print out all fonts to verify it gets registered.
Then I use the font like so
setFont(PdfFontFactory.createRegisteredFont("lato-regular"))
However there are very subtle differences in the display using the same ttf file on my website vs my pdf.
For example, the dot above the "i" is not circular but more of a rectangle with rounded edges when using iText. Any ideas?

Change font color in StaticNote of PDFClown

Referring to Build text callout with PDF Clown - Is there a possibility to change the font color of the text within the callout note?
I haven't found a suitable method yet, can someone please give me a hint?
There is no explicit PDF Clown method to set the text color. This might be related to the fact that there is no explicit entry in the PDF annotation dictionary for it either.
There are two options, though:
There is a default appearance (DA) entry for variable text in annotations in general. As PDF Clown does not hide generic object methods, you can extend the original callout sample like this:
// Callout.
composer.showText("Callout note annotation:", new Point(35, 85));
new StaticNote(
page,
new Rectangle(250, 90, 150, 70),
"Text of the Callout note annotation"
).withLine(
new StaticNote.CalloutLine(
page,
new Point(250,125),
new Point(150,125),
new Point(100,100)
)
)
.withLineEndStyle(LineEndStyleEnum.OpenArrow)
.withBorder(new Border(1))
.withColor(DeviceRGBColor.get(Color.YELLOW))
.getBaseDataObject().put(PdfName.DA, new PdfString("1 0 1 rg /Ti 12 Tf"));
You have to use plain PDF instructions there, though, rg sets a RGB color defined by the three preceding values, and Tf sets font and size according to the preceding two values. The result of the above is:
As you see, the text now is purple (red 100%, green 0%, blue 100%). A side effect is, though, that the callout line and the frame around the callout box also are purple.
Alternatively a PDF can bring along an own appearance stream defining the whole appearance of the annotation in question. This means, though, that you really have to draw everything yourself including lines, frames, backgrounds, and text.
PDF Clown allows you to set the appearance of an annotation using the setAppearance and withAppearance methods.

Creating a PDF with itext, embedding an animation with buttons

I'm trying to create a PDF using iText library. The PDF has to embed an animation, which is a set of bitmaps. And there are buttons to control the animation. To understand it, see the following file:
http://www.texample.net/media/tikz/examples/PDF/wankel-motor.pdf
How can I create such a file from iText?
I know that I can embed a video file with this code:
http://itextpdf.com/examples/iia.php?id=188
But here I don't want to embed a video file, but a set of bitmaps and to add the control buttons.
Thanks in advance,
V. Henley
The document doesn't have any images. Instead it has a large series of Widget annotations inside a rectangle of which the lower-left and upper-right corners have the following coordinates:
llx = 4.981
lly = 287.238
urx = 322.053
ury = 542.754
These widget annotations are buttons that overlap each other and of which the appearance is defined using PDF syntax (paths consisting of straight lines and Bézier curves).
There are also a number of smaller buttons with arrows and other symbols. When clicking them, some JavaScript is executed:
The animations is actually JavaScript alternating the visibility of the different buttons. If you want to know more about the JavaScript that is used, you have to dig into the document using iText RUPS (which is what I did to create the above screen shot).
The principle that is used to create this PDF is identical to the principle that was used in the Calculator example, which is an example that was distributed with the same book you refer to.
Finally, I've been able to create such a PDF using latex code:
This is the latex code:
\documentclass[10pt]{article}
\usepackage{animate}
\usepackage{graphicx}
\usepackage{media9}
\pagestyle{empty}
\begin{document}
\AtEndDocument{%
\label{lastpage}%
}
\animategraphics[width=9.54cm,height=6.36cm,controls]{2}{C:/Users/casa/Documents/programacion/tex/construc_}{0}{3}
\end{document}
So after compiling such code with a latex compiler, it produces a pdf similar to the one I posted.
Kind Regards

Transparent images are showing up as black boxes after xfa.fillXfaForm. Are transparent images supported for the xfa fill?

Here's the current problem:
I have an XFA Form created by a 3rd party and I would like to use it as is.
I was able generate the PDF with filled fields by:
a) Extracting the XML via Acrobat Pro
b) filling the fields within the XML and calling
XfaForm xfa = form.getXfa();
xfa.fillXfaForm(new FileInputStream(XML));
What I'm trying to do is just stamp an image/watermark over the 2nd page which has a form w/multiple fields. The "DRAFT" png image I'm stamping has a transparent background so if the overlay works, the image background should make the underlay appear and look like that the image text is sitting on top of the pdf page.
What I wanted to accomplish would have been trivial if this was not an XFA form. I would just use iText's pdfStamper and stamp this transparent PNG over the 2nd page, but since I'm now confined to use Adobe LiveCycle Designer, I noticed that this once trivial task in the non XFA document isn't so trivial within XFA.
From a previous post, I learned that I couldn't mix technologies together. I had to choose between nonXFA (AcroForms) vs XFA (built by Adobe LiveCycle Designer). Basically, I couldn't do a fillXFA then use the stamper, so I had to figure out how to do this using XFA.
I've tried the following steps as a static PDF and a dynamic PDF....it didn't make a difference what type the PDF was.
1) Within Adobe LiveCycle Designer, I went to the second page of the source PDF and defined 2 image fields.
overlay1 - this will span the top portion width of the page which has text
content underneath
overlay2 - this will span the lower portion width of the page which has text
content underneath
2) As a test...I selected an image for overlay1 which has a transparent background and it's
foreground background as DRAFT
At design time...the DRAFT transparency image worked and it was laid on top of the content correctly
for the imageField: overlay1.
I saved the modified XFA-based PDF, opened it up in Acrobat Pro, and exported the XFA XML structure.
I verified that overlay1 had the DRAFT image as a base64 encoded string.
<overlay1 xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:contentType="image/png"
>iVBORw0KGgoAAAANSUhEUgAACWAAAAJYCAYAAADmY91UAAAACXBIWXMAAC4jAAAuIwF4pT92AABH
.......
.......
3) When I took the same base 64 string and only entered it's content within overlay2 and rendered it through the fillXFA method...the image was a black box instead.
I also opened the file in Acrobat Pro, then double clicked on the imageField area, selected the transparent image, and it still showed up as a black box.
I repeated the previous step with an image w/no transparency and it's rectangular white background
overlayed everything underneath it.
4) I went ahead and made another image...one that didn't have any transparency.
DRAFT with no transparency and it's background is white.
I had it encoded in base64 format.
I was able to place it within both overlay1 & overlay2 image fields without any problems.
The new problem is that the white background of the DRAFT images covered everything behind it.
Why did the initial transparent png work during the Adobe LifeCycle Design (design time) and after
a fillXFA call it shows up as a black box? But if I change the image to not use transparency at
all...everything works?
Does XFA not support transparent images for image fields during an xfa fill? Remember, it worked during
design time when I told Adobe LiveCycle designer to use this transparent png for this field.
I'm basically trying to create 2 image watermarks over a specific page within an XFA pdf.
My current backup plan is to flatten the PDF (take off the XFA) and putting back all the fields back on the form using Acrobat Pro and filling it using the standard PDF itext calls and using a stamper (this is going to be tedious since there's a bunch of fields). But I'd like to know if anyone ever had to do the same w/an XFA PDF form before I look at option B.
So I replaced the same PNG transparent image with a GIF transparent image. The GIF image encoded in base64 worked. I can create a new GIF file w/transparency, encode it in base64, and replace the previous one & it still worked. Looks like a bug with PNG rendering within the XFA form

Categories