对于pyPdf用于IndirectObject提取感兴趣的读者,本文将提供您所需要的所有信息,我们将详细讲解python提取pdf信息,并且为您提供关于active-directory–如何匿名获取A
对于pyPdf用于IndirectObject提取感兴趣的读者,本文将提供您所需要的所有信息,我们将详细讲解python提取pdf信息,并且为您提供关于active-directory – 如何匿名获取Active Directory域objectGUID、angular – 无法解析AuthenticationService的所有参数:([object Object],?,[object Object])、ASP.NET list的宝贵知识。
本文目录一览:- pyPdf用于IndirectObject提取(python提取pdf信息)
- active-directory – 如何匿名获取Active Directory域objectGUID
- angular – 无法解析AuthenticationService的所有参数:([object Object],?,[object Object])
- ASP.NET list
- c – delete(Object)等效于调用Object .~Object()
pyPdf用于IndirectObject提取(python提取pdf信息)
按照此示例,我可以将所有元素列出到pdf文件中
import pyPdfpdf = pyPdf.PdfFileReader(open("pdffile.pdf"))list(pdf.pages) # Process all the objects.print pdf.resolvedObjects
现在,我需要从pdf文件中提取非标准对象。
我的对象是一个名为MYOBJECT的对象,它是一个字符串。
与我有关的python脚本打印的部分是:
{''/MYOBJECT'': IndirectObject(584, 0)}
pdf文件是这样的:
558 0 obj<</Contents 583 0 R/CropBox[0 0 595.22 842]/MediaBox[0 0 595.22 842]/Parent 29 0 R/Resources <</ColorSpace <</CS0 563 0 R>> /ExtGState <</GS0 568 0 R>> /Font<</TT0 559 0 R/TT1 560 0 R/TT2 561 0 R/TT3 562 0 R>> /ProcSet[/PDF/Text/ImageC] /Properties<</MC0<</MYOBJECT 584 0 R>>/MC1<</SubKey 582 0 R>> >> /XObject<</Im0 578 0 R>>>> /Rotate 0/StructParents 0/Type/Page>>endobj.........584 0 obj<</Length 8>>stream1_22_4_1 --->>>> this is the string I need to extract from the objectendstreamendobj
我如何跟随584
值以引用我的字符串(当然在pyPdf下)?
答案1
小编典典中的每个元素pdf.pages
都是字典,因此假设它在第1页上,pdf.pages[0][''/MYOBJECT'']
应该是您想要的元素。
您可以尝试单独打印或戳在它help
和dir
在提示更多关于如何得到你想要的字符串蟒蛇
编辑:
收到pdf副本后,我在找到了对象,pdf.resolvedObjects[0][558][''/Resources''][''/Properties''][''/MC0''][''/MYOBJECT'']
可以通过getData()检索值
以下函数通过递归查找有问题的密钥提供了一种更通用的解决方案
import typesimport pyPdfpdf = pyPdf.PdfFileReader(open(''file.pdf''))pages = list(pdf.pages)def findInDict(needle,haystack): for key in haystack.keys(): try: value = haystack[key] except: continue if key == needle: return value if type(value) == types.DictType or isinstance(value,pyPdf.generic.DictionaryObject): x = findInDict(needle,value) if x is not None: return xanswer = findInDict(''/MYOBJECT'',pdf.resolvedObjects).getData()
active-directory – 如何匿名获取Active Directory域objectGUID
dsquery * "DC=lab,DC=local" -scope base -attr objectguid
我可以在Linux中使用此命令从域控制器labdc01获取域(lab.local)SID而无需帐户(匿名):
# rpcclient -U% labdc01.lab.local -c lsaquery Domain Name: LAB Domain Sid: S-1-5-21-3869872838-1836277878-698564084
如果我知道GUID,我可以从DNS获取它:
_ldap._tcp.4f904480-7c78-11cf-b057-00aa006b4f8f.domains._msdcs.lab.local.
如何匿名获取域objectGUID(如上面的SID示例)?
你不能
使用Active Directory,对于任何任何无关的LDAP操作(除了RootDSE绑定)成功,您需要:
> Enable anonymous binds
> Allow Anonymous access to public properties
angular – 无法解析AuthenticationService的所有参数:([object Object],?,[object Object])
Can’t resolve all parameters for AuthenticationService: ([object Object],?,[object Object])
我已经检查了几乎每个主题,并尝试了多种方法来解决它,但仍然无法在第二天击败它.
我试图像这样在appService中注入第一个authService但是得到了同样的错误
@Inject(forwardRef(() => AuthenticationService)) public authService: AuthenticationService
我检查了所有DI和服务内部的导入顺序,在我看来一切都是正确的
如果有人可以帮我处理它,我很感激.
Angular 4.0.0
AuthService
import { Injectable } from '@angular/core'; import {Http,Headers,Response} from '@angular/http'; import 'rxjs/add/operator/toPromise'; import {Observable} from 'rxjs/Rx'; import {AppServices} from "../../app.services"; import {Router} from "@angular/router"; @Injectable() export class AuthenticationService { public token: any; constructor( private http: Http,private appService: AppServices,private router: Router ) { this.token = localStorage.getItem('token'); } login(username: string,password: string): Observable<boolean> { let headers = new Headers(); let body = null; headers.append("Authorization",("Basic " + btoa(username + ':' + password))); return this.http.post(this.appService.api + '/login',body,{headers: headers}) .map((response: Response) => { let token = response.json() && response.json().token; if (token) { this.token = token; localStorage.setItem('Conform_token',token); return true; } else { return false; } }); } logout(): void { this.token = null; localStorage.removeItem('Conform_token'); this.router.navigate(['/login']); } }
应用服务
import {Injectable} from '@angular/core'; import {Headers,Http,RequestOptions} from '@angular/http'; import {Router} from "@angular/router"; import {AuthenticationService} from "./auth/auth.service"; import 'rxjs/add/operator/toPromise'; import {Observable} from 'rxjs/Rx'; @Injectable() export class AppServices { api = '//endpoint/'; public options: any; constructor( private http: Http,private router: Router,public authService: AuthenticationService // doesn't work // @Inject(forwardRef(() => AuthenticationService)) public authService: AuthenticationService // doesn't work either ) { let head = new Headers({ 'Authorization': 'Bearer ' + this.authService.token,"Content-Type": "application/json; charset=utf8" }); this.options = new RequestOptions({headers: head}); } // ==================== // data services // ==================== getData(): Promise<any> { return this.http .get(this.api + "/data",this.options) .toPromise() .then(response => response.json() as Array<Object>) .catch((err)=>{this.handleError(err);}) }
应用模块
import { browserModule } from '@angular/platform-browser'; import { browserAnimationsModule } from '@angular/platform-browser/animations'; import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; import {BaseRequestOptions,HttpModule} from '@angular/http'; import { MaterialModule} from '@angular/material'; import {FlexLayoutModule} from "@angular/flex-layout"; import 'hammerjs'; import { routing,appRoutingProviders } from './app.routing'; import { AppServices } from './app.services'; import {AuthGuard} from "./auth/auth.guard"; import {AuthenticationService} from "./auth/auth.service"; import {AppComponent} from './app.component'; import {AuthComponent} from './auth/auth.component'; import {NotFoundComponent} from './404/not-found.component'; import { HomeComponent } from './home/home.component'; @NgModule({ declarations: [ AppComponent,AuthComponent,NotFoundComponent,HomeComponent ],imports: [ browserModule,browserAnimationsModule,FormsModule,HttpModule,routing,MaterialModule,FlexLayoutModule ],providers: [AppServices,AuthGuard,AuthenticationService],bootstrap: [AppComponent] }) export class AppModule { }
解决方法
你可以使用
export class AuthenticationService { public token: any; appService: AppServices; constructor( private http: Http,// private appService: AppServices,injector:Injector; private router: Router ) { setTimeout(() => this.appService = injector.get(AppServices)); this.token = localStorage.getItem('token'); }
另见DI with cyclic dependency with custom HTTP and ConfigService
要避免使用setTimeout,您还可以从AppService的构造函数中设置AuthenticationService.appService(或者相反)
ASP.NET list
public partial class 测试 : System.Web.UI.Page
{
static List<Item> allAnswer= new List<Item>();
protected void Page_Load(object sender, EventArgs e)
{
//首次加载
if (IsPostBack == false)
{
//不能使用将allAnswer中的元素全部删除,这样也会将session中的值清空
//allAnswer.clean();
//使用重新定义新的空的对象来实现对allAnswer的清空
allAnswer = new List<Item>();
List<Item> reallAnswer = null;
try
{
//其中Session["ReAllAnswer"]来自于另一页面
reallAnswer = (List<Item>)Session["ReAllAnswer"];
//PrintAllAnwser(reallAnswer);
}
catch { }
}
}
如果使用allAnswer.clean()函数,则接收的数据Session["ReAllAnswer"]将会设置为空;
而使用new List<Item>(),则不会。
c – delete(Object)等效于调用Object .~Object()
static void Constructor(ObjectType *thisPointer) { new(thisPointer) ObjectType(); }
和这样的代码来销毁对象:
static void Destructor(ObjectType *thisPointer) { thisPointer->~ObjectType(); }
我有几个问题:
>这种方式使用析构函数是否正确? (Eclipse判断这是一个错误)据我所知,这段代码应该调用析构函数而不释放内存(调用free())
>是否可以使用delete(thisPointer)(或类似的东西)而不是这种结构,它是否相同? (至少这段代码在编译和运行时没有错误)
>还有其他方法可以在不释放内存的情况下调用析构函数吗?
先感谢您.
解决方法
Is it correct way to use destructor this way?
是.您使用placement-new就地构造了对象,因此必须使用显式析构函数调用来销毁它(假设它具有非平凡的析构函数).
Is it possible to use
delete(thisPointer)
(or something like it) instead of this construction and is it will be equivalent?
删除号将尝试使用operator delete()将内存释放到免费存储区;这只有在使用普通的新表达式(或者可能是显式使用operator new())时才有效.
Is there other ways to call destructor without deallocating memory?
并不是的.调用析构函数当然是调用析构函数的最清晰,最简单的方法.
今天关于pyPdf用于IndirectObject提取和python提取pdf信息的讲解已经结束,谢谢您的阅读,如果想了解更多关于active-directory – 如何匿名获取Active Directory域objectGUID、angular – 无法解析AuthenticationService的所有参数:([object Object],?,[object Object])、ASP.NET list的相关知识,请在本站搜索。
本文标签: