简体   繁体   English

使用Aspose转换和合并pdf

[英]Convert and merge pdfs with Aspose

I am trying to build a service to convert documents to pdfs and merge them using Aspose. 我试图建立一种服务,将文档转换为pdf并使用Aspose合并它们。 So far I haven't found the right combination of functions to do so. 到目前为止,我还没有找到合适的功能组合。 Here is the closes I have gotten. 这是我得到的关闭。

Creating an Aspose document in their cloud: 在他们的云中创建一个Aspose文档:

storageApi.PutCreate('file.jpg', null, null, '/tmp/file.pdf', cb);

Converting the document to pdf: 将文档转换为pdf:

pdfApi.PutCreateDocument('file.pdf', 'file.jpg', null, 'jpg', null, null, cb)

I think this step may be wrong because the pdf is exactly the same size as the jpg. 我认为此步骤可能是错误的,因为pdf的大小与jpg的大小完全相同。 That being said I still get a 200 response. 话虽如此,我仍然收到200条回应。

Merging the documents: 合并文件:

pdfApi.PutMergeDocuments('output.pdf', null, null, ['file.pdf', ...], cb)

This seems to not be returning the error: 这似乎没有返回错误:

{ Message: 'Object reference not set to an instance of an object.' }

And then to retrieve the file : 然后检索文件:

storageApi.getDownload('output.pdf', null, null, cb)

This is obviously a little irrelevant considering the last step fails, but I think it should work if I can get things going. 考虑到最后一步失败,这显然是无关紧要的,但是我认为如果我能使事情顺利进行的话,它应该可以工作。

What I suspect is happening is the converting step is just renaming the file and not converting it. 我怀疑正在发生的是,转换步骤只是重命名文件而不进行转换。 I've tried with pdfApi.PutConvertDocument but I haven't got that working either. 我已经尝试了pdfApi.PutConvertDocument但是我也没有用。

I haven't found the documentation particularly helpful in this area. 我还没有发现文档在这方面特别有用。 What steps should I take to get this working? 我应该采取什么步骤使它正常工作?

It looks like you are not passing the list of source documents correctly. 看来您没有正确传递源文档列表。 Please check http://www.aspose.com/docs/display/pdfcloud/Merge+Multiple+PDF+Files for more details on how to format the list of documents when passing it to PutMergeDocuments . 请检查http://www.aspose.com/docs/display/pdfcloud/Merge+Multiple+PDF+Files,以获取有关在将文档列表传递给PutMergeDocuments时如何格式化文档列表的更多详细信息。 Specially focus on the following variable which is passed as parameter in the above mentioned example. 特别关注以下变量,在上述示例中,该变量作为参数传递。

var mergeDocumentsBody = {
        'List' : [mergefilename1, mergefilename2]
};

I work as developer evangelist at Aspose. 我在Aspose担任开发人员推广员。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM