|
|
how to insert <</Type/Annot into a pdf programmatically.
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.
|
|
0
|
|
|
|
Reply
|
John
|
10/13/2005 6:33:38 PM |
|
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
John E. wrote:
> 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.
|
|
0
|
|
|
|
Reply
|
Paulo
|
10/13/2005 9:14:43 PM
|
|
|
1 Replies
700 Views
(page loaded in 0.12 seconds)
|
|
|
|
|
|
|
|
|