2005年10月11日

没有特别原因,将不在对这个网站做更新

可以访问我的新blog

http://hardrock.cnblogs.com/

英文博客请访问

http://blog.rubypdf.com

软件下载请访问

http://soft.rubypdf.com

 

2005年08月28日

因为空间的问题,我上传到http://hardrock.cnblogs.com上了

下载路径为http://hardrock.cnblogs.com/Files/hardrock/iTextSharp.tutorial.zip

介绍参考http://hardrock.cnblogs.com/archive/2005/08/28/224200.html

因为工作的关系,iTextSharp tutorial的翻译工作只好暂时搁浅。

2005年08月19日

经过近一个星期(利用早晨的时间)调试了http://itextsharp.sourceforge.net/tutorial/下所有教程,总计111个程序(多数还没有来得及研究,只是调试通过,正确输出结果),除了Chap0908(没有PdfBarcode类,无法测试),并另外又补充了10个没有被收录的程序(来自iText的教程,补充工作继续中)。

测试的同时发现了iTextSharp的2个bug,其中一个在最新版本已经修改过来了,还有一个是我今天刚提交的。

另外添加了对STSong-Light这类字体的支持,这样对PDF的Form填写也可以方便实现了。

http://switch.dl.sourceforge.net/sourceforge/itextsharp/itextsharp-3.0.6.zip

http://switch.dl.sourceforge.net/sourceforge/itextsharp/itextsharp-3.0.6-dll.zip

Changes in iTextSharp 3.0.6 (2005-08-18) 
 
- constructor Image(Image) didn’t copy one of the fields 
 
- Image.ScaledToFit() didn’t take rotation into account 
 
- Table.Width was not being overriden. The result was an exception in PdfDocument 
 
- added BaseFont.CorrectArabicAdvance() to make Arabic Diactrics (tashkeel) 
have zero advance. Some Microsoft fonts like Arial.ttf have non-zero advances 
that confuse the Arabic shaper. 
 
- in PdfDocument the waiting image in the last page was not being placed 
 
- PdfString didn’t output the BOM in Unicode 
 
- PdfStamper supports encryption in append mode 
 
- added verbose analysis of the permissions in PdfEncryptor 
 
- fixed a conversion bug in PdfPCell.NoWrap 
 
- PdfReader.SelectPages() is working again 
 
- PdfWriter.PrintScalingNone had the wrong value 
 
- fixed a conversion bug in SimpleBookmark.IterateOutlines() 
 
- MultiColumnText didn’t respect mirrored margins 
 
- in RTF added the option for chars above ‘z’ to not be encoded in Unicode 
to support older Word versions 

测试例子(翻译自Chap13_form.java程序,已经成功转为Chap13_form.cs,iTextSharp中没有收录这个iText下的教程代码):
            String[,] colorvalues = {{"#FF0000", "Red"}, {"#00FF00", "Green"}, {"#0000FF", "Blue"}};

            acroForm.AddSelectList("list2", colorvalues, "#0000FF", helv, fontSize, 315, 550, 450, 600);
            acroForm.AddComboBox("combo2", colorvalues, "#0000FE", false, helv, fontSize, 315, 440, 450, 490);

出错:System.IndexOutOfRangeException

AddComboBox的bug比较隐蔽,除非你故意把defaultValue输为colorvalues 数组中不存在的值,否则不会导致错误抛出。

public PdfFormField AddComboBox(string name, string[,] options, string defaultValue, bool editable, BaseFont font, float fontSize, float llx, float lly, float urx, float ury) {
        PdfFormField choice = PdfFormField.CreateCombo(writer, editable, options, 0);
        SetChoiceParams(choice, name, defaultValue, llx, lly, urx, ury);
        string value = null;
        for (int i = 0; i < options.GetLength(0); i++) {//Steven Lee 20050819,原来为options.Length
            if (options[i, 0].Equals(defaultValue)) {
                value = options[i, 1];
                break;
            }
        }
        if (value == null) {
            value = options[0, 1];
        }
        DrawSingleLineOfText(choice, value, font, fontSize, llx, lly, urx, ury);
        AddFormField(choice);
        return choice;
    }

public PdfFormField AddSelectList(string name, string[,] options, string defaultValue, BaseFont font, float fontSize, float llx, float lly, float urx, float ury) {
        PdfFormField choice = PdfFormField.CreateList(writer, options, 0);
        SetChoiceParams(choice, name, defaultValue, llx, lly, urx, ury);
        StringBuilder text = new StringBuilder();
        for (int i = 0; i < options.GetLength(0); i++) {//Steven Lee 20050819,原来为options.Length
            text.Append(options[i, 1]).Append("\n");
        }
        DrawMultiLineOfText(choice, text.ToString(), font, fontSize, llx, lly, urx, ury);
        AddFormField(choice);
        return choice;
    }

2005年08月14日

        今天调试了http://itextsharp.sourceforge.net上第一章的教程,竟然发现多数都无法调试通过(估计是使用转换工具转换过来的),而且主要是方法首字母应该转为大写的问题,当然还有一部份是其他原因,感觉真的不是很爽,花了1个小时的时间把第一章的全部教程都修改了下,现在可以了,方便的时候会传到网上供大家分享。

2005年08月12日

http://gmail.512j.com/soft/Total.Training.For.(Adobe.Acrobat.7.Professional).(Rls.Date-05-18-05).{4CD’s}.A[m]D.torrent

应一些朋友的要求,重新找到这个torrent,感兴趣的话就快些下载吧。

2005年08月11日

今天在调试书签导入的时候发现SimpleBookmark.cs的一处bug(注意对比我红色字体标记部分):

源程序是:

 internal static Object[] IterateOutlines(PdfWriter writer, PdfIndirectReference parent, ArrayList kids, bool namedAsNames) {
            PdfIndirectReference[] refs = new PdfIndirectReference[kids.Count];
            for (int k = 0; k < refs.Length; ++k)
                refs[k] = writer.PdfIndirectReference;
            int ptr = 0;
            int count = 0;
            foreach (Hashtable map in kids) {
                ++ptr;
                Object[] lower = null;
                ArrayList subKid = (ArrayList)map["Kids"];
                if (subKid != null && subKid.Count > 0)
                    lower = IterateOutlines(writer, refs[ptr], subKid, namedAsNames);
                PdfDictionary outline = new PdfDictionary();
                ++count;
                if (lower != null) {
                    outline.Put(PdfName.FIRST, (PdfIndirectReference)lower[0]);
                    outline.Put(PdfName.LAST, (PdfIndirectReference)lower[1]);
                    int n = (int)lower[2];
                    if ("false".Equals(map["Open"])) {
                        outline.Put(PdfName.COUNT, new PdfNumber(-n));
                    }
                    else {
                        outline.Put(PdfName.COUNT, new PdfNumber(n));
                        count += n;
                    }
                }
                outline.Put(PdfName.PARENT, parent);
                if (ptr > 0)
                    outline.Put(PdfName.PREV, refs[ptr - 1]);
                if (ptr < refs.Length – 1)
                    outline.Put(PdfName.NEXT, refs[ptr + 1]);
                outline.Put(PdfName.TITLE, new PdfString((String)map["Title"], PdfObject.TEXT_UNICODE));
                String color = (String)map["Color"];
                if (color != null) {
                    try {
                        PdfArray arr = new PdfArray();
                        StringTokenizer tk = new StringTokenizer(color);
                        for (int k = 0; k < 3; ++k) {
                            float f = float.Parse(tk.NextToken(), System.Globalization.NumberFormatInfo.InvariantInfo);
                            if (f < 0) f = 0;
                            if (f > 1) f = 1;
                            arr.Add(new PdfNumber(f));
                        }
                        outline.Put(PdfName.C, arr);
                    } catch {} //in case it’s malformed
                }
                String style = (String)map["Style"];
                if (style != null) {
                    style = style.ToLower();
                    int bits = 0;
                    if (style.IndexOf("italic") >= 0)
                        bits |= 1;
                    if (style.IndexOf("bold") >= 0)
                        bits |= 2;
                    if (bits != 0)
                        outline.Put(PdfName.F, new PdfNumber(bits));
                }
                CreateOutlineAction(outline, map, writer, namedAsNames);
                writer.AddToBody(outline, refs[ptr]);//这里变成了从refs[1]到refs[refs.Lenght]了,结果自然而知了。
            }
            return new Object[]{refs[0], refs[refs.Length - 1], count};
        }

修改后的程序为:

 internal static Object[] IterateOutlines(PdfWriter writer, PdfIndirectReference parent, ArrayList kids, bool namedAsNames) {
            PdfIndirectReference[] refs = new PdfIndirectReference[kids.Count];
            for (int k = 0; k < refs.Length; ++k)
                refs[k] = writer.PdfIndirectReference;
            int ptr = 0;
            int count = 0;
            foreach (Hashtable map in kids) {                
                Object[] lower = null;
                ArrayList subKid = (ArrayList)map["Kids"];
                if (subKid != null && subKid.Count > 0)
                    lower = IterateOutlines(writer, refs[ptr], subKid, namedAsNames);
                PdfDictionary outline = new PdfDictionary();
                ++count;
                if (lower != null) {
                    outline.Put(PdfName.FIRST, (PdfIndirectReference)lower[0]);
                    outline.Put(PdfName.LAST, (PdfIndirectReference)lower[1]);
                    int n = (int)lower[2];
                    if ("false".Equals(map["Open"])) {
                        outline.Put(PdfName.COUNT, new PdfNumber(-n));
                    }
                    else {
                        outline.Put(PdfName.COUNT, new PdfNumber(n));
                        count += n;
                    }
                }
                outline.Put(PdfName.PARENT, parent);
                if (ptr > 0)
                    outline.Put(PdfName.PREV, refs[ptr - 1]);
                if (ptr < refs.Length – 1)
                    outline.Put(PdfName.NEXT, refs[ptr + 1]);
                outline.Put(PdfName.TITLE, new PdfString((String)map["Title"], PdfObject.TEXT_UNICODE));
                String color = (String)map["Color"];
                if (color != null) {
                    try {
                        PdfArray arr = new PdfArray();
                        StringTokenizer tk = new StringTokenizer(color);
                        for (int k = 0; k < 3; ++k) {
                            float f = float.Parse(tk.NextToken(), System.Globalization.NumberFormatInfo.InvariantInfo);
                            if (f < 0) f = 0;
                            if (f > 1) f = 1;
                            arr.Add(new PdfNumber(f));
                        }
                        outline.Put(PdfName.C, arr);
                    } catch {} //in case it’s malformed
                }
                String style = (String)map["Style"];
                if (style != null) {
                    style = style.ToLower();
                    int bits = 0;
                    if (style.IndexOf("italic") >= 0)
                        bits |= 1;
                    if (style.IndexOf("bold") >= 0)
                        bits |= 2;
                    if (bits != 0)
                        outline.Put(PdfName.F, new PdfNumber(bits));
                }
                CreateOutlineAction(outline, map, writer, namedAsNames);
                writer.AddToBody(outline, refs[ptr]);
                ++ptr;
            }
            return new Object[]{refs[0], refs[refs.Length - 1], count};
        }

主题是PDF的应用与开发以及纺织服装行业信息化。

http://gmail.512j.com/forum

欢迎光临

2005年08月10日

http://soft.rubypdf.com/softwares/pdf-bookmark-extractor

About PDF Bookmark Extractor 1.0

从PDF中提取书签,然后存为xml或者txt,也可以在textBox中显示,需要Microsoft .Net Framework 1.1

Allows extract bookmarks(outlines) from a given PDF
and show it in textBox, save it as XML or txt format.
Supports unicode bookmarks.
Is Free software,any question and suggestion please contract:
steedsoft@gmail.com
http://www.steedsoft.com
http://blog.donews.com/rocsky
Thanks for iTextSharp

notice:
this software need Microsoft .Net Framework 1.1 support,you can get it from
http://download.microsoft.com/download/7/b/9/7b90644d-1af0-42b9-b76d-a2770319a568/dotnetfx.exe