HTML file to PDF file, deal with base64,svg picture problem solution.

조회 수: 7 (최근 30일)
Fangping
Fangping 2024년 8월 30일
답변: Rushikesh 2024년 9월 23일
HTML file to PDF file, error when processing base64,svg images
  댓글 수: 2
Fangping
Fangping 2024년 8월 30일
import mlreportgen.dom.*;
import mlreportgen.utils.html2dom.*
rpt = Document('Myhtml','pdf');
% Preprocess the HTML file in advance
preppedHTMLFile = prepHTMLFile('Myhtml',"mypreppedHTML.html");
htmlFile = HTMLFile(preppedHTMLFile);
% Add the file to the rpt file
append(rpt,htmlFile);
close(rpt);
delete('mypreppedHTML.html');
rptview(rpt.OutputPath);
Rahul
Rahul 2024년 8월 30일
Could you share the '.html' file with the base 64 image as it would help in reproducing the issue. Thanks.

댓글을 달려면 로그인하십시오.

답변 (1개)

Rushikesh
Rushikesh 2024년 9월 23일
Hello @Fangping,
I understand that you are getting error while preparing HTML file for conversion to MATLAB Report Generator DOM using “prepHTMLFile” function.
In the prepHTMLFilefunction, it's crucial to include the full file name with the .html extension. If your HTML file is named "Myhtml.html," ensure you use the complete name, including the extension, to avoid errors.
The function prepHTMLFile(inputFile, outputFileName) creates a prepared HTML file with the name specified by outputFileName. In your scenario, you have outputFileName as "mypreppedHTML.html" and inputFile as "Myhtml" without the .html extension. This omission can result in an error message stating, "HTML File Myhtml does not exist." To prevent this, use the correct syntax:
>> prepHTMLFile("Myhtml.html", "//output_file_name.html");
I have attached sample HTML file containing base 64 encoded image for more understanding. Above updated code works well on attached HTML file to generate PDF..
For further information on the “prepHTMLFile function, please refer to the MATLAB documentation at the following link: https://www.mathworks.com/help/rptgen/ug/mlreportgen.utils.html2dom.prephtmlfile.html

카테고리

Help CenterFile Exchange에서 Report Generator Creation에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by