In our documentEditor implementation we have implemented a PDF Export that exports all pages of the document as PDF. In the header of our document we have a background-image (contains logo, sender etc).
This all works pretty well as lomg as we are on ocumentEditor version 19.4.47.
We upgraded to 19.4.52 because we had an issue with insertText Method ignoring linebreaks (\n and \r) wich we saw was fixed in 19.4.52.
Howerver since we upgraded to 19.4.52 - the PDF export does no longer include background-images in header/footer wich is a very crutial feature for us.
Do you have any ideas how we can have both - background-images in PDF export AND linebreaks in insertText method ?
Any help would be appreciated. Thanks.
Any ideas anyone ? Why version 19.4.52 no longer exports backgroundimages in PDF ?
Hi Thomas,
Syncfusion greetings.
Can you please share the input document which you have tried at your end with a video illustration that will be helpful for us to proceed further and provide you the solution at the earliest.
Also, can you please share us the document editor version details.
Note: If you have any confidential data in your Word document, please replace with some dummy data and provide us the same. We just need your document to recreate the problem you face.
Regards,
Ajithamarlin E
Hello,
unfortunately I am not able to provide a video illustration, but attached you will find 4 files - 2 sfdt (source) files and 2 pdfs (output).
sampleGeneratedWith19.4.47.sfdt is the source for sampleGeneratedWith19.4.47.pdf
in that File I have included text with Linebreaks wich are lost, but in the generated PDF you can see the background image.
sampleGeneratedWith19.4.52.sfdt is the source for sampleGeneratedWith19.4.52.pdf
In that file I have includes text with Linebreaks wich are still in the document, but in the generated PDF the background image is lost.
The application code is the exact same, the only difference between these 2 is that I increased the version of documentEditor from 19.4.47 to 19.4.52.
Any help would be appreceated.
HI Thomas,
We have tried to reproduce the reported issue in the version 19.4.52, But we couldn't.
Please refer the attached video.
Can you please share us the PDF export code used at your end, it may be helpful to us to validate further.
Regards,
Ajithamarlin E
Hi,
thanks for your reply.
Here ist the code I use to export the PDF:
public exportAsPdf() {
const obj = this;
const pdfdocument: PdfDocument = new PdfDocument();
const count: number = obj.container.documentEditor.pageCount;
obj.container.documentEditor.documentEditorSettings.printDevicePixelRatio = 2;
let loadedPage = 0;
for (let i = 1; i <= count; i++) {
setTimeout(() => {
const format: ImageFormat = "image/jpeg" as ImageFormat;
const image = obj.container.documentEditor.exportAsImage(i, format);
image.onload = () => {
const imageHeight = parseInt(image.style.height.toString().replace("px", ""), 10);
const imageWidth = parseInt(image.style.width.toString().replace("px", ""), 10);
const section: PdfSection = pdfdocument.sections.add() as PdfSection;
const settings: PdfPageSettings = new PdfPageSettings(0);
if (imageWidth > imageHeight) {
settings.orientation = PdfPageOrientation.Landscape;
}
settings.size = new SizeF(imageWidth, imageHeight);
(section as PdfSection).setPageSettings(settings);
const page = section.pages.add();
const graphics = page.graphics;
const imageStr = image.src.replace("data:image/jpeg;base64,", "");
const pdfImage = new PdfBitmap(imageStr);
graphics.drawImage(pdfImage, 0, 0, imageWidth, imageHeight);
loadedPage++;
if (loadedPage === count) {
pdfdocument.save(
(obj.container.documentEditor.documentName === ""
? "dummy"
: obj.container.documentEditor.documentName) + ".pdf"
);
}
};
}, 500);
}
}
I imported these libs:
import {
PdfBitmap,
PdfDocument,
PdfPageOrientation,
PdfPageSettings,
PdfSection,
SizeF,
} from "@syncfusion/ej2-pdf-export";
But the moment I am writing this, it comes to my mind, that I havent upgraded the @syncfussion/ej2-pdf-export package, maybe that could be a reason. So I am also sending you the exact list of packages in my package.json file, and maybe you can say if the list is ok or if you think that there is a problem. Maybe you could provide me with the exact list of the bare minimum of dependencies that I have to install to run documentEditor in an angular 13 application.
"@syncfusion/ej2-angular-documenteditor": "19.4.52",
"@syncfusion/ej2-angular-base": "19.4.52",
"@syncfusion/ej2-documenteditor": "19.4.52",
"@syncfusion/ej2-base": "19.4.42",
"@syncfusion/ej2-buttons": "19.4.42",
"@syncfusion/ej2-compression": "19.4.38",
"@syncfusion/ej2-data": "19.4.47",
"@syncfusion/ej2-dropdowns": "19.4.47",
"@syncfusion/ej2-file-utils": "19.4.38",
"@syncfusion/ej2-inputs": "19.4.47",
"@syncfusion/ej2-lists": "19.4.38",
"@syncfusion/ej2-navigations": "19.4.47",
"@syncfusion/ej2-popups": "19.4.47",
"@syncfusion/ej2-splitbuttons": "19.4.47",
"@syncfusion/ej2-charts": "19.4.47",
"@syncfusion/ej2-angular-splitbuttons": "19.4.47",
"@syncfusion/ej2-angular-popups": "19.4.47",
"@syncfusion/ej2-angular-buttons": "19.4.42",
"@syncfusion/ej2-angular-inputs": "19.4.47",
"@syncfusion/ej2-angular-lists": "19.4.38",
"@syncfusion/ej2-angular-dropdowns": "19.4.47",
"@syncfusion/ej2-angular-navigations": "19.4.47",
"@syncfusion/ej2-angular-charts": "19.4.47"
Thank you
Hi Thomas,
In version 19.4.52, we can reproduce the reported issue. But in latest version 20.1.0.52, we couldn't reproduce the reported issue.
Can you please upgrade your Document editor packages to latest version(20.1.0.52)?
Please upgrade to the latest version packages to resolve this issue.
https://www.npmjs.com/package/@syncfusion/ej2-documenteditor
https://www.npmjs.com/package/@syncfusion/ej2-angular-documenteditor
Please let us know if still issues persist.
Regards,
Suriya M.
Hi,
now that I upgraded to version 20.1.52 (20.1.0.52 was not working) - it seems to work and do both backgroundinages in pdf and linebreaks in inserted text.
Howerver now, whenever I load documentEditor I get the red syncfusion license validation message on top of my page - how do I get rid of that
Hi Thomas,
We have introduced license key validation for Essential JS2 platforms from the 2022 Volume 1 release (v20.1.0.47). So, you have to register the license key to avoid licensing warning.
Please refer the below documentation to know about how to generate and Register Syncfusion License key in EJ2-Angular application
https://ej2.syncfusion.com/angular/documentation/licensing/license-key-generation/
https://ej2.syncfusion.com/angular/documentation/licensing/license-key-registration/
Regards,
Suriya M.