Node.js 응용 프로그램과 함께 Bluemix 문서 변환 서비스를 사용하여 문서를 변환하려고합니다. 내 애플 리케이션에서 아무것도하지만, 오류가 나타납니다,하지만 데모 페이지를 사용하여 괜찮아 변환 사용하고 테스트 문서. 아래는이 응용 프로그램이 디스크에서 PDF를 변환하는 동안 "실제"응용 프로그램이이를 수행 할 수 없으므로 (즉, Buffer 객체) 문제를 보여주는 최소한의 응용 프로그램입니다. 테스트 PDF (782K)에 대해이 프로그램을 실행 한IBM Bluemix 문서 변환 서비스를 사용하려고 할 때 "다시 푸시 할 수 없습니다"오류가 발생하는 이유는 무엇입니까?
'use strict';
var fs = require('fs');
var DocumentConversionV1 = require('watson-developer-cloud/document-conversion/v1');
var bluemix=require('./my_bluemix');
var extend=require('util')._extend; //Node.js' built-in object extend function
var dcCredentials = extend({
url: '<url>',
version: 'v1',
username: '<username>',
password: '<password>'
}, bluemix.getServiceCreds('document_conversion')); // VCAP_SERVICES
var document_conversion = new DocumentConversionV1(dcCredentials);
var contents = fs.readFileSync('./testdoc.pdf', 'utf8');
var parms={
file: new Buffer(contents,'utf8'),
conversion_target: 'ANSWER_UNITS', // (JSON) ANSWER_UNITS, NORMALIZED_HTML, or NORMALIZED_TEXT
content_type:'application/pdf',
contentType:'application/pdf', //don't know which of these two works, seems to be inconsistent so I include both
html_to_answer_units: {selectors: [ 'h1', 'h2','h3', 'h4']},
};
console.log('First 100 chars of file:\n******************\n'+contents.substr(0,100)+'\n******************\n');
document_conversion.convert(parms, function(err,answerUnits)
{
if (!err)
console.log('Returned '+answerUnits.length);
else
console.log('Error: '+JSON.stringify(err));
});
결과는 다음과 같습니다
이$ node test.js
[DocumentConversion] WARNING: No version_date specified. Using a (possibly old) default. e.g. watson.document_conversion({ version_date: "2015-12-15" })
[DocumentConversion] WARNING: No version_date specified. Using a (possibly old) default. e.g. watson.document_conversion({ version_date: "2015-12-15" })
First 100 chars of file:
******************
%PDF-1.5
%����
1 0 obj
<</Type/Catalog/Pages 2 0 R/Lang(en-US) /StructTreeRoot 105 0 R/MarkInfo<<
******************
Error: {"code":400,"error":"Could not push back 82801 bytes in order to reparse stream. Try increasing push back buffer using system property org.apache.pdfbox.baseParser.pushBackSize"}
$
누군가가 경고 메시지를 제거하는 방법을 나에게
- 를 말할 수
- 문서가 변환되지 않는 이유
- "밀어 넣기 버퍼를 늘리는 방법"
다른 문서는 다른 오류를 나타내지 만,이 문서를 만들면 다른 오류도 사라질 것입니다.
나는 파문 배열을 잘못했다. { 값 : 새로운 버퍼 (컨텐츠) 선택해 { CONTENT_TYPE '프로그램/PDF " } } conversion_target'ANSWER_UNITS ' 구성 { 적절한 형태 { \t 파일 conversion_target : 'ANSWER_UNITS', // "h2", "h3"및 "h4"태그로 html 파일 분할하기 html_to_answer_units : {선택자 : [ 'h1', 'h2', 'h3', 'h4']} } \t} 그렇습니다. conversion_target 매개 변수는 두 번 있어야합니다. –