Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to insert <</Type/Annot into a pdf programmatically.

172 views
Skip to first unread message

John E.

unread,
Oct 13, 2005, 2:33:38 PM10/13/05
to
I am writing an in-house program in C#.NET that takes a .tiff and converts
it to .pdf. Using either ImageMagick/Ghostscript or iTextSharp I can do the
conversion. However, the problem is that I have to add a special
text/annotation in the pdf header. The header in the .pdf file (if opened
in notepad) should look like this when I am finished:

<</Type/Annot

/MyStuff <<

/Label (id)

/AnotherLabel (id)

>>

Currently, the only way I have been able to do it is via
imagemagick/ghostscript as such:

. convert tiff -> postscript via imagemagick/ghostscript

. add the following text to the .ps file: [ /MyStuff << /Label (id)
/AnotherLabel (id) >> /ANN pdfmark
. convert the ps -> pdf via imagemagick/ghostscript

I am trying to get rid of the postscript step, it seems excessive and
clunky(?)

I have been able to do it via iTextSharp Annotation method but the format
ends up all wrong. When I open the ending .pdf file it looks like:

"<</Subtype/Text/Contents(this is my blurb)/T(myTitle)/Rect[36 788 56
768]>>"

...which doesn't work for what I need.

Does anyone know of a .NET compatible application that is capable of doing
this conversion without having to first go to postscript and manually adding
text? Am I missing something in ImageMagick or iTextSharp? Or, is there a
better utility do accomplish this conversion with the appended text
information? Something that can be programmatically accessed...not command
line or gui only.

Any help would be appreciated, as I am a c# developer, and pdf/ps is not my
area of expertise, so I am kind of at a loss as to my possible options.

TIA,

-John.


Paulo Soares

unread,
Oct 13, 2005, 5:14:43 PM10/13/05
to
That's quite easy in itextsharp if you use the latest CVS version:

PdfAnnotation annot = new PdfAnnotation(writer, null);
annot.Put(PdfName.TYPE, PdfName.ANNOT);
PdfDictionary dic = new PdfDictionary();
dic.Put(new PdfName("Label"), new PdfString("id"));
dic.Put(new PdfName("AnotherLabel"), new PdfString("id"));
annot.Put(new PdfName("MyStuff"), dic);
writer.AddAnnotation(annot);

Best Regards,
Paulo Soares

xiaoyuandlg

unread,
Oct 10, 2014, 4:44:50 PM10/10/14
to
This must be good reference to see, I know it is about code for barcode .jpg file convertion in c#.net


http://www.businessrefinery.com/integration/csharp/barcode.html


0 new messages