我一直在使用此代码取得巨大成功,以提取PDF的每个页面中找到的第一个图像.但是,由于未知原因,它现在无法使用某些新PDF.我已经使用了其他工具(Datalogics等),这些工具可以很好地利用这些新的PDF来提取图像.但是,如果我可以使用iTextSharp,我不想购买Datalogics或任何工具.任何人都可以告诉我为什么这段代码没有找到PDF中的图像?
Knowns:我的PDF每页只有1张图片,没有别的.
using iTextSharp.text;
using iTextSharp.text.pdf;
...
public static void ExtractImagesFromPDF(string sourcePdf, string outputPath)
{
// NOTE: This will only get the first image it finds per page.
PdfReader pdf = new PdfReader(sourcePdf);
RandomAccessFileOrArray raf = new iTextSharp.text.pdf.RandomAccessFileOrArray(sourcePdf);
try
{
for (int pageNumber = 1; pageNumber <= pdf.NumberOfPages; pageNumber++)
{
PdfDictionary pg = pdf.GetPageN(pageNumber);
PdfDictionary res = (PdfDictionary)PdfReader.GetPdfObject(pg.Get(PdfName.RESOURCES));
PdfDictionary xobj = (PdfDictionary)PdfReader.GetPdfObject(res.Get(PdfName.XOBJECT));
if (xobj != null)
{
foreach (PdfName name in xobj.Keys)
{
PdfObject obj = xobj.Get(name);
if (obj.IsIndirect())
{ …Run Code Online (Sandbox Code Playgroud) 我正在使用iTextSharp和reader.GetPageContent方法从PDF中提取文本.我需要找到文档中找到的每个单词的矩形/位置.有没有办法使用iTextSharp获取PDF中单词的矩形/位置?
我正在将文档扫描到JPG图像.扫描仪必须将所有页面扫描为彩色或将所有页面扫描为黑白.由于我的许多页面都是彩色的,我必须将所有页面扫描为彩色.扫描完成后,我想用.Net检查图像并尝试检测哪些图像是黑白的,这样我就可以将这些图像转换为灰度并节省存储空间.
有人知道如何使用.Net检测灰度图像吗?
请告诉我.
我正在使用一些非托管代码,它将指针(IntPtr)返回给大图像对象.我使用引用但在完成图像后,我需要释放指针引用的内存.目前,唯一释放内存的是关闭我的整个应用程序.我需要能够从我的应用程序中释放内存.
这是对内存的分配的调用. hbitmap是返回的指针,需要取消分配.
[DllImport("twain_32.dll", EntryPoint = "#1")]
public static extern TwainResult DsImageTransfer(
[In, Out] Identity origin, [In] Identity dest, DataGroup dg,
DataArgumentType dat, Message msg, ref IntPtr hbitmap);
Run Code Online (Sandbox Code Playgroud) 我确信我只是遗漏了一些东西.但是我已经搜索了几天试图找到如何显示一个4位数的年份显示NSDate与NSDateFormatterShortStyle样式.如果您有解决方案,请告诉我.这是我现在使用的代码.
[NSDateFormatter setDefaultFormatterBehavior:NSDateFormatterBehavior10_4];
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease ];
[dateFormatter setDateStyle:NSDateFormatterShortStyle];
[dateFormatter setTimeStyle:NSDateFormatterNoStyle];
// add label for birth
UILabel *birthday = [[UILabel alloc] initWithFrame:CGRectMake(125, 10, 100, 25)];
birthday.textAlignment = UITextAlignmentRight;
birthday.tag = kLabelTag;
birthday.font = [UIFont boldSystemFontOfSize:14];
birthday.textColor = [UIColor grayColor];
birthday.text = [dateFormatter stringFromDate:p.Birth];
Run Code Online (Sandbox Code Playgroud) 我打算将我的网络应用程序部署到EC2.我有几个webserver实例.我有1个主数据库实例.我有1个故障转移数据库实例.我需要一种策略,在主数据库实例失败时将Web服务器重定向到故障转移数据库实例IP.
我希望我可以在连接字符串中使用弹性IP.但是,Web服务器无法访问/ ping弹性IP.我有几个蛮力的想法来解决这个问题.但是,我试图找到最优雅的解决方案.
我正在使用所有.Net和SQL Server.我的连接字符串已加密.
有没有人有使用某种形式的自动化或DNS配置在EC2中故障转移数据库实例的策略?
请告诉我.
我在S3中存储文件,并希望将数据加密到最大.我正在使用ThreeSharp S3库,它使用DESCryptoServiceProvider来加密数据.与.Net中提供的其他加密相比,DESCryptoServiceProvider有多强?
我也看到像Mozy.com这样使用448位Blowfish加密的服务.我做了一些研究,发现了一些提供Blowfish的免费图书馆.但没有什么可以说明为什么Blowfish比.Net提供的更好.
我需要知道.Net 3.5中最强大的加密方式.我还想了解其他可能不会在.Net中提供更高加密的库的建议.
我正在尝试向客户传达在 S3 中丢失文件的可能性。我还想知道是否有可能从 S3 中丢失整个存储桶。所以,我想知道以下几点:
当我说“丢失”文件时。我的意思是丢失、损坏或无法从 S3 中提取的文件。这种“损失”是由 S3 上的故障引起的。它不是由工具或其他用户错误引起的。
我正在开发一个应用程序,客户想要为大图像制作动画(305x332).客户希望在1.75秒内使用50帧来循环动画.通过这么多处理,我发现应用程序非常慢.启动缓慢,响应触摸并关闭.在它自己的iPhone上,该应用程序将经常崩溃或锁定手机.请参阅下面的代码.我的问题:
请告诉我.这是代码......
NSMutableArray *tempArray = [[NSMutableArray alloc] init];
for(int i = 1; i <= 50; i++)
{
[tempArray addObject:[UIImage imageNamed:[NSString stringWithFormat:@"%@-%d-%04d.JPG",[constitution getConstitutionWord], constitution.getAnimationEnum, i]]];
}
backgroundImage.animationImages = tempArray;
[tempArray release];
backgroundImage.animationDuration = 1.75; // seconds
backgroundImage.animationRepeatCount = 0; // 0 = loops forever
[backgroundImage startAnimating];
Run Code Online (Sandbox Code Playgroud) 我在黑色UIToolbar上有一个UISegmentedControl.我已将样式设置为Bar并将背景颜色设置为clear(也尝试为黑色).我已经尝试将tintColor设置为clear(也尝试黑色).我的按钮变黑,以匹配黑色UIToolbar.但是,按钮不再像UISegmentedControl是默认的蓝色/灰色那样表示点击状态.我该怎么做才能使按钮显示黑/灰点击状态?请告诉我.到目前为止用于设置UISegmentedControl颜色的代码:
viewTypeSelection.segmentedControlStyle = UISegmentedControlStyleBar;
viewTypeSelection.backgroundColor = [UIColor clearColor];
Run Code Online (Sandbox Code Playgroud) 我花了最后3个小时试图找出这个错误.我希望有人向我解释,所以我不再这样做了.
我没有使用"self"就分配了一个NSString实例变量.当类("self")发布时,我收到了"错误访问"错误.我在另一个具有相同变量声明的类中完成了同样的事情并且没有此错误.以下是我的代码.我注释掉了破坏的线,下面的线修复了它.但我不明白为什么......请注意,还有其他实例变量不会导致此问题.在分配实例变量时,我是否应始终使用"self"保留字?请告诉我.
声明
@property (nonatomic, readonly, assign) int IID;
@property (nonatomic, assign) int ProfileIID;
@property (nonatomic, retain) NSDate *NoteDate;
@property (nonatomic, copy) NSString *NoteText;
Run Code Online (Sandbox Code Playgroud)
代码段
// the default date format is Year-Month-Day
NSDateFormatter *df = [[[NSDateFormatter alloc] init] autorelease];
[df setDateFormat:kDateFormat];
IID = sqlite3_column_int(selectstmt, 0);
ProfileIID = sqlite3_column_int(selectstmt, 1);
// notice this does not cause a memory error
NoteDate = [[df dateFromString: [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt, 2)]] retain];
// the following may be NULL. Checking using the sqlite3_column_text method
const char …Run Code Online (Sandbox Code Playgroud) iphone ×4
.net ×2
c# ×2
itextsharp ×2
amazon-ec2 ×1
amazon-s3 ×1
animation ×1
cocoa ×1
encryption ×1
failover ×1
grayscale ×1
nsdate ×1
objective-c ×1
pdf ×1
pointers ×1
uitoolbar ×1
unmanaged ×1