Hi
Thanks for your previous advice.
As a first test I tried to use the example form_text.java to add text to a
existing pdf document.
I extracted the first page from the PDFReference an added the textfied and
it worked just fine.
When I tried to do tha same with my scanned forms as the base pdfs the
textfield I added did not show.
No exceptions was thrown. Any Ideas about this? Is it possible my base pdfs
are broken in some way?
thanks
/Martin Abrahamsson
---- snip
PdfReader reader = new
PdfReader("d:\\Dev\\pdf\\magic\\lakarutlatande_ht.pdf");
// PdfReader reader = new PdfReader("d:\\Dev\\PDFReference.pdf");
Rectangle psize = reader.getPageSize(1);
Document document = new Document(psize, 50, 50, 50, 50);
float width = psize.width();
float height = psize.height();
PdfWriter writer = PdfWriter.getInstance (document, stream);
document.open();
PdfContentByte cb = writer.getDirectContent();
PdfImportedPage page = writer.getImportedPage(reader, 1);
cb.addTemplate(page,1,0,0,1,0,0);
BaseFont helv = BaseFont.createFont("Helvetica", "winansi",
false);
cb.moveTo(0, 0);
String text = "Some start text";
float fontSize = 12;
Color textColor = new GrayColor(0f);
PdfFormField field = PdfFormField.createTextField(writer, false,
false, 0);
field.setWidget(new Rectangle(171, 750, 342, 769),
PdfAnnotation.HIGHLIGHT_INVERT);
field.setFlags(PdfAnnotation.FLAGS_PRINT);
field.setFieldName("ATextField");
field.setValueAsString(text);
field.setDefaultValueAsString(text);
field.setBorderStyle(new PdfBorderDictionary(2,
PdfBorderDictionary.STYLE_SOLID));
field.setPage();
PdfAppearance tp = cb.createAppearance(171, 19);
PdfAppearance da = (PdfAppearance)tp.getDuplicate();
da.setFontAndSize(helv, fontSize);
da.setColorFill(textColor);
field.setDefaultAppearanceString(da);
tp.beginVariableText();
tp.saveState();
tp.rectangle(2, 2, 167, 15);
tp.clip();
tp.newPath();
tp.beginText();
tp.setFontAndSize(helv, fontSize);
tp.setColorFill(textColor);
tp.setTextMatrix(4, 5);
tp.showText(text);
tp.endText();
tp.restoreState();
tp.endVariableText();
field.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, tp);
writer.addAnnotation(field);
document.close ();
---- snip
-----Ursprungligt meddelande-----
Fr�n: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Leonard
Rosenthol
Skickat: den 24 juli 2003 22:23
Till: Matt Benson; Martin Abrahamsson;
[EMAIL PROTECTED]
�mne: Re: [iText-questions] Acro form in existing pdf
At 12:54 PM -0700 7/24/03, Matt Benson wrote:
>What would be the difference between these two
>approaches regarding the database data:
>
>1) Add the data as precisely-positioned text.
>2) Add precisely-positioned data fields and populate.
>
Performance and typography. #1 will be faster and supports
all of the typographical features of iText (kerning, arabic shaping,
font/style selection etc.). #2 will limit you to Acrobat form fields
and their restrictions - unless you want to deal with flattening...
Leonard
--
---------------------------------------------------------------------------
Leonard Rosenthol <mailto:[EMAIL PROTECTED]>
Chief Technical Officer <http://www.pdfsages.com>
PDF Sages, Inc. 215-629-3700 (voice)
215-629-0789 (fax)
-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions
N�HS^�隊[)�{(��[�Z�z��n襴�4D��w%�ا�6�i���l�&���x�+��ljwE������j�����zz0�'�����Zɩ�z{^��0�v�\���b��J��DNm��ڲ��brK���&�
?�ƴ�]4�Mڽ�݊����Z��N��M���5�7�����ب�ɚ�X��X��$��ڮz�b�{%��l���q���z�m��?�X���(��~��zw��X�����b��?�ױ����ب�