0
데스크탑과 핸드 헬드 장치간에 문서를 보내고 있으며 다음과 같이 PDF에 메타 데이터 헤더를 추가하려고합니다. PDFDocument에 사용자 정의 메타 데이터 추가하기
<CUSTOM_HEADER>\n
{"fileInfoEncodedInJson\":
{"filename":"My Print Out",
"filesize\":"630",
"filedesc":"",}
}\n
</CUSTOM_HEADER>\n
… file contents …
은 내가
documentAttributes
및
setDocumentAttributes
방법을 공급 PDFKit 및 PDFDocument를 사용하고 있지만, 사용자 정의 헤더이기 때문에, 내가 속성을 설정할 때 지속하는 것하고 파일을 저장하지 않습니다
를
NSURL *path = [NSURL fileURLWithPath:@"/Users/username/Desktop/file.pdf"];
PDFDocument *document = [[PDFDocument alloc] initWithURL:path];
NSDictionary *docAttributes = [self.document documentAttributes];
NSMutableDictionary *newAttributes = [[NSMutableDictionary alloc] initWithDictionary:docAttributes];
[newAttributes setObject: @"Custom header contents" forKey:@"Custom header"];
docAttributes = [[NSDictionary alloc] initWithDictionary: newAttributes];
[document setDocumentAttributes: docAttributes];
//Here Custom Header is an entry in the dictionary
[self.document writeToFile:@"/Users/username/Desktop/UPDATEDfile.pdf"];
//Here the UPDATEDfile.pdf does not contain the custom header
나는 두루의 비슷한 질문 (예 : here, 예 : cocoadev)을 발견했지만 답이 없습니다. 누구든지 PDF 파일에 사용자 정의 (즉, 문서 속성 키 아래 제공된 8 개의 미리 정의 된 상수) 헤더를 저장하는 방법을 알고 있습니까?
이 상황에서는 개체 오프셋이 잘못되어 파일이 손상되었습니다. Adobe Reader는 파일을 열 수 있습니다 (상호 참조를 복구 함). 그러나 다른 PDF 프로세서는 이에 대해 불평 할 수 있습니다. 목표가 Adobe Reader만이면 괜찮습니다. – iPDFdev
맞습니다. 필자는이 헤더가 필요한 모바일 응용 프로그램으로 파일을 보내고 Adobe Reader 응용 프로그램에 문서를 푸시합니다. 그러나 헤드 업에 감사드립니다. – Katie