iOS开发之Quartz2D生成PDF-Part2

工业排程中遗传算法落地的四大支柱与12个实战陷阱 遗传算法作为经典启发式优化方法,其核心原理在于模拟自然选择过程实现解空间搜索,但在实际工业场景中,简单套用标准框架极易遭遇早熟收敛、非法解泛滥、结果不稳定等工程瓶颈。本文聚焦产线柔性排程这一典型离散优化问题,深入解析如何通过重构选择策略、工艺感知交叉、邻域导向变异及分层动态适应度函数,系统性提升算法鲁棒性与可解释性。内容深度融合种群多样性控制、硬软约束协同建模等关键技术,并覆盖冷启动、数据噪声、人机协同等真实部署盲区,为智能制造领域算法工程师提供可复用、可验证、带油渍味的GA工程化实践指南。 阅读详情

iOS开发之Quartz2D生成PDF-Part2

在上一节当中,我们创建了一个基于Quartz2D的PDF,并在PDF中添加一线条。
在这一节,主要是添加一个logo,和绘制一个table。

下载图片资源,然后添加到工程当中。

在`PDFRenderer.m`文件中添加下面方法:
//绘制图像
+ (void)drawImage:(UIImage*)image inRect:(CGRect)rect {
    [image drawInRect:rect];
}

在PDFRenderer.h中添加下面方法:

+ (void)drawImage:(UIImage*)image inRect:(CGRect)rect;

为了能在PDF上显示此logo,在PDFRenderer.m的drawPDF方法中添加下面代码,此代码写在UIGraphicsEndPDFContext();之前:

UIImage *logo = [UIImage imageNamed:@"ray-logo"];
    CGRect frame = CGRectMake(20, 100, 300, 60);
    [PDFRenderer drawImage:logo inRect:frame];

在上面的代码中,创建一个UIImage对象,并定义图像的位置和大小,调用drawImage方法将两个参数传过去进行绘制。

完整代码如下:

+ (void)drawPDF:(NSString*)fileName {
    UIGraphicsBeginPDFContextToFile(fileName, CGRectZero, nil);
    UIGraphicsBeginPDFPageWithInfo(CGRectMake(0, 0, 612, 792), nil);

    CGPoint from = CGPointMake(0, 0);
    CGPoint to = CGPointMake(200, 300);
    [PDFRenderer drawLineFromPoint:from toPoint:to];

    UIImage *logo = [UIImage imageNamed:@"ray-logo"];
    CGRect frame = CGRectMake(20, 100, 300, 60);
    [PDFRenderer drawImage:logo inRect:frame];

    [self drawText];

    UIGraphicsEndPDFContext();
}

至此了解到如何绘制清单的基本元素:文本、线条、图片。接下来将运用这些所有元素构建更为完美的布局。

绘制Labels

创建一个xib,并命名为InvoiceView,选中InvoiceViewIB,设置View的width: 612 和height: 792,这些都是A4PDF的默认尺寸。下面拖拽8个UILabel,并按如下命名:

  • Recipient [Name]
  • Recipient’s Address
  • Recipient’s City
  • Recipient’s Postal Code
  • Invoicer [Name]
  • Invoicer’s Address
  • Invoicer’s City
  • Invoicer’s Postal Code

这些labels的位置将会在PDF上进行布局。给每个label从0-7设置tag。例如:Recipient的tag是0,Recipient’s Address的tag事1,以此类推。

打开PDFRenderer.m文件,并重构drawText方法。代码清单如下:

+(void)drawText:(NSString*)textToDraw inFrame:(CGRect)frameRect {

    CFStringRef stringRef = (__bridge CFStringRef)textToDraw;
    CFAttributedStringRef currentText = CFAttributedStringCreate(NULL, stringRef, NULL);
    CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString(currentText);

    CGMutablePathRef framePath = CGPathCreateMutable();
    CGPathAddRect(framePath, NULL, frameRect);
    CFRange currentRange = CFRangeMake(
Quartz2.2.1存储与持久化-基于Spring的配置 Quartz2.2.1存储与持久化-基于Spring的配置 ,具体效果与过程请看博文http://blog.youkuaiyun.com/evankaka/article/details/45556207 立即下载

相关推荐

Quartz.pdf

quartz中文文档,易懂且齐全,该文档包括quartz的使用,Trigger说明,job并发,spring整合quartz以及持久化相关的知识,相对网上看到的文档来说,更容易上手和入门

Quartz Job Scheduling Framework 中文版 V1.0.0.pdf

本人译作,在先前那个 Quartz Job Scheduling Framework_V1.0.0.CHM 文件的基础上做成的 PDF 文件,方便大家阅读。

《Quartz开发指南》pdf

通过代码及实例详细介绍Quartz开发,pdf的,包括基本的Jobs and Triggers ,和集群模式下的事务处理以及其他的高级特性。

Quartz2.2版本开发手册(JAVA).pdf

Quartz是一个功能丰富的,开源的作业调度库,可以在几乎任何Java应用程序集成-从最 小的独立的应用程序,以最大的电子商务系统。 Quartz可以用来创建简单或复杂的调度执行几十,几百,甚至是数万名成千上万的就业机会;jb被定义为标准的Java组件可以执行几乎任何你可以编程他们做。 Quartz调度包括了许多企业级特性,如JTA事务和集群支持。 Quartz是可自由使用的,基于 Apache2.0许可协议发布。

Quartz如何从入门到精通.pdf

Quartz如何从入门到精通

quartz最全文档

quartz最全文档,虽然版本比较老,但是十分全面,可以配合官方例子看

Quartz框架快速入门.pdf

Quartz框架快速入门.pdf

人工势场法在自动驾驶避障中的实践与优化

本文深入探讨了人工势场法在自动驾驶避障中的核心原理与实践优化。通过解析引力与斥力模型,揭示了经典算法在局部最优和目标不可达等问题上的局限性,并重点介绍了改进斥力场函数、引入道路边界斥力及动态参数调整等关键优化策略,有效提升了该局部路径规划算法在复杂动态场景下的实用性与鲁棒性。

weixin_29208327的博客 927

从逻辑门到RISC-V指令:ALU设计实战与Verilog实现

本文详细介绍了从逻辑门到RISC-V指令集的ALU设计实战与Verilog实现方法。通过构建1位ALU并扩展至64位,深入解析了RISC-V指令集的算术逻辑单元实现技巧,包括加法器设计、零标志检测和溢出检测等关键功能。文章还分享了Verilog代码优化、流水线设计和常见问题调试的实用经验,为开发者提供了一套完整的ALU设计解决方案。

weixin_29214335的博客 185

用CentOS 7安装cadence搭建适合IC Design的科研环境(四)——IC617、MMSIM151、calibre2015安装过程step by step

以下操作都在root权限下执行。建立安装目录建议把这种大型软件装在/opt目录下。mkdir -p /opt/cadence/installscape mkdir -p /opt/mentor/Calibre2015其中-p参数是直接建立父目录。因为IC617和MMISM151会自己建立安装目录,所以在这里没有建相关目录。而calibre则是默认安装在安装包所在的目录下,所以需要提前建立。解压安

maxwell2ic的博客 7万+

第二章 HART硬件设计实战 — 基于SD2057的低功耗调制解调器电路详解与选型指南

本文详细解析了基于SD2057芯片的HART协议低功耗调制解调器硬件设计。通过对比分析,阐述了SD2057在成本与性能上的优势,并重点拆解了其核心电路、外围元件选型、原理图绘制要点及PCB布局的实战技巧,为工业现场仪表的智能通信模块开发提供了完整的低功耗解决方案。

gan8painter的博客 423

力扣(Leetcode)第1题:两数之和(C语言版本)

题目: 给定一个整数数组 nums 和一个整数目标值 target,请你在该数组中找出和为目标值 target 的那两个整数,并返回它们的数组下标。 你可以假设每种输入只会对应一个答案。但是,数组中同一个元素在答案里不能重复出现。 你可以按任意顺序返回答案。 示例 1: 输入:nums = [2,7,11,15], target = 9 输出:[0,1] 解释:因为 nums[0] + nums[1] == 9 ,返回 [0, 1] 。 示例 2: 输入:nums = [3,2,4], target = 6

qq_39855356的博客 3308

【安全机制分析案例】从PDF预览页面提取原始PDF文件的方法原理与实践 篇二:基于致远互联(Seeyon)封装的SuwellLightRead技术

该HTML代码片段展示了致远OA协同办公系统的前端页面结构,包含多个CSS样式表和JavaScript文件的引用。页面设置了IE兼容模式,加载了全局环境变量、UI组件库和公告模块相关资源。代码中定义了系统路径、静态资源后缀等全局变量,并包含公告查看功能的相关配置参数。页面还引用了水印、文档处理、即时通讯等功能的JS文件,并设置了文件下载框架。整体呈现了一个典型的OA系统前端实现方案,包含浏览器兼容处理、资源加载和功能模块初始化等逻辑。

生活在别处 2074

Yocto系列讲解[入门篇]36 - 编译arm虚拟机qemuarm

玩一下qemuarm,因为之前用的x86架构

fulinux的博客 2571

医疗影像配准与融合: 使用MATLAB对医学影像进行配准和融合,实现不同影像模态之间的对准和结构信息融合等

医疗影像配准与融合是医学影像处理的重要技术,它用于将不同来源、不同时间或不同模态的医学影像进行配准和融合,以获得更加完整、准确的患者解剖信息。基于MATLAB的医疗影像配准与融合可以帮助医生更准确地诊断疾病,制定更有效的治疗方案。医疗影像配准与融合是医学影像处理的关键技术,它对于提高医学影像诊断和治疗的准确性至关重要。MATLAB是一种功能强大的数学和科学计算软件,它可以为医疗影像配准与融合提供强大的工具和支持。

走向CTO的路上... 713

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

上一篇: iOS开发之Quartz2D生成PDF-Part1
下一篇: 初探SocialFramework和UIActivityViewController
Cola-Bean
博客等级 码龄13年 5粉丝 29原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值