-
Notifications
You must be signed in to change notification settings - Fork 270
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
move download chart PDF function to the front-end #2094
move download chart PDF function to the front-end #2094
Conversation
if (!svgToPdfDownload("oncoprint.pdf", this.oncoprint.toSVG(true))) { | ||
alert("Oncoprint too big to download as PDF - please download as SVG."); | ||
} | ||
svgToPdfDownload("oncoprint.pdf", this.oncoprint.toSVG(false)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe wrap this in try catch and notify user if there's an error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure I can do that. But should we have a limitation on the file size of SVG? For a very large oncoprint SVG, it may take half a minute for downloading.
src/shared/lib/svgToPdfDownload.ts
Outdated
req.end((err, res)=>{ | ||
if (!err && res.ok) { | ||
fileDownload(base64ToArrayBuffer(res.text), filename); | ||
// dealing with oncoprint svg (temporarily) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is temporary b/c @adamabeshouse will fix in actual library?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, correct. when we have the new oncoprint.js, these lines can be removed from here.
} | ||
|
||
export async function svgToPdfPromise(svg:Element, servletUrl?: string) { | ||
const res = await svgToPdfRequest(svg, servletUrl); | ||
export async function svgToPdfPromise(svg:Element) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we get rid of this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This promise is required by the charts in study view page, may not easy to change.
@tmazor Thank you so much for helping to find these issues. The issues have been solved by changing to a custom font(FreeSerif), this font can handle most of the special characters. Could you help me to review my pr again? thanks in advance! Here is the link: https://cbioportal-frontend-pr-2094.herokuapp.com/ |
Thanks @dippindots ! I don't really love the fact that we now have a mix of fonts in some of the PDF downloads (I'm having trouble with uploading images, but take a look at the PDF download of the plot on the co-expression tab and note how the title is a different font than everything else), and the predominant font in the PDF downloads is now a serif font when the website (and png/svg downloads) all use a sans serif font. I realize this is a consequence of using FreeSerif to fix the problems with the special characters. Is there a sans serif option that we could use instead? This isn't a deal breaker for me - so if freeSerif if the best option to get PDF downloads working again, I can live with this. But I'd be happier with more consistency in the fonts :) |
77941ab
to
95c8651
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me @dippindots !
@@ -78,8 +79,10 @@ export class ChartHeader extends React.Component<IChartHeaderProps, {}> { | |||
const fileName = `${this.fileName}.${props.type.substring(0, 3).toLowerCase()}`; | |||
if (props.type === "PNG") { | |||
saveSvgAsPng(data, fileName, {backgroundColor:"#ffffff"}); | |||
} else if ((props.type === "PDF" || typeof data === "string") && data.length > 0) { | |||
} else if (typeof data === "string" && data.length > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what type is this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alisman It is for SVG type, SVG will be serialized to string.
95c8651
to
0755104
Compare
5ad303a
to
289a4e2
Compare
289a4e2
to
e136047
Compare
e136047
to
c21aeb0
Compare
c21aeb0
to
81c7d24
Compare
There are three failing e2e tests that fail with timeout. They are not connected with this PR. |
Create SVG to PDF using the library: svg2pdf.js
Fix cBioPortal/cbioportal#5738.