• ios 代码生成绘制 pdf 小技巧


      绘制的整个过程      

      UIGraphicsBeginPDFPage();//创建一个空白页

       CGContextSetTextMatrix(pdfContext, flip);//为上下文设置仿射矩阵

            CGContextBeginPath(pdfContext); // 打开上下文 开始绘制

     

    CGFloat height=50;

     NSString*  textContent=[NSStringstringWithFormat:@"绘制第一个PDF"];

    NSString *  width=[self getfontwidth:textContent fontsize:20];

      int     font=[UIFontfontWithName:@"Arial-BoldMT"size:20];

    [textContent drawAtPoint:CGPointMake((612-width)/2, height) withFont:font];

     

    //获得字符串宽度

    -(CGFloat)getfont(NSString *)string fontsize:(int)fontsize{

        UIFont *font=[UIFontsystemFontOfSize:fontsize];

        CGSize size=[string sizeWithFont:font];

        return size.width;

    }

    1. 另起一页

     UIGraphicsBeginPDFPage(); // 就ok了

     2. 绘制一条线

            //set the path of the line that we will draw

            //起始点

             CGContextMoveToPoint(pdfContext, 50, height);//当前上下文移动到固定的一点(起始点)

            //结束点

                        CGContextAddLineToPoint(pdfContext, 612-50, height);// 在上下当前图层上下文的坐标点绘制一个直线结束点)

                       //绘制 线

            CGContextStrokePath(pdfContext);

  • 相关阅读:
    OpenCV 使用FLANN进行特征点匹配
    OpenCV 特征描述
    OpenCV 特征点检测
    OpenCV 亚像素级的角点检测
    OpenCV Shi-Tomasi角点检测子
    OpenCV Harris 角点检测子
    OpenCV 模板匹配
    OpenCV 直方图计算
    OpenCV 直方图均衡化
    OpenCV 仿射变换
  • 原文地址:https://www.cnblogs.com/zander/p/2670045.html
Copyright © 2020-2023  润新知