Using this code to write text on page but instead of "Hello Fanta" text I get "atnaF olleH"
var filePath = path.join(__dirname, '../storage/templates/IOT.pdf');
var outputPath = path.join(__dirname, '../storage/signed/IOT.pdf');
var pdfWriter = hummus.createWriterToModify(filePath, {
modifiedFilePath: outputPath
});
var pageModifier = new hummus.PDFPageModifier(pdfWriter, 0);
var pageContext = pageModifier.startContext().getContext()
pageContext.writeText(
'Hello Fanta',
75, 650,
{
font: pdfWriter.getFontForFile(path.join(__dirname, '../resources/fonts/arial.ttf')),
size: 25,
//colorspace: 'green',
color: 'black'
}
);
pageModifier.endContext().writePage();
pdfWriter.end();
Oh that's annoying :)
I would guess that the page has a global matrix defined that does the flipping.
if this is the case, the text right edge (H) should be 75 points from the right edge, instead of being 75 points from the left edge.
what you should do is flip the matrix to what you need.
do pageContext->cm(-1,0,0,1,-PAGE_WIDTH,0)
where PAGE_WIDTH is the page width (can get via media box etc. RE your other question).
Gal.
Thanks a lot.
Is there option to detect if page has matrix with flipping?
On Jul 4, 2016 08:26, "gal kahana" [email protected] wrote:
Oh that's annoying :)
I would guess that the page has a global matrix defined that does the
flipping.
if this is the case, the text right edge (H) should be 75 points from the
right edge, instead of being 75 points from the left edge.what you should do is flip the matrix to what you need.
do pageContext->cm(-1,0,0,1,-PAGE_WIDTH,0)where PAGE_WIDTH is the page width (can get via media box etc. RE your
other question).Gal.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/galkahana/HummusJS/issues/81#issuecomment-230214367,
or mute the thread
https://github.com/notifications/unsubscribe/AAJlraactQMreThuP5C5pbn0czzaXis1ks5qSKeZgaJpZM4JD8d6
.
yes.
but it requires some more digging into the page content stream, which requires PDF knowledge.
you will be looking for 'cm' commands Q..q scopes etc.
better to know in advance
Hi,
got a better answer now.
provide a last "true" parameter to the constructor of the page modifier, like this:
var pageModifier = new hummus.PDFPageModifier(pdfWriter, 0,true);
this will make sure that the existing content is well encapsulated and that your code is not affected by it.
can you please give an example on writing text (flip it up side down, and invert it)
Thanks!
Most helpful comment
Hi,
got a better answer now.
provide a last "true" parameter to the constructor of the page modifier, like this:
this will make sure that the existing content is well encapsulated and that your code is not affected by it.