hummusRecipe icon indicating copy to clipboard operation
hummusRecipe copied to clipboard

hummusRecipe + firebase / hummusRecipe + stream

Open kriefsacha opened this issue 5 years ago • 7 comments

Hi,

I'm using the last version of hummusRecipe in nodejs.

To begin , thanks for your work your library is very useful and easy to use.

I have a little issue thow.

I have tried in local and everything is working , but my function is supposed to be a firebase http function.

And when i putted my pdf's on it , i had the " Unable to modify PDF file, make sure that output file target is available and that it is not protected " error.

It's because when you put it on the firebase function directory you only have acces to the reading part.

The question is , how can i send a stream in output when i create the " new HummusRecipe() " ?

Do you have an exemple of it ? It is even possible to do it ? I'm quite new in it so if i'm not clear or it's missing informations i'm sorry just tell me.

Thanks for all !

kriefsacha avatar Sep 14 '18 12:09 kriefsacha

Hi @kriefsacha I am sorry that HummusRecipe does not support Stream/Buffer at this moment. However, PR #55 will add the feature to accept Buffer, I will test it and add stream/buffer example once it's merged.

chunyenHuang avatar Sep 14 '18 16:09 chunyenHuang

Hi @chunyenHuang Thanks for your help.

I didn't have the time to wait so i copied the module in my directory and changed it myself.

Just for you to know , maybe it can help i don't know , i send you what i did , it works perfectly.

in the Recipe.js i added :

const Type = require('type-of-is');

and i changed the _createWriter function like this :

if (this.src.toLowerCase() == 'new') {
            this.isNewPDF = true;

            this.writer = hummus.createWriter(this.output, {
                version: this._getVerion(this.options.version)
            });
        } else {
            this.isNewPDF = false;
            this.read();
            try {

				if(Type.is(this.output, String))	
				{
					this.writer = hummus.createWriterToModify(
						this.src, {
							modifiedFilePath: this.output,
							log: this.logFile
						}
					);
				}
				else{
					this.writer = hummus.createWriterToModify(new hummus.PDFRStreamForFile(this.src), this.output);
				}
            } catch (err) {
                throw new Error(err);
            }
        }

        this.info(this.options);

In the server side this is my code :

let pdfDoc = new HummusRecipe(filePath, new hummus.PDFStreamForResponse(res), {
		title: 'Contrat',
	});

kriefsacha avatar Sep 16 '18 14:09 kriefsacha

yah, it's included in the new PR#55 as well. Thanks for your help

chunyenHuang avatar Sep 17 '18 16:09 chunyenHuang

@chunyenHuang did you released a version with it ?

kriefsacha avatar Jan 13 '20 14:01 kriefsacha

@kriefsacha I think so, this PR was merged last year. Please take a look https://github.com/chunyenHuang/hummusRecipe/pull/55

chunyenHuang avatar Jan 13 '20 17:01 chunyenHuang

@chunyenHuang thanks for you answer , i saw that the PR was merged but i don't see that you puted it in a release. I did an update of the package and didn't get it

kriefsacha avatar Jan 13 '20 17:01 kriefsacha

oops, I see your issue. You actually request the stream output but not input (#55 ). My mistake. I will add your request for the next release.

chunyenHuang avatar Jan 13 '20 21:01 chunyenHuang