Java 如何使用Rastermaster Snow在图像中插入文本?

Java 如何使用Rastermaster Snow在图像中插入文本?,java,Java,我需要在文件映像中插入文件名。我们正在为此使用RasterMaster Snow API。我知道我们可以使用注释合并在图像中插入文本。但找不到如何使用Snow注释合并图像中的文本的任何帮助。下面是代码片段,但不起作用 它会毫无例外地生成test1.tiff映像,但不会在生成的映像中插入文件名。似乎我没有正确使用snow注释合并功能 try { File source= new File("D:\\rastermaster\\test1.pdf"); File

我需要在文件映像中插入文件名。我们正在为此使用RasterMaster Snow API。我知道我们可以使用注释合并在图像中插入文本。但找不到如何使用Snow注释合并图像中的文本的任何帮助。下面是代码片段,但不起作用

它会毫无例外地生成test1.tiff映像,但不会在生成的映像中插入文件名。似乎我没有正确使用snow注释合并功能

try {

         File source= new File("D:\\rastermaster\\test1.pdf");
         File result = new File("D:\\rastermaster\\test1.tiff");


        Snowbnd snowbnd = new Snowbnd();
        Snow.SANN_RECT sn = new Snow.SANN_RECT();
        sn.left=1200;
        sn.right=1200;
        sn.top=1200;
        sn.bottom=1200;
        Snow.SANN_POINT p1 = new Snow.SANN_POINT();
        p1.x=12;
        p1.y=12;
        Snow.SANN_POINT p2 = new Snow.SANN_POINT();
        p2.x=102;
        p2.y=102;


        Snow.SANN_POINT pn[] = new Snow.SANN_POINT[]{p1,p2};

        int status = snowbnd.IMG_decompress_bitmap(source.getAbsolutePath(), 0);
       // snowbnd.IMGLOW_set_bitmap_name("BT-7208_file_name", "BT-7208");
        //snowbnd.IMGLOW_set_print_header("BT-7208_file_name", "BT-7208",1); snowbnd
        snowbnd.IMGLOW_set_pdf_output((int) PD4Constants.A4.getWidth(), (int) PD4Constants.A4.getHeight());


        SnowAnn sann = new SnowAnn(200, 300);
      //  Sann = new SnowAnn(Simage.getWidth(),Simage.getHeight()); 

      //Set the size and position of the rectangle using 
        sann.SANN_set_croprect(120, 120, 120, 120); 

      //add text using 
        sann.SANN_add_object(3, sn, "file_name".getBytes(), pn, "file_name".length()); 
        //sann.textString="hello";
      //if you wish to view the annotation use 
        //sann.SANN_display_annotations(grp, f, status, status, status, status); 

      //burn the annotation into the file using 
        int status2 =sann.SANN_merge_annotations(snowbnd, null);
        status = snowbnd.IMG_save_bitmap(result.getAbsolutePath(), 16);


        if (status < 0) {
            System.out.println("fail");
        }

        } catch (RuntimeException re) {
            re.printStackTrace();
        } catch (Error err) {
            err.printStackTrace();
        } catch (Throwable t) {
            t.printStackTrace();
        } finally {
        }

我们怎样才能做到这一点呢?

我找到了解决办法。在下面的代码行中

 sann.SANN_add_object(3, sn, "file_name".getBytes(), pn, "file_name".length());
它需要通过13而不是3作为第一个参数

 sann.SANN_add_object(13, sn, "file_name".getBytes(), pn, "file_name".length());
当我们给出一个值3时,它会忽略我们需要插入的objecttext的值,该值被传递为插入。还有Snow.SANN_POINT[]数组的值作为参数传递给SANN.SANN_add_object。。。。。。数组可以为空,至少我不知道它的用途

File source= new File("D:\\demo\\test.pdf");
File result = new File("D:\\demo\\test.tif");
Snowbnd snowbnd = new Snowbnd();
snowbnd.IMGLOW_set_license_path("path of licence");
int status = snowbnd.IMG_decompress_bitmap(source.getAbsolutePath(), 0);
Snow.SANN_RECT sn = new Snow.SANN_RECT();
sn.left=0;
sn.right=600;
sn.top=0;
sn.bottom=20;
SnowAnn sann = new SnowAnn(snowbnd.getWidth(), snowbnd.getHeight());
sann.SANN_set_croprect(0, 0, 200, 600);
sann.ann_font_height=1;
sann.ann_bold=1;
sann.SANN_set_fcolor(0,0,0);
sann.SANN_add_object(13, sn, "file_name".getBytes(), null, "file_name".length());
int status2 =sann.SANN_merge_annotations(snowbnd, null);
status = snowbnd.IMG_save_bitmap(result.getAbsolutePath(), 16);

你能详述一下你对不工作的描述吗?你有错误吗?部分工作正常吗?@halfer,它可以正常工作并生成test1.tiff图像,但它不会在生成的图像中插入文件名。似乎我没有正确使用snow注释合并功能。