我使用以下代码使用itextsharp
将div内容导出为pdf格式Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=Panel.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
Panel1.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
// Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 100f, 0f);
Document pdfDoc = new Document(new Rectangle(1000f, 1000f));
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();
它显示以下错误
Could not find a part of the path 'C:\Program Files\Common Files\Microsoft Shared\DevServer\10.0\Images\logo.png'.`
如果我在desin中隐藏徽标,则将其导出为pdf但缺少对齐。如何纠正它。我需要导出的页面如下
答案 0 :(得分:0)
为了将内容导出到任何pdf文件,您需要遵循pdf文件的基本约定,这些约定在以下pdf参考的附录G中给出,
http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_reference_1-7.pdf
答案 1 :(得分:0)
class text_speech(base.TemplateView):
.....
@staticmethod
def post(request, *args, **kwargs):
form = forms.input_form(request.POST)
if form.is_valid():
# process the data
.....
# Generate the mp3 file at ./speech.mp3
amazon_polly.amazon_polly(....)
return http.JsonResponse({}, status=200)
else:
return http.JsonResponse({}, status=400)