Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot add logo before content #9

Open
dgofman opened this issue Jan 7, 2016 · 4 comments
Open

Cannot add logo before content #9

dgofman opened this issue Jan 7, 2016 · 4 comments

Comments

@dgofman
Copy link

dgofman commented Jan 7, 2016

I need to generate PDF with logo on top. Looks like bug in your code I can only add after some content text. Also I can only set width and height how about padding/position (top/left)

lxDocument.addImage('content', './logo.png');

lxDocument.addImage('header', './logo.png');

lxDocument.addImage('content', './logo.png', {top:0});

Workaround create patch on line 1025

var imgData = PDFImage.open(entry.image.filename),
imgHeight = options.height || imgData.height,
reqPageBreak = (sectionInfo.topIndex + imgHeight > sectionDimension.height),
imageTop = options.top === undefined ? reqPageBreak ? sectionDimension.top || 0 : null : options.top;

@LitixThomas
Copy link
Member

Hi,

i have tried to retrace your issue, but i can't confirm this. Can you explain that in more detail? Maybe is your image too big for this section?

When you need a Image/Logo at the same position on every Page, have you tried to use a background image? For example see the Invoice Test.

A padding/margin for images would be nice. I will add this in the next release.

@dgofman
Copy link
Author

dgofman commented Jan 7, 2016

To reproduce this issue add footer into your template and just image (instead image move on top in content position moving to footer, until I will not add some text to content.

var doc = require('lx-pdf')('templates/export_search_pdf.json');
doc.addImage('logo', './logo.png');
doc.save('document' + Date.now() + '.pdf', function(result) {
});

"footer": {
"font": {
"name": "templates/Helvetica.ttf",
"size": 6,
"color": "#F0F0F0"
},
"format": {
"align": "center",
"height": 60,
"textmargin": {
"left": 10,
"top": 10,
"right": 10
},
"background": "#000000"
},
"data": [
[
{
"text": "ANSCHRIFT",
"align": "left",
"font": "footer_header"
}
]
]
},

@dgofman
Copy link
Author

dgofman commented Jan 7, 2016

Another problem I cannot move image some pixels down (top: XXX) I tried move section "format": {
"align": "right",
"left": 25,
"top": 25,
"width": 570,
"height": 30
}
But still on top: 0, funny part is "left" it's working

@LitixThomas
Copy link
Member

Okay, now i can confirm that issue. I will fix that.

LitixThomas added a commit that referenced this issue Jan 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants