英文:
Convert Maps to PDF and open PDF Viewer
问题
我试图将地图与一些标题文本转换。标题保持与地图重叠,而不是位于标题上方并在标题下方显示地图。我想在旁边添加一个日志和标题,并在标题下方显示地图,有人可以帮助吗?我正在使用open layers版本7.2.2来导出使用jsPDF并使用CanvasRenderingContext2D创建画布。
这是我尝试实现相同输出的POC:- 导出为PDF
英文:
I am trying to convert the map with some header text. The header keeps overlapping on the map instead of being above header and displaying the map below. I want to add a log and header besides it and display the map below the header can someone help. I am using open layers verion 7.2.2 to export used jsPDF and creating the canvas using CanvasRenderingContext2D.
Here is an POC of the same where I tried to achieve the same output: - EXPORT to PDF
答案1
得分: 1
为了将绘制的图像向下移动,保存上下文并将其向下平移
mapContext.save();
mapContext.translate(0, 50);
在绘制图像的每个部分时,您需要将 setTransform
替换为 transform
并在操作周围使用 save
和 restore
mapContext.save();
CanvasRenderingContext2D.prototype.transform.apply(
mapContext,
matrix
);
mapContext.drawImage(canvas, 0, 0);
mapContext.restore();
然后将上下文还原到其默认原点并添加标题
mapContext.restore();
链接:https://stackblitz.com/edit/angular-nnsvbj?file=src/main.ts
英文:
To move the drawn image down save the context and translate it down
mapContext.save();
mapContext.translate(0, 50);
When drawing each part of the image you will need to replace setTransform
with transform
and use save
and restore
around the operation
mapContext.save()
CanvasRenderingContext2D.prototype.transform.apply(
mapContext,
matrix
);
mapContext.drawImage(canvas, 0, 0);
mapContext.restore();
Afterwards restore the context to its default origin and add the header
mapContext.restore();
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论